*& REPORT ZEWM_RE0006
*&
*&---------------------------------------------------------------------*
*& CREATE BY QIANYUN.LIU 2018.8.21
*&
*&---------------------------------------------------------------------*
REPORT ZEWM_RE0006.
TYPE-POOLS SLIS.
TABLES:LIKP,AUFK.
*&---------------------------------------------------------------------*
*& TABLES
*&---------------------------------------------------------------------*
* 模板数据结构
TYPES: BEGIN OF GTY_UPLOAD,
VALUE_0001(10) TYPE C , "销售凭证
VALUE_0002 TYPE POSNR_VA, "销售凭证项目
VALUE_0003(12) TYPE C, "生产订单号
VALUE_0004(18) TYPE C, "物料号
VALUE_0005(13) TYPE C, "目标数量
VALUE_0006(40) TYPE C, "PO/日期码
VALUE_0007(40) TYPE C, "客户货号
END OF GTY_UPLOAD.
TYPES : BEGIN OF TY_DATA ,
VBELN TYPE VBELN_VA, "销售凭证
POSNR TYPE POSNR_VA, "销售凭证项目
AUFNR TYPE AUFNR, "生产订单号
MATNR TYPE MATNR, "物料号
MAKTX TYPE ARKTXT, "物料描述
ZMENG TYPE DZMENG, "目标数量
ZPODAT TYPE ZPODAT, "PO/日期码
ZZHH TYPE ZZHH, "客户货号
ID(30) TYPE C, "
MSG TYPE CHAR255, "
TYPE TYPE CHAR1, "
*--------2018/9/28 ADD BY LQY START---------*
WERKS TYPE WERKS_D,
*--------2018/9/28 ADD BY LQY END-----------*
CHK,"20181023 ADD BY LQY
END OF TY_DATA.
TYPES : BEGIN OF TY_MSG ,
INDEX TYPE I,
ID(30) TYPE C,
MSG TYPE CHAR255,
TYPE TYPE CHAR1,
END OF TY_MSG .
DATA: BEGIN OF GT_TEMPLATE OCCURS 0,
TAB1(40) TYPE C VALUE '销售凭证',
TAB2(10) TYPE C VALUE '销售凭证项目',
TAB3(6) TYPE C VALUE '生产订单号',
TAB4(3) TYPE C VALUE '物料号',
TAB5(10) TYPE C VALUE '目标数量(PCS)',
TAB6(18) TYPE C VALUE 'PO/日期码',
TAB7(18) TYPE C VALUE '客户货号',
TAB8(18) TYPE C VALUE '',
TAB9(18) TYPE C VALUE '',
TAB10(50) TYPE C VALUE '销售凭证,销售凭证项目,物料号3个必填,PO/日期码 与 客户货号 二选一',
END OF GT_TEMPLATE.
DATA: GT_UPLOAD TYPE STANDARD TABLE OF GTY_UPLOAD,
GS_UPLOAD TYPE GTY_UPLOAD.
DATA : GT_DATA TYPE STANDARD TABLE OF TY_DATA,
GS_DATA TYPE TY_DATA,
LT_DATA TYPE STANDARD TABLE OF TY_DATA,
LS_DATA TYPE TY_DATA,
GT_VBAK TYPE STANDARD TABLE OF VBAK,
GS_VBAK TYPE VBAK,
GT_MARA TYPE STANDARD TABLE OF MARA,
GS_MARA TYPE MARA,
GT_ZTPP069 TYPE STANDARD TABLE OF ZTPP069_C,
GS_ZTPP069 TYPE ZTPP069_C
.
DATA: GT_AUFK TYPE STANDARD TABLE OF AUFK,
GS_AUFK TYPE AUFK,
GT_AFKO TYPE STANDARD TABLE OF AFKO,
GS_AFKO TYPE AFKO.
DATA: GT_VBAP TYPE STANDARD TABLE OF VBAP,
GS_VBAP TYPE VBAP.
DATA: IT_FIELD TYPE SLIS_T_FIELDCAT_ALV,
LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: LV_TXT TYPE /LIME/CUST_CATSP-TXT .
DATA: LT_MSG TYPE STANDARD TABLE OF TY_MSG,
LS_MSG TYPE TY_MSG.
DATA:GT_MAKT TYPE STANDARD TABLE OF MAKT,
GS_MAKT TYPE MAKT.
DATA: GT_ZSOPOCON TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON WITH HEADER LINE,
GS_ZSOPOCON TYPE ZTEWM_ZSOPOCON,
GS1_ZSOPOCON TYPE ZTEWM_ZSOPOCON,
LT_ZSOPOCON TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON,
LS_ZSOPOCON TYPE ZTEWM_ZSOPOCON,
LT1_ZSOPOCON TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON,
LS1_ZSOPOCON TYPE ZTEWM_ZSOPOCON,
LT_ZSOPOCONL TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON_L,
LS_ZSOPOCONL TYPE ZTEWM_ZSOPOCON_L,
GT_DEL TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON,
GS_DEL TYPE ZTEWM_ZSOPOCON,
GT_DEL_L TYPE STANDARD TABLE OF ZTEWM_ZSOPOCON_L,
GS_DEL_L TYPE ZTEWM_ZSOPOCON_L,
LV_MSG TYPE CHAR50,
GV_MSG TYPE CHAR1,
LV_RFCDEST TYPE RFCDEST,
G_GRID TYPE REF TO CL_GUI_ALV_GRID,
ZTABIX TYPE I.
DATA:EXCEL_NAME TYPE STRING.
DATA:WL_ANSWER TYPE C. "ADD BY LQY 20181023
*---------------------------------------------------------------------*
* 说明: 定义选择屏幕 *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK T1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
P_PLDR RADIOBUTTON GROUP G1 USER-COMMAND UC , "批量导入
P_CXXG RADIOBUTTON GROUP G1 DEFAULT 'X'. "查询与修改
SELECTION-SCREEN END OF BLOCK T1.
SELECTION-SCREEN BEGIN OF BLOCK T2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS:
S_VBELN FOR LIKP-VBELN,
S_AUFNR FOR AUFK-AUFNR.
SELECTION-SCREEN END OF BLOCK T2.
SELECTION-SCREEN BEGIN OF BLOCK T3 WITH FRAME TITLE TEXT-003.
PARAMETERS:
"P1_PLDR AS CHECKBOX,
P_XZLJ LIKE RLGRAP-FILENAME MODIF ID TP1 .
SELECTION-SCREEN END OF BLOCK T3.
*----------------------------------------------------------------------*
* 说明: 初始化事件
*----------------------------------------------------------------------*
INITIALIZATION.
SET PF-STATUS 'STATUS'.
*----------------------------------------------------------------------*
* 说明: 屏幕输出前处理
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF P_PLDR <> 'X'.
CASE SCREEN-GROUP1.
WHEN 'TP1'.
SCREEN-ACTIVE = '0'.
WHEN OTHERS.
ENDCASE.
ENDIF.
IF P_PLDR = 'X'.
CASE SCREEN-GROUP1.
WHEN 'TP1'.
SCREEN-ACTIVE = '1'.
WHEN OTHERS.
ENDCASE.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
*----------------------------------------------------------------------*
* 说明: 处理选择屏幕字段事件
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
CASE SY-UCOMM .
WHEN 'DOWNLOAD'.
" PERFORM FRM_TEMPLATE.
PERFORM FRM_GER_TEMPLATE USING EXCEL_NAME .
ENDCASE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_XZLJ.
PERFORM GET_P_XZLJ.
*----------------------------------------------------------------------*
* 说明: 数据检索
*----------------------------------------------------------------------*
START-OF-SELECTION.
IF P_PLDR = 'X'.
PERFORM FRM_UPLOAD_FILE.
PERFORM FRM_IMPORT_DATA.
ELSE.
PERFORM FRM_GET_DATA.
ENDIF.
*----------------------------------------------------------------------*
* END OF SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM FRM_DISPLAY_DATA.
*&---------------------------------------------------------------------*
*& FORM FRM_TEMPLATE
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_GER_TEMPLATE USING EXCEL_NAME.
DATA:
LO_OBJDATA LIKE WWWDATATAB,
LS_DESTINATION LIKE RLGRAP-FILENAME,
LS_OBJNAM TYPE STRING,
LI_RC LIKE SY-SUBRC,
LS_ERRTXT TYPE STRING.
DATA:
P_OBJID TYPE WWWDATATAB-OBJID,
P_DEST LIKE SAPB-SAPPFAD,
L_TITLE TYPE STRING,
L_DFNAME TYPE STRING,
L_FILENAME TYPE STRING,
L_PATH TYPE STRING,
L_L_PATH TYPE STRING.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = L_TITLE
DEFAULT_EXTENSION = 'xls'
DEFAULT_FILE_NAME = L_DFNAME
FILE_FILTER = '(EXCEL)'
CHANGING
FILENAME = L_FILENAME
PATH = L_PATH
FULLPATH = L_L_PATH.
LO_OBJDATA-RELID = 'MI'.
LO_OBJDATA-OBJID = 'ZEWM006'.
LS_DESTINATION = L_L_PATH.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = LO_OBJDATA
DESTINATION = LS_DESTINATION
IMPORTING
RC = LI_RC.
IF LI_RC NE 0.
MESSAGE '下载失败,检查输入数据及模板是否上传' TYPE 'E'.
ENDIF.
ENDFORM. " FRM_GER_TEMPLATE
*&---------------------------------------------------------------------*
*& Form FRM_TEMPLATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FRM_TEMPLATE .
REFRESH GT_TEMPLATE.
APPEND GT_TEMPLATE.
"1.获取文件路径 "
DATA LV_FILE TYPE STRING.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',EXCEL,*.XLS.'
MODE = 'S'
IMPORTING
FILENAME = LV_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
ENDIF.
"2.把内表下载到指定文件路径
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = LV_FILE
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = GT_TEMPLATE
EXCEPTIONS
FILE_WRITE_ERROR = 1
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE '下载失败,检查输入数据及模板是否上传' TYPE 'E'.
ENDIF.
ENDFORM. "FRM_TEMPLATE
*&---------------------------------------------------------------------*
*& FORM GET_P_XZLJ
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM GET_P_XZLJ .
DATA: L_RC TYPE I,
L_ACTION TYPE I,
LD_FILE TYPE FILE_TABLE,
LT_FILE TYPE FILETABLE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = LT_FILE
RC = L_RC
USER_ACTION = L_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC = 0
AND L_ACTION IS INITIAL.
READ TABLE LT_FILE INTO LD_FILE INDEX 1.
P_XZLJ = LD_FILE-FILENAME.
ENDIF.
ENDFORM. "GET_P_XZLJ
*&---------------------------------------------------------------------*
*& FORM FRM_UPLOAD_FILE
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_UPLOAD_FILE .
DATA:LT_EXCEL LIKE TABLE OF ALSMEX_TABLINE,
LS_EXCEL TYPE ALSMEX_TABLINE.
CLEAR LS_EXCEL.
FIELD-SYMBOLS TYPE ANY.
DATA:
LV_TIND(4) TYPE N,
LV_ZFIELD(25) TYPE C.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_XZLJ
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 7
I_END_ROW = 10000
TABLES
INTERN = LT_EXCEL "以单元格来保存值
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* IMPLEMENT SUITABLE ERROR HANDLING HERE
ENDIF.
IF LT_EXCEL IS INITIAL.
MESSAGE '导入文件没有数据,请检查!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
LOOP AT LT_EXCEL INTO LS_EXCEL.
AT NEW ROW.
CLEAR GS_UPLOAD.
ENDAT.
LV_TIND = LS_EXCEL-COL.
CONCATENATE 'GS_UPLOAD-VALUE_' LV_TIND INTO LV_ZFIELD.
ASSIGN (LV_ZFIELD) TO .
= LS_EXCEL-VALUE.
AT END OF ROW.
*-------2018/9/21 ADD BY LQY START----*
IF GS_UPLOAD-VALUE_0001 IS INITIAL.
CLEAR:LV_MSG .
CONCATENATE '第' LV_TIND '行销售凭证为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
IF GS_UPLOAD-VALUE_0002 IS INITIAL.
CLEAR:LV_MSG .
CONCATENATE '第' LV_TIND '行销售凭证项目为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
IF GS_UPLOAD-VALUE_0003 IS INITIAL.
CLEAR:LV_MSG .
CONCATENATE '第' LV_TIND '行生产订单号为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
IF GS_UPLOAD-VALUE_0004 IS INITIAL.
CLEAR:LV_MSG .
CONCATENATE '第' LV_TIND '行物料号为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
IF GS_UPLOAD-VALUE_0006 IS INITIAL.
CLEAR:GV_MSG .
CONCATENATE '第' LV_TIND '行PO/日期码为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
IF GS_UPLOAD-VALUE_0007 IS INITIAL.
CLEAR:LV_MSG .
CONCATENATE '第' LV_TIND '行客户货号为空!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
*------2018/9/21 ADD BY LQY END-------*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-VALUE_0001
IMPORTING
OUTPUT = GS_UPLOAD-VALUE_0001.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-VALUE_0002
IMPORTING
OUTPUT = GS_UPLOAD-VALUE_0002.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-VALUE_0003
IMPORTING
OUTPUT = GS_UPLOAD-VALUE_0003.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_UPLOAD-VALUE_0004
IMPORTING
OUTPUT = GS_UPLOAD-VALUE_0004.
APPEND GS_UPLOAD TO GT_UPLOAD.
ENDAT.
ENDLOOP.
IF GT_UPLOAD IS INITIAL.
MESSAGE '导入文件没有数据,请检查!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
SORT LT_EXCEL BY ROW COL.
ENDFORM. "FRM_UPLOAD_FILE
*&---------------------------------------------------------------------*
*& FORM FRM_IMPORT_DATA
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_IMPORT_DATA .
DATA: IR_LGPLA TYPE RSELOPTION,
IS_LGPLA TYPE RSDSSELOPT.
DATA: IR_MATNR TYPE RSELOPTION,
IS_MATNR TYPE RSDSSELOPT.
DATA :IR_CAT TYPE RSELOPTION,
IS_CAT TYPE RSDSSELOPT.
DATA :IR_ENTITLED TYPE RSELOPTION,
IS_ENTITLED TYPE RSDSSELOPT.
*--------2018/9/13 ADD BY LQY START-------------*
DATA: GT1_VBAP TYPE STANDARD TABLE OF VBAP,
GS1_VBAP TYPE VBAP,
GT_ZEWM006QX TYPE STANDARD TABLE OF ZTEWM006_QX,
GS_ZEWM006QX TYPE ZTEWM006_QX,
ZAUFNR TYPE AFKO-AUFNR.
*--------2018/9/13 ADD BY LQY END---------------*
IF GT_UPLOAD IS NOT INITIAL.
*--------2018/9/13 ADD BY LQY START----------*
SELECT
VBELN
POSNR
MATNR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE GT1_VBAP
FOR ALL ENTRIES IN GT_UPLOAD
WHERE VBELN = GT_UPLOAD-VALUE_0001
AND POSNR = GT_UPLOAD-VALUE_0002.
IF GT1_VBAP IS NOT INITIAL.
SELECT
MATNR
ZZCPLY
FROM MARA
INTO CORRESPONDING FIELDS OF TABLE GT_MARA
FOR ALL ENTRIES IN GT1_VBAP
WHERE MATNR = GT1_VBAP-MATNR.
IF GT_MARA IS NOT INITIAL.
SELECT
ZZCPLY
WERKS
FROM ZTPP069_C
INTO CORRESPONDING FIELDS OF TABLE GT_ZTPP069
FOR ALL ENTRIES IN GT_MARA
WHERE ZZCPLY = GT_MARA-ZZCPLY.
ENDIF.
ENDIF.
SELECT
WERKS
ZZH
FROM ZTEWM006_QX
INTO CORRESPONDING FIELDS OF TABLE GT_ZEWM006QX.
SORT GT_ZEWM006QX BY WERKS ZZH.
LOOP AT GT_ZTPP069 INTO GS_ZTPP069.
READ TABLE GT_ZEWM006QX INTO GS_ZEWM006QX WITH KEY WERKS = GS_ZTPP069-WERKS ZZH = SY-UNAME BINARY SEARCH.
IF SY-SUBRC <> 0.
CLEAR:LV_MSG.
CONCATENATE '用户' SY-UNAME '没有工厂' GS_ZTPP069-WERKS '的权限!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR:GS_ZTPP069,GS_ZEWM006QX.
ENDLOOP.
*-------2018/9/13 ADD BY LQY END-------------*
SELECT
VBELN "销售凭证
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE GT_VBAK
FOR ALL ENTRIES IN GT_UPLOAD
WHERE VBELN = GT_UPLOAD-VALUE_0001.
SORT GT_VBAK BY VBELN.
SELECT
AUFNR "生产订单
KDAUF "销售订单
KDPOS "销售订单项目
FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE GT_AUFK
FOR ALL ENTRIES IN GT_UPLOAD
WHERE AUFNR = GT_UPLOAD-VALUE_0003.
SORT GT_AUFK BY AUFNR.
SELECT
MATNR "物料
SPRAS "语言
MAKTX "描述
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE GT_MAKT
FOR ALL ENTRIES IN GT_UPLOAD
WHERE MATNR = GT_UPLOAD-VALUE_0004.
SORT GT_MAKT BY MATNR SPRAS.
IF GT_AUFK IS NOT INITIAL.
SELECT
VBELN "销售订单
POSNR "行项目
MATNR "物料
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE GT_VBAP
FOR ALL ENTRIES IN GT_AUFK
WHERE VBELN = GT_AUFK-KDAUF
AND POSNR = GT_AUFK-KDPOS
.
SORT GT_VBAP BY VBELN POSNR.
ENDIF.
ENDIF.
REFRESH: LT_DATA.
LOOP AT GT_UPLOAD INTO GS_UPLOAD .
GS_DATA-VBELN = GS_UPLOAD-VALUE_0001.
GS_DATA-POSNR = GS_UPLOAD-VALUE_0002.
GS_DATA-AUFNR = GS_UPLOAD-VALUE_0003.
GS_DATA-MATNR = GS_UPLOAD-VALUE_0004.
GS_DATA-ZMENG = GS_UPLOAD-VALUE_0005.
GS_DATA-ZPODAT = GS_UPLOAD-VALUE_0006.
GS_DATA-ZZHH = GS_UPLOAD-VALUE_0007.
LS_DATA-AUFNR = GS_UPLOAD-VALUE_0003.
LS_DATA-ZMENG = GS_UPLOAD-VALUE_0005.
*-------2018/9/28 ADD BY LQY START-------*
"工厂
READ TABLE GT_MARA INTO GS_MARA WITH KEY MATNR = GS_UPLOAD-VALUE_0004.
IF SY-SUBRC = 0.
READ TABLE GT_ZTPP069 INTO GS_ZTPP069 WITH KEY ZZCPLY = GS_MARA-ZZCPLY.
IF SY-SUBRC = 0.
GS_DATA-WERKS = GS_ZTPP069-WERKS.
ENDIF.
ENDIF.
CLEAR:GS_MARA,GS_ZTPP069.
*-------2018/9/28 ADD BY LQY END---------*
"物料描述
READ TABLE GT_MAKT INTO GS_MAKT WITH KEY MATNR = GS_UPLOAD-VALUE_0004 SPRAS = '1' BINARY SEARCH.
IF SY-SUBRC = 0.
GS_DATA-MAKTX = GS_MAKT-MAKTX.
ENDIF.
IF GS_UPLOAD-VALUE_0003 IS NOT INITIAL.
"检查生产订单号是否存在。
READ TABLE GT_AUFK INTO GS_AUFK WITH KEY AUFNR = GS_UPLOAD-VALUE_0003 BINARY SEARCH.
IF SY-SUBRC <> 0.
CLEAR:ZAUFNR.
ZAUFNR = GS_UPLOAD-VALUE_0003.
"去前导零
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = ZAUFNR
IMPORTING
OUTPUT = ZAUFNR.
IF STRLEN( ZAUFNR ) = 9.
CLEAR :LV_MSG.
CONCATENATE '生产订单号' GS_UPLOAD-VALUE_0003 '不存在!' INTO LV_MSG.
CONDENSE LV_MSG NO-GAPS .
GS_DATA-MSG = LV_MSG .
GS_DATA-TYPE = 'E'.
GS_DATA-ID = '@0A@' .
APPEND GS_DATA TO GT_DATA .
CLEAR:GS_UPLOAD,GS_AUFK,GS_DATA.
CONTINUE.
ENDIF.
ELSE.
ENDIF.
READ TABLE GT_VBAP INTO GS_VBAP WITH KEY VBELN = GS_UPLOAD-VALUE_0001 POSNR = GS_UPLOAD-VALUE_0002 BINARY SEARCH.
IF SY-SUBRC = 0.
"检查物料号是否存在。
IF GS_VBAP-MATNR IS INITIAL.
CLEAR :LV_MSG.
CONCATENATE '物料号' GS_VBAP-MATNR '不存在!' INTO LV_MSG.
CONDENSE LV_MSG NO-GAPS .
GS_DATA-MSG = LV_MSG .
GS_DATA-TYPE = 'E'.
GS_DATA-ID = '@0A@' .
APPEND GS_DATA TO GT_DATA .
CLEAR:GS_UPLOAD,GS_AUFK,GS_VBAP,GS_DATA.
CONTINUE.
ENDIF.
ELSE.
IF STRLEN( ZAUFNR ) = 9.
"检查销售凭证行项目是否存在。
CLEAR :LV_MSG.
CONCATENATE '销售凭证' GS_UPLOAD-VALUE_0001 '行项目' GS_UPLOAD-VALUE_0002 '不存在!' INTO LV_MSG.
CONDENSE LV_MSG NO-GAPS .
GS_DATA-MSG = LV_MSG .
GS_DATA-TYPE = 'E'.
GS_DATA-ID = '@0A@' .
APPEND GS_DATA TO GT_DATA .
CLEAR:GS_UPLOAD,GS_AUFK,GS_VBAP,GS_DATA.
CONTINUE.
ENDIF.
ENDIF.
ELSE.
"如果生产订单号为空就只检查销售凭证是否存在。
READ TABLE GT_VBAK TRANSPORTING NO FIELDS WITH KEY VBELN = GS_UPLOAD-VALUE_0001 BINARY SEARCH.
IF SY-SUBRC <> 0.
CLEAR :LV_MSG.
CONCATENATE '销售凭证' GS_UPLOAD-VALUE_0001 '不存在!' INTO LV_MSG.
CONDENSE LV_MSG NO-GAPS .
GS_DATA-MSG = LV_MSG .
GS_DATA-TYPE = 'E'.
GS_DATA-ID = '@0A@' .
APPEND GS_DATA TO GT_DATA .
CLEAR:GS_UPLOAD,GS_AUFK,GS_VBAP,GS_DATA.
CONTINUE.
ENDIF.
ENDIF.
IF GS_DATA-TYPE = ''.
GS_DATA-MSG = '检查成功!' .
GS_DATA-TYPE = 'S'.
GS_DATA-ID = '@08@' .
ELSE .
SHIFT GS_DATA-MSG .
ENDIF.
APPEND GS_DATA TO GT_DATA .
COLLECT LS_DATA INTO LT_DATA.
CLEAR: GS_UPLOAD ,LV_MSG,GS_DATA,GS_AUFK,GS_VBAP.
ENDLOOP.
* IF LT_DATA IS NOT INITIAL.
* SELECT
* AUFNR "订单
* GAMNG "目标数量
* FROM AFKO
* INTO CORRESPONDING FIELDS OF TABLE GT_AFKO
* FOR ALL ENTRIES IN LT_DATA
* WHERE AUFNR = LT_DATA-AUFNR.
* ENDIF.
* LOOP AT LT_DATA INTO LS_DATA.
* READ TABLE GT_AFKO INTO GS_AFKO WITH KEY AUFNR = LS_DATA-AUFNR.
* IF SY-SUBRC = 0.
* IF LS_DATA-ZMENG > GS_AFKO-GAMNG.
* CLEAR:LV_MSG.
* CONCATENATE '生产订单' LS_DATA-AUFNR '的数量合计大于订单目标数量!' INTO LV_MSG.
* MESSAGE LV_MSG TYPE 'S' DISPLAY LIKE 'E'.
* LEAVE LIST-PROCESSING.
* ENDIF.
* ENDIF.
* CLEAR:LS_DATA,GS_AFKO.
* ENDLOOP.
ENDFORM. "FRM_IMPORT_DATA
*
**&---------------------------------------------------------------------*
**& FORM FRM_DISPLAY_DATA
**&---------------------------------------------------------------------*
** TEXT
**----------------------------------------------------------------------*
** --> P1 TEXT
** <-- P2 TEXT
**----------------------------------------------------------------------*
FORM FRM_DISPLAY_DATA .
*报表显示
PERFORM FRM_FIELD_INFO .
LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LS_LAYOUT-ZEBRA = 'X'.
LS_LAYOUT-BOX_FIELDNAME = 'CHK'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND '
I_SAVE = 'A'
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = IT_FIELD
TABLES
T_OUTTAB = GT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* IMPLEMENT SUITABLE ERROR HANDLING HERE
ENDIF.
ENDFORM. "FRM_DISPLAY_DATA
*&---------------------------------------------------------------------*
*& FORM SET_STATUS
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_EXTAB TEXT
*----------------------------------------------------------------------*
FORM SET_STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS'ZST01'.
ENDFORM. "SET_STATUS
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE P_UCOMM.
WHEN '%IMPORT'.
" 刷新ALV报表
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = G_GRID.
CALL METHOD G_GRID->CHECK_CHANGED_DATA.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.
RS_SELFIELD-REFRESH = 'X'.
"检查是否有报错信息
READ TABLE GT_DATA TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
MESSAGE '有错误信息!' TYPE 'E'.
ENDIF.
"数量检查
REFRESH:LT_DATA.
LOOP AT GT_DATA INTO GS_DATA.
LS_DATA-AUFNR = GS_DATA-AUFNR.
LS_DATA-ZMENG = GS_DATA-ZMENG.
COLLECT LS_DATA INTO LT_DATA.
CLEAR:GS_DATA,LS_DATA.
ENDLOOP.
IF P_PLDR <> 'X' AND LT_DATA IS NOT INITIAL.
SELECT
AUFNR "订单
GAMNG "目标数量
FROM AFKO
INTO CORRESPONDING FIELDS OF TABLE GT_AFKO
FOR ALL ENTRIES IN LT_DATA
WHERE AUFNR = LT_DATA-AUFNR.
ENDIF.
"检查报表输出后数量可能有所更改再次对数量进行检查。
LOOP AT LT_DATA INTO LS_DATA.
READ TABLE GT_AFKO INTO GS_AFKO WITH KEY AUFNR = LS_DATA-AUFNR.
IF SY-SUBRC = 0.
IF LS_DATA-ZMENG > GS_AFKO-GAMNG.
CLEAR:LV_MSG.
CONCATENATE '生产订单' LS_DATA-AUFNR '的数量合计大于订单目标数量!' INTO LV_MSG.
MESSAGE LV_MSG TYPE 'E'.
ENDIF.
ENDIF.
CLEAR:LS_DATA,GS_AFKO.
ENDLOOP.
*-----2018/9/20 ADD BY LQY START-------------*
DELETE GT_DATA WHERE ZPODAT IS INITIAL.
DELETE GT_DATA WHERE ZZHH IS INITIAL.
*----2018/9/20 ADD BY LQY END----------------*
IF P_PLDR = 'X' AND GT_DATA IS NOT INITIAL.
SELECT
* VBELN "销售凭证
* POSNR "项目
* GUID "UUID
* AUFNR "订单号
* ERNAM "创建者
* ERDAT "创建日期
* ERZET "时间
*
FROM ZTEWM_ZSOPOCON
INTO CORRESPONDING FIELDS OF TABLE GT_ZSOPOCON
FOR ALL ENTRIES IN GT_DATA
WHERE VBELN = GT_DATA-VBELN
AND POSNR = GT_DATA-POSNR.
SORT GT_ZSOPOCON BY VBELN POSNR.
ENDIF.
LOOP AT GT_DATA INTO GS_DATA.
MOVE-CORRESPONDING GS_DATA TO LS_ZSOPOCON.
MOVE-CORRESPONDING GS_DATA TO LS_ZSOPOCONL.
"READ TABLE GT_ZSOPOCON INTO GS_ZSOPOCON WITH KEY VBELN = GS_DATA-VBELN POSNR = GS_DATA-POSNR.
CLEAR:ZTABIX.
READ TABLE GT_ZSOPOCON INTO GS1_ZSOPOCON WITH KEY VBELN = GS_DATA-VBELN POSNR = GS_DATA-POSNR.
IF SY-SUBRC = 0.
"如果原先有记录就只修改修改人
ZTABIX = SY-TABIX.
LS_ZSOPOCON-ERNAM = GS1_ZSOPOCON-ERNAM.
LS_ZSOPOCON-ERDAT = GS1_ZSOPOCON-ERDAT.
LS_ZSOPOCON-ERZET = GS1_ZSOPOCON-ERZET.
LS_ZSOPOCON-GUID = CL_SYSTEM_UUID=>CREATE_UUID_X16_STATIC( ).
LS_ZSOPOCONL-GUID = LS_ZSOPOCON-GUID.
LS_ZSOPOCONL-ERNAM = GS1_ZSOPOCON-ERNAM.
LS_ZSOPOCONL-ERDAT = GS1_ZSOPOCON-ERDAT.
LS_ZSOPOCONL-ERZET = GS1_ZSOPOCON-ERZET.
LS_ZSOPOCONL-CHNAM = SY-UNAME.
LS_ZSOPOCONL-CHDAT = SY-DATUM.
LS_ZSOPOCONL-CHZET = SY-UZEIT.
LOOP AT GT_ZSOPOCON INTO GS_ZSOPOCON FROM ZTABIX WHERE VBELN = GS_DATA-VBELN AND POSNR = GS_DATA-POSNR.
APPEND GS_ZSOPOCON TO LT1_ZSOPOCON.
CLEAR:GS_ZSOPOCON.
ENDLOOP.
ELSE.
"如果原先表里面没有数据就赋值当前值
LS_ZSOPOCON-ERNAM = SY-UNAME.
LS_ZSOPOCON-ERDAT = SY-DATUM.
LS_ZSOPOCON-ERZET = SY-UZEIT.
LS_ZSOPOCON-GUID = CL_SYSTEM_UUID=>CREATE_UUID_X16_STATIC( ).
LS_ZSOPOCONL-GUID = LS_ZSOPOCON-GUID.
LS_ZSOPOCONL-ERNAM = SY-UNAME.
LS_ZSOPOCONL-ERDAT = SY-DATUM.
LS_ZSOPOCONL-ERZET = SY-UZEIT.
LS_ZSOPOCONL-CHNAM = SY-UNAME.
LS_ZSOPOCONL-CHDAT = SY-DATUM.
LS_ZSOPOCONL-CHZET = SY-UZEIT.
ENDIF.
APPEND LS_ZSOPOCON TO LT_ZSOPOCON.
APPEND LS_ZSOPOCONL TO LT_ZSOPOCONL.
CLEAR:GS_DATA,LS_ZSOPOCON,LS_ZSOPOCONL,GS1_ZSOPOCON.
ENDLOOP.
* IF SY-MANDT = '120'.
* LV_RFCDEST = 'WMDCLNT120'.
* ELSEIF SY-MANDT = '210'.
* LV_RFCDEST = 'WMQCLNT200'.
* ELSEIF SY-MANDT = '800'.
* LV_RFCDEST = 'WMPCLNT800'.
* ENDIF.
"更新数据库表
DELETE ADJACENT DUPLICATES FROM LT1_ZSOPOCON COMPARING VBELN POSNR AUFNR MATNR ZMENG ZPODAT ZZHH ERNAM ERDAT ERZET.
* DELETE ADJACENT DUPLICATES FROM LT_ZSOPOCON COMPARING VBELN POSNR AUFNR MATNR ZMENG ZPODAT ZZHH ERNAM ERDAT ERZET.
* DELETE ADJACENT DUPLICATES FROM LT_ZSOPOCONL COMPARING VBELN POSNR AUFNR MATNR ZMENG ZPODAT ZZHH ERNAM ERDAT ERZET CHNAM CHDAT CHZET.
DELETE ZTEWM_ZSOPOCON FROM TABLE LT1_ZSOPOCON.
MODIFY ZTEWM_ZSOPOCON FROM TABLE LT_ZSOPOCON.
MODIFY ZTEWM_ZSOPOCON_L FROM TABLE LT_ZSOPOCONL.
IF SY-SUBRC = 0.
* CALL FUNCTION 'ZFM_EWM0002_008'
* DESTINATION LV_RFCDEST
* IMPORTING
* EV_MSG = GV_MSG
* TABLES
* IT_ZSOPOCON = LT_ZSOPOCON
* IT1_ZSOPOCON = LT1_ZSOPOCON.
"调整程序:改用proxy调用po接口 by sean 20190809
"定义数据
DATA LV_INPUT TYPE ZZFM_EWM0002_008_INPUT.
DATA LV_OUTPUT TYPE ZZFM_EWM0002_008_OUTPUT.
DATA LV_IF_MTYPE TYPE C.
DATA LV_IF_MSG TYPE BAPI_MSG.
"处理输入数据
PERFORM CONVERT_TABLES(ZPO_FORMPOOL001) IF FOUND TABLES LT_ZSOPOCON "输入表
LV_INPUT-IT_ZSOPOCON."输处表
PERFORM CONVERT_TABLES(ZPO_FORMPOOL001) IF FOUND TABLES LT1_ZSOPOCON "输入表
LV_INPUT-IT1_ZSOPOCON."输处表
"调用接口
PERFORM CALL_INTERFACE_METHOD(ZPO_FORMPOOL001) IF FOUND USING 'ZCO_SI_EWM016_ERP2EWM_PROXY2PR' "proxy类名称
'SI_EWM016_ERP2EWM_PROXY2PROXY' "方法名称
LV_INPUT "输入参数
CHANGING LV_OUTPUT "输出参数
LV_IF_MTYPE "是否出现异常
LV_IF_MSG "异常信息
.
"处理返回数据
GV_MSG = LV_OUTPUT-EV_MSG.
IF LV_IF_MTYPE = 'E'.
GV_MSG = LV_IF_MTYPE.
ENDIF.
IF GV_MSG = 'S'.
COMMIT WORK AND WAIT.
MESSAGE '数据更新成功' TYPE 'S'.
ELSE.
ROLLBACK WORK.
IF LV_IF_MTYPE = 'E'.
MESSAGE LV_IF_MSG TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
MESSAGE 'EWM数据更新失败' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ELSE.
ROLLBACK WORK.
MESSAGE 'ECC数据更新失败' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
REFRESH:LT_ZSOPOCON,LT_ZSOPOCONL.
WHEN '%DEL'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TEXT_QUESTION = '该操作会删除选中的数据,确认删除?'
ICON_BUTTON_1 = '是'
ICON_BUTTON_2 = '否'
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
START_COLUMN = 25
START_ROW = 6
IMPORTING
ANSWER = WL_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
CHECK WL_ANSWER = '1' .
LOOP AT GT_DATA INTO GS_DATA WHERE CHK = 'X'.
MOVE-CORRESPONDING GS_DATA TO GS_DEL.
MOVE-CORRESPONDING GS_DATA TO GS_DEL_L.
APPEND GS_DEL TO GT_DEL.
APPEND GS_DEL_L TO GT_DEL_L.
DELETE GT_DATA INDEX SY-TABIX.
ENDLOOP.
* MODIFY ZTEWM_ZSOPOCON FROM TABLE LT_ZSOPOCON.
* MODIFY ZTEWM_ZSOPOCON_L FROM TABLE LT_ZSOPOCONL.
LOOP AT GT_DEL INTO GS_DEL.
DELETE FROM ZTEWM_ZSOPOCON WHERE VBELN = GS_DEL-VBELN AND POSNR = GS_DEL-POSNR AND MATNR = GS_DEL-MATNR.
DELETE FROM ZTEWM_ZSOPOCON_L WHERE VBELN = GS_DEL-VBELN AND POSNR = GS_DEL-POSNR AND MATNR = GS_DEL-MATNR.
ENDLOOP.
IF SY-MANDT = '120'.
LV_RFCDEST = 'WMDCLNT120'.
ELSEIF SY-MANDT = '210'.
LV_RFCDEST = 'WMQCLNT200'.
ELSEIF SY-MANDT = '800'.
LV_RFCDEST = 'WMPCLNT800'.
ENDIF.
CLEAR:GV_MSG.
CALL FUNCTION 'ZFM_EWM0002_009'
DESTINATION LV_RFCDEST
IMPORTING
EV_FLAG = GV_MSG
TABLES
IT_SCAN = GT_DEL.
IF GV_MSG = 'X'.
COMMIT WORK AND WAIT.
MESSAGE '数据更新成功' TYPE 'S'.
ELSE.
ROLLBACK WORK .
MESSAGE '数据更新失败' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = G_GRID.
CALL METHOD G_GRID->CHECK_CHANGED_DATA.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.
RS_SELFIELD-REFRESH = 'X'.
WHEN OTHERS.
ENDCASE.
RS_SELFIELD-REFRESH = 'X'.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& FORM FRM_FIELD_INFO
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_FIELD_INFO .
CLEAR IT_FIELD.
PERFORM FRM_FIELDCAT_SET USING: 'VBELN' '销售凭证' 15 'X' '' 'X' ,
'POSNR' '销售凭证项目' 8 '' '' '' ,
'AUFNR' '生产订单号' 10 '' '' '' ,
*---------------2018/9/28 ADD BY LQY START------------*
'WERKS' '工厂' 10 '' '' '',
*--------------2018/9/28 ADD BY LQY END----------------*
'MATNR' '物料号' 15 'X' '' '' ,
'MAKTX' '物料描述' 15 'X' '' '' ,
'ZMENG' '目标数量' 15 '' 'X' '' ,
'ZPODAT' 'PO/日期码' 8 '' 'X' '' ,
'ZZHH' '客户货号' 15 'X' 'X' '' ,
'MSG' '消息' 15 '' '' '' ,
'TYPE' '状态' 8 '' '' '',
'ID' '备注' 8 '' '' ''
.
ENDFORM. "FRM_FIELD_INFO
*&---------------------------------------------------------------------*
*& FORM FRM_FIELDCAT_SET
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_1640 TEXT
* -->P_1641 TEXT
* -->P_15 TEXT
* -->P_1643 TEXT
* -->P_1644 TEXT
* -->P_1645 TEXT
*----------------------------------------------------------------------*
FORM FRM_FIELDCAT_SET USING FIELDNAME TYPE SLIS_FIELDCAT_ALV-FIELDNAME
SELTEXT TYPE SLIS_FIELDCAT_ALV-SELTEXT_L
OUTPUTLEN TYPE SLIS_FIELDCAT_ALV-OUTPUTLEN
NO_ZERO TYPE SLIS_FIELDCAT_ALV-NO_ZERO
EDIT TYPE SLIS_FIELDCAT_ALV-EDIT
KEY TYPE SLIS_FIELDCAT_ALV-KEY .
DATA:IS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
IS_FIELDCAT-FIELDNAME = FIELDNAME.
IS_FIELDCAT-SELTEXT_S = SELTEXT.
IS_FIELDCAT-SELTEXT_M = SELTEXT.
IS_FIELDCAT-SELTEXT_L = SELTEXT.
IS_FIELDCAT-OUTPUTLEN = OUTPUTLEN.
IS_FIELDCAT-NO_ZERO = NO_ZERO.
IS_FIELDCAT-EDIT = EDIT.
IS_FIELDCAT-KEY = KEY .
IF IS_FIELDCAT-FIELDNAME = 'VSOLA'.
IS_FIELDCAT-DECIMALS_OUT = 3.
ENDIF.
APPEND IS_FIELDCAT TO IT_FIELD.
CLEAR IS_FIELDCAT.
ENDFORM. "FRM_FIELDCAT_SET
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
SELECT
VBELN "销售凭证
POSNR "销售凭证项目
AUFNR "订单号
MATNR "物料号
ZMENG "销售单位目标数量
ZPODAT "PO/日期码
ZZHH "货号
ERNAM "创建者
ERDAT "创建日期
ERZET "时间
FROM ZTEWM_ZSOPOCON
INTO CORRESPONDING FIELDS OF TABLE GT_ZSOPOCON
WHERE VBELN IN S_VBELN
AND AUFNR IN S_AUFNR.
IF GT_ZSOPOCON[] IS NOT INITIAL.
SELECT
MATNR "物料
SPRAS "语言
MAKTX "描述
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE GT_MAKT
FOR ALL ENTRIES IN GT_ZSOPOCON[]
WHERE MATNR = GT_ZSOPOCON-MATNR
AND SPRAS = '1'
.
SELECT
MATNR
ZZCPLY
FROM MARA
INTO CORRESPONDING FIELDS OF TABLE GT_MARA
FOR ALL ENTRIES IN GT_ZSOPOCON[]
WHERE MATNR = GT_ZSOPOCON-MATNR.
IF GT_MARA IS NOT INITIAL.
SELECT
ZZCPLY
WERKS
FROM ZTPP069_C
INTO CORRESPONDING FIELDS OF TABLE GT_ZTPP069
FOR ALL ENTRIES IN GT_MARA
WHERE ZZCPLY = GT_MARA-ZZCPLY.
ENDIF.
ENDIF.
LOOP AT GT_ZSOPOCON INTO GS_ZSOPOCON.
MOVE-CORRESPONDING GS_ZSOPOCON TO GS_DATA.
READ TABLE GT_MAKT INTO GS_MAKT WITH KEY MATNR = GS_DATA-MATNR SPRAS = '1'.
IF SY-SUBRC = 0.
GS_DATA-MAKTX = GS_MAKT-MAKTX.
ENDIF.
*------2018/9/28 ADD BY LQY START--------*
"工厂
READ TABLE GT_MARA INTO GS_MARA WITH KEY MATNR = GS_ZSOPOCON-MATNR.
IF SY-SUBRC = 0.
READ TABLE GT_ZTPP069 INTO GS_ZTPP069 WITH KEY ZZCPLY = GS_MARA-ZZCPLY.
IF SY-SUBRC = 0.
GS_DATA-WERKS = GS_ZTPP069-WERKS.
ENDIF.
ENDIF.
CLEAR:GS_MARA,GS_ZTPP069.
*------2018/9/28 ADD BY LQY END----------*
GS_DATA-MSG = '检查成功!' .
GS_DATA-TYPE = 'S'.
GS_DATA-ID = '@08@' .
APPEND GS_DATA TO GT_DATA.
CLEAR:GS_ZSOPOCON,GS_DATA,GS_MAKT.
ENDLOOP.
ENDFORM. " FRM_GET_DATA