工艺路线详解
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
REPORT ZPP_BDC_CREATE_ROUTING NO STANDARD PAGE HEADING
MESSAGE-ID ZSSMCMP
LINE-SIZE 132
LINE-COUNT 65(3).
CONSTANTS:C_FILENAME LIKE RLGRAP-FILENAME VALUE 'D:\ZCA01.TXT',
C_FILETYPE LIKE RLGRAP-FILETYPE VALUE 'DAT'.
DATA:G_ITEMCOUNT TYPE I VALUE '0'.
DATA:MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA:L_MSTRING(480).
DATA:L_FALG TYPE C,L_FALG1 TYPE C.
DATA:SUM TYPE I,ZSUM TYPE I.
TABLES:T100.
DATA:BEGIN OF I_DATA OCCURS 0,
MATNR LIKE RC29N-MATNR,
WERKS LIKE RC29N-WERKS,
PLNNR LIKE RC271-PLNNR,
PLNAL LIKE PLKOD-PLNAL,
KTEXT LIKE PLKOD-KTEXT,
* PLNME LIKE PLKOD-PLNME,
ARBPL LIKE PLPOD-ARBPL,
STEUS LIKE PLPOD-STEUS,
LTXA1 LIKE PLPOD-LTXA1,
BMSCH(13),
VGW01(9),
VGW02(9),
VGW03(9),
VGW04(9),
VGW05(9),
VGW06(9),
END OF I_DATA.
DATA:BEGIN OF I_DATA2 OCCURS 0,
MATNR LIKE RC29N-MATNR,
WERKS LIKE RC29N-WERKS,
PLNNR LIKE RC271-PLNNR,
END OF I_DATA2.
DATA:BEGIN OF I_DATA3 OCCURS 0,
MATNR LIKE RC29N-MATNR,
WERKS LIKE RC29N-WERKS,
PLNAL LIKE PLKOD-PLNAL,
KTEXT LIKE PLKOD-KTEXT,
NUM(2) TYPE N,
END OF I_DATA3.
DATA:T_BDC LIKE STANDARD TABLE OF BDCDATA INITIAL SIZE 0 WITH HEADER
LINE.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETER PP_GROUP(12) DEFAULT 'PP_ROUTING'.
SELECTION-SCREEN END OF BLOCK A1.
INITIALIZATION.
START-OF-SELECTION.
PERFORM OPEN_DATA_FILE TABLES I_DATA.
PERFORM GENERATE_BDC_SESSION USING PP_GROUP.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form OPEN_DATA_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_DATA text
*----------------------------------------------------------------------*
FORM OPEN_DATA_FILE TABLES ITAB.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = C_FILENAME
FILETYPE = C_FILETYPE
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '001' WITH '上传失败!'.
ENDIF.
ENDFORM. " OPEN_DATA_FILE
*&---------------------------------------------------------------------*
*& Form GENERATE_BDC_SESSION
*&---------------------------------------------------------------------*
* text
*-----------------------
-----------------------------------------------*
* -->P_PP_GROUP text
*----------------------------------------------------------------------*
FORM GENERATE_BDC_SESSION USING SESSION_NAME.
PERFORM OPEN_GROUP USING SESSION_NAME.
PERFORM GET_IDATAS.
CLEAR:I_DATA,I_DATA2,I_DATA3.
DATA:L_FLAG1,L_FLAG2.
SORT I_DATA3 BY MATNR WERKS NUM.
LOOP AT I_DATA2.
CLEAR:I_DATA3,I_DATA.
L_FLAG1 = 'X'.
* READ TABLE I_DATA INDEX SY-TABIX.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1010',
' ' 'BDC_OKCODE' '=XALU',
' ' 'RC27M-MATNR' I_DATA2-MATNR,
' ' 'RC27M-WERKS' I_DATA2-WERKS,
' ' 'RC271-PLNNR' I_DATA2-PLNNR.
LOOP AT I_DATA3 WHERE MATNR = I_DATA2-MATNR AND WERKS = I_DATA2-WERKS.
CLEAR I_DATA.
L_FLAG2 = 'X'.
IF L_FLAG1 = 'X'.
CLEAR L_FLAG1.
ELSE.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDA' '1200',
' ' 'BDC_OKCODE' '=ANLG'.
ENDIF.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDA' '1200',
' ' 'BDC_OKCODE' '=VOUE',
' ' 'PLKOD-KTEXT' I_DATA3-KTEXT,
* ' ' 'PLKOD-WERKS' I_DATA-WERKS,
* ' ' 'PLKOD-PLNME' I_DATA-PLNME,
' ' 'PLKOD-VERWE' '1',
' ' 'PLKOD-STATU' '4'.
* ' ' 'PLKOD-PLNME' 'PC'.
LOOP AT I_DATA WHERE MATNR = I_DATA3-MATNR AND WERKS = I_DATA3-WERKS
AND PLNAL = I_DATA3-PLNAL.
IF L_FLAG2 = 'X'.
CLEAR L_FLAG2.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
* ' ' 'BDC_CURSOR' 'PLPOD-VORNR(01)',
' ' 'BDC_OKCODE' '/00',
' ' 'PLPOD-ARBPL(01)' I_DATA-ARBPL,
' ' 'PLPOD-STEUS(01)' I_DATA-STEUS,
' ' 'PLPOD-LTXA1(01)' I_DATA-LTXA1.
* ' ' 'PLPOD-BMSCH(01)' I_DATA-BMSCH.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
' ' 'BDC_CURSOR' 'PLPOD-VORNR(01)',
' ' 'BDC_OKCODE' '=PICK',
' ' 'RC27X-ENTRY_ACT' '1'.
ELSE.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
' ' 'BDC_OKCODE' '/00',
' ' 'PLPOD-ARBPL(02)' I_DATA-ARBPL,
' ' 'PLPOD-STEUS(02)' I_DATA-STEUS,
' ' 'PLPOD-LTXA1(02)' I_DATA-LTXA1.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
' ' 'BDC_CURSOR' 'PLPOD-VORNR(02)',
' ' 'BDC_OKCODE' '=PICK',
' ' 'RC27X-ENTRY_ACT' '1'.
ENDIF.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDO' '1200
',
' ' 'BDC_OKCODE' '=BACK',
' ' 'PLPOD-BMSCH' I_DATA-BMSCH,
' ' 'PLPOD-UMREZ' '1',
' ' 'PLPOD-UMREN' '1',
' ' 'PLPOD-VGW01' I_DATA-VGW01,
' ' 'PLPOD-VGW02' I_DATA-VGW02,
' ' 'PLPOD-VGW03' I_DATA-VGW03,
' ' 'PLPOD-VGW04' I_DATA-VGW04,
' ' 'PLPOD-VGW05' I_DATA-VGW05,
' ' 'PLPOD-VGW06' I_DATA-VGW06.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
' ' 'BDC_OKCODE' '=P+',
' ' 'RC27X-ENTRY_ACT' '1'.
ENDLOOP.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDI' '1400',
' ' 'BDC_OKCODE' '=ALD1',
' ' 'RC27X-ENTRY_ACT' '2'.
ENDLOOP.
PERFORM FILL_BDC_TABLE USING:'1' 'SAPLCPDA' '1200',
' ' 'BDC_OKCODE' '=BU'.
CALL TRANSACTION 'CA01' USING T_BDC MODE 'E' MESSAGES INTO MESSTAB.
LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
ELSE.
L_MSTRING = '无可用信息!'.
ENDIF.
ENDLOOP.
WRITE:/ I_DATA-MATNR,L_MSTRING.
CLEAR T_BDC.
REFRESH T_BDC.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
ENDFORM. " GENERATE_BDC_SESSION
FORM OPEN_GROUP USING SESSION_NAME.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = SESSION_NAME
USER = SY-UNAME
.
IF SY-SUBRC <> 0.
MESSAGE ID '00' TYPE 'E' NUMBER '001' WITH 'BDC_OPEN失败!'.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_BDC_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0182 text
* -->P_0183 text
* -->P_0184 text
*----------------------------------------------------------------------*
FORM FILL_BDC_T
ABLE USING TMP_FLAG
TMP_VAR1
TMP_VAR2.
CLEAR T_BDC.
IF TMP_FLAG = '1'.
T_BDC-PROGRAM = TMP_VAR1.
T_BDC-DYNPRO = TMP_VAR2.
T_BDC-DYNBEGIN = 'X'.
ELSE.
T_BDC-FNAM = TMP_VAR1.
T_BDC-FVAL = TMP_VAR2.
ENDIF.
APPEND T_BDC.
ENDFORM. " FILL_BDC_TABLE
*&---------------------------------------------------------------------*
*& Form GET_IDATAS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_IDATAS.
DATA:L_MATNR LIKE MARA-MATNR,
L_WERKS LIKE MARC-WERKS,
L_PLNAL LIKE PLKOD-PLNAL,
T_TAB LIKE STANDARD TABLE OF I_DATA WITH HEADER LINE.
T_TAB[] = I_DATA[].
SORT T_TAB BY MATNR WERKS PLNAL.
LOOP AT T_TAB.
IF T_TAB-MATNR NE L_MATNR OR T_TAB-WERKS NE L_WERKS.
MOVE-CORRESPONDING T_TAB TO I_DATA2.
APPEND I_DATA2.
ENDIF.
IF T_TAB-MATNR NE L_MATNR OR T_TAB-WERKS NE L_WERKS OR
T_TAB-PLNAL NE L_PLNAL.
MOVE-CORRESPONDING T_TAB TO I_DATA3.
I_DATA3-NUM = I_DATA3-PLNAL.
APPEND I_DATA3.
ENDIF.
MOVE T_TAB-MATNR TO L_MATNR.
MOVE T_TAB-WERKS TO L_WERKS.
MOVE T_TAB-PLNAL TO L_PLNAL.
ENDLOOP.
CLEAR:T_TAB.
REFRESH:T_TAB.
ENDFORM. " GET_IDATAS