Vous êtes sur la page 1sur 10

report ZROUTING3 no standard page heading line-size 255. include bdcrecx1.

TYPES: BEGIN OF S_UPLOAD, MATNR TYPE WERKS TYPE INDICATOR1 INDICATOR_R1 ARBPL TYPE STEUS TYPE VGW01 TYPE VGE01 TYPE VGW02 TYPE VGE02 TYPE VGW03 TYPE VGE03 TYPE RC27M-MATNR, RC27M-WERKS, TYPE C, TYPE C, PLKOD-ARBPL, PLPOD-STEUS, N,"PLPOD-VGW01, PLPOD-VGE01, N,"PLPOD-VGW02, PLPOD-VGE02, N,"PLPOD-VGW03, PLPOD-VGE03,

END OF S_UPLOAD. TYPES: BEGIN OF S_WORK_C, MATNR TYPE RC27M-MATNR, INDICATOR TYPE C, ARBPL TYPE PLKOD-ARBPL, STEUS TYPE PLPOD-STEUS, VGW01 TYPE PLPOD-VGW01, VGE01 TYPE PLPOD-VGE01, VGW02 TYPE PLPOD-VGW02, VGE02 TYPE PLPOD-VGE02, VGW03 TYPE PLPOD-VGW03, VGE03 TYPE PLPOD-VGE03, END OF S_WORK_C. DATA: IT_UPLOAD WA_UPLOAD WA_UPLOAD1 IT_HEADER WA_HEADER IT_WORK_C_H WA_WORK_C_H WA_WORK_C_H1 IT_WORK_C_I WA_WORK_C_I WA_WORK_C_I1 LV_FILENAME TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TABLE OF S_UPLOAD, S_UPLOAD, S_UPLOAD, TABLE OF S_UPLOAD, S_UPLOAD, TABLE OF S_UPLOAD, S_UPLOAD, S_UPLOAD, TABLE OF S_UPLOAD, S_UPLOAD, S_UPLOAD, STRING.

DATA: COUNTER1 COUNTER2 T_FNAM T_FVAL

TYPE TYPE TYPE TYPE

N LENGTH 2, N LENGTH 2, BDCDATA-FNAM, BDCDATA-FVAL.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-011. PARAMETERS : P_FILE TYPE RLGRAP-FILENAME, P_MODE TYPE C OBLIGATORY DEFAULT 'N'. SELECTION-SCREEN END OF BLOCK B1. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE. CALL FUNCTION 'F4_FILENAME' EXPORTING PROGRAM_NAME = SYST-CPROG DYNPRO_NUMBER = SYST-DYNNR FIELD_NAME = ' ' IMPORTING FILE_NAME = P_FILE. LV_FILENAME = P_FILE. START-OF-SELECTION. PERFORM GUI_UPLOAD. PERFORM GET_HEADER_MATNR. PERFORM BDCDATA. END-OF-SELECTION. FORM GUI_UPLOAD. CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename FILETYPE HAS_FIELD_SEPARATOR * HEADER_LENGTH * READ_BY_LINE * DAT_MODE * CODEPAGE * IGNORE_CERR * REPLACEMENT * CHECK_BOM * VIRUS_SCAN_PROFILE * NO_AUTH_CHECK * IMPORTING * FILELENGTH * HEADER tables

= LV_FILENAME = 'ASC' = 'X' = 0 = 'X' = ' ' = ' ' = ABAP_TRUE = '#' = ' ' = = ' ' = =

data_tab = IT_UPLOAD. * EXCEPTIONS * FILE_OPEN_ERROR = 1 * FILE_READ_ERROR = 2 * NO_BATCH = 3 * GUI_REFUSE_FILETRANSFER = 4 * INVALID_TYPE = 5 * NO_AUTHORITY = 6 * UNKNOWN_ERROR = 7 * BAD_DATA_FORMAT = 8 * HEADER_NOT_ALLOWED = 9 * SEPARATOR_NOT_ALLOWED = 10 * HEADER_TOO_LONG = 11 * UNKNOWN_DP_ERROR = 12 * ACCESS_DENIED = 13 * DP_OUT_OF_MEMORY = 14 * DISK_FULL = 15 * DP_TIMEOUT = 16 * OTHERS = 17 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM.

FORM BDCDATA. perform open_group.

LOOP AT IT_HEADER INTO WA_HEADER. PERFORM GET_HEADER_WORKCENTRES. LOOP AT IT_WORK_C_H INTO WA_WORK_C_H. WA_WORK_C_H1 = WA_WORK_C_H. COUNTER1 = COUNTER1 + 1. OR WORK CENTRES. AT NEW MATNR. COUNTER1 = 1. S. COUNTER2 = 1. perform bdc_dynpro perform bdc_field perform bdc_field using 'SAPLCPDI' '1010'. using 'BDC_CURSOR' 'RC27M-MATNR'. using 'BDC_OKCODE'

"TO INCREMENT COUNTER F

"COUNTER FOR WORK CENTRE " COUNTER FOR ROUTING.

perform bdc_field perform bdc_field perform bdc_field

'/00'. using 'RC27M-MATNR' WA_WORK_C_H1-MATNR. "'FS001'. using 'RC27M-WERKS' WA_WORK_C_H1-WERKS. "'0001'. using 'RC271-STTAG' '12.06.2013'. using 'SAPLCPDA' '1200'. using 'BDC_OKCODE' '=VOUE'. using 'PLKOD-PLNAL' COUNTER2."'1'. using 'PLKOD-KTEXT' 'fg'. using 'PLKOD-WERKS' '0001'. using 'BDC_CURSOR' 'PLKOD-STATU'. using 'PLKOD-VERWE' '1'. using 'PLKOD-STATU' '4'. using 'PLKOD-LOSBS' '99.999.999'. using 'PLKOD-PLNME' 'EA'.

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field ENDAT.

*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& IF COUNTER1 EQ 1. perform bdc_dynpro using 'SAPLCPDI' '1400'. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FVAL. perform bdc_field using 'BDC_CURSOR' "'PLPOD-STEUS(01)'. T_FVAL. CLEAR T_FVAL. *perform bdc_field using 'BDC_CURSOR' * 'PLPOD-STEUS(01)'. perform bdc_field using 'BDC_OKCODE' '/00'. CONCATENATE 'PLPOD-ARBPL(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-ARBPL(01)' WA_WORK_C_H1-ARBPL. "'A10'. CLEAR: T_FNAM. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-STEUS(01)' WA_WORK_C_H1-STEUS."'pp01'.

CLEAR T_FNAM. *perform bdc_field * *perform bdc_field *

using 'PLPOD-ARBPL(01)' WA_WORK_C_H1-ARBPL. "'A12'. using 'PLPOD-STEUS(01)' 'pp01'.

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field

"'/MI'. ENDIF. *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& IF COUNTER1 NE 1. perform bdc_dynpro using 'SAPLCPDI' '1400'. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FVAL. perform bdc_field using 'BDC_CURSOR' "'PLPOD-STEUS(01)'. T_FVAL. CLEAR T_FVAL. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'RC27XENTRY_ACT' "DIFFERENT SYNTAX FOR EQ AND NE 1 '1'. CONCATENATE 'PLPOD-ARBPL(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-ARBPL(01)' WA_WORK_C_H1-ARBPL. "'A10'. CLEAR: T_FNAM. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-STEUS(01)' WA_WORK_C_H1-STEUS."'pp01'. CLEAR T_FNAM.

using 'SAPLCPDO' '1010'. using 'PLPOD-VGW01' WA_WORK_C_H1-VGW01. using 'PLPOD-VGE01' WA_WORK_C_H1-VGE01. using 'PLPOD-VGW02' WA_WORK_C_H1-VGW02. using 'PLPOD-VGE02' WA_WORK_C_H1-VGE02. using 'PLPOD-VGW03' WA_WORK_C_H1-VGW03. using 'PLPOD-VGE03' WA_WORK_C_H1-VGE03.

"'1'. "'/MI'. "'1'. "'/MI'. "'1'.

perform bdc_dynpro perform bdc_field

using 'SAPLCPDO' '1010'. using 'PLPOD-VGW01'

perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field

"'/MI'. ENDIF. *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&& CLEAR: WA_WORK_C_H1,WA_WORK_C_H. ENDLOOP.

WA_WORK_C_H1-VGW01. using 'PLPOD-VGE01' WA_WORK_C_H1-VGE01. using 'PLPOD-VGW02' WA_WORK_C_H1-VGW02. using 'PLPOD-VGE02' WA_WORK_C_H1-VGE02. using 'PLPOD-VGW03' WA_WORK_C_H1-VGW03. using 'PLPOD-VGE03' WA_WORK_C_H1-VGE03.

"'1'. "'/MI'. "'1'. "'/MI'. "'1'.

PERFORM GET_ITEM_HEADER_WORKCENTRES. IF IT_WORK_C_I IS NOT INITIAL. LOOP AT IT_WORK_C_I INTO WA_WORK_C_I. WA_WORK_C_I1 = WA_WORK_C_I. COUNTER1 = COUNTER1 + 1. "TO INCREMENT COUNTER FOR WORK CENTRES. AT NEW INDICATOR_R1. "THIS LOOP IS PERFORMED TO GO BACK FOR THE FIR ST TIME WHEN NEW ROUTING IS TO BE CREATED. COUNTER1 = 1. "COUNTER FOR WORK CENTRES. COUNTER2 = 2. " COUNTER FOR ROUTING. perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field using 'SAPLCPDI' '1400'. using 'BDC_CURSOR' 'RC27X-ENTRY_ACT'. using 'BDC_OKCODE' '=BACK'. using 'RC27X-ENTRY_ACT' '1'.

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field

using 'SAPLCPDA' '1200'. using 'BDC_OKCODE' '=ANLG'. using 'PLKOD-KTEXT' 'fg'. using 'PLKOD-WERKS' '0001'. using 'BDC_CURSOR' 'PLKOD-STATU'.

perform bdc_field perform bdc_field perform bdc_field perform bdc_field

using 'PLKOD-VERWE' '1'. using 'PLKOD-STATU' '4'. using 'PLKOD-LOSBS' '99.999.999'. using 'PLKOD-PLNME' 'EA'.

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field COUNTER2 = COUNTER2 + 1. ENDAT.

using 'SAPLCPDA' '1200'. using 'BDC_OKCODE' '=VOUE'. using 'PLKOD-PLNAL' COUNTER2. "'2'. using 'PLKOD-KTEXT' 'fg'. using 'PLKOD-WERKS' '0001'. using 'BDC_CURSOR' 'PLKOD-STATU'. using 'PLKOD-VERWE' '1'. using 'PLKOD-STATU' '4'. using 'PLKOD-LOSBS' '99.999.999'. using 'PLKOD-PLNME' 'EA'.

IF COUNTER1 EQ 1. perform bdc_dynpro using 'SAPLCPDI' '1400'. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FVAL. perform bdc_field using 'BDC_CURSOR' T_FVAL."'PLPOD-STEUS(01)'. CLEAR T_FVAL. perform bdc_field using 'BDC_OKCODE' '/00'. CONCATENATE 'PLPOD-ARBPL(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-ARBPL(01)' WA_WORK_C_I1-ARBPL. "'A12'. CLEAR T_FNAM. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-STEUS(01)' 'pp01'.

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field perform bdc_field ENDIF.

using 'SAPLCPDO' '1010'. using 'PLPOD-VGW01' WA_WORK_C_I1-VGW01. using 'PLPOD-VGE01' WA_WORK_C_I1-VGE01. using 'PLPOD-VGW02' WA_WORK_C_I1-VGW02. using 'PLPOD-VGE02' WA_WORK_C_I1-VGE02. using 'PLPOD-VGW03' WA_WORK_C_I1-VGW03. using 'PLPOD-VGE03' WA_WORK_C_I1-VGE03.

"'1'. "'/MI'. "'1'. "'/MI'. "'1'. "'/MI'.

IF COUNTER1 NE 1. perform bdc_dynpro using 'SAPLCPDI' '1400'. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FVAL. perform bdc_field using 'BDC_CURSOR' T_FVAL. "'PLPOD-STEUS(01)'. CLEAR T_FVAL. perform bdc_field using 'BDC_OKCODE' '/00'. *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ perform bdc_field using 'RC27XENTRY_ACT' "DIFFERENT SYNTAX FOR COUNTER1 EQ AND NE 1 '1'. *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ CONCATENATE 'PLPODARBPL(' COUNTER1 ')' INTO T_FNAM. "################### perform bdc_field using T_FNAM "'PLPOD-ARBPL(01)' WA_WORK_C_I1-ARBPL. "'A11'. CLEAR T_FNAM. CONCATENATE 'PLPOD-STEUS(' COUNTER1 ')' INTO T_FNAM. perform bdc_field using T_FNAM "'PLPOD-STEUS(01)' WA_WORK_C_H1-STEUS. "'pp01'. CLEAR T_FNAM. "################ ###

perform bdc_dynpro perform bdc_field perform bdc_field perform bdc_field perform bdc_field

using 'SAPLCPDO' '1010'. using 'PLPOD-VGW01' WA_WORK_C_I1-VGW01. "'1'. using 'PLPOD-VGE01' WA_WORK_C_I1-VGE01."'/MI'. using 'PLPOD-VGW02' WA_WORK_C_I1-VGW02."'1'. using 'PLPOD-VGE02'

perform bdc_field perform bdc_field ENDIF.

WA_WORK_C_I1-VGE02."'/mi'. using 'PLPOD-VGW03' WA_WORK_C_I1-VGW03."'1'. using 'PLPOD-VGE03' WA_WORK_C_I1-VGE03."'/mi'.

CLEAR: WA_WORK_C_I1, WA_WORK_C_I. ENDLOOP. ENDIF.

perform bdc_dynpro perform bdc_field

using 'SAPLCPDI' '1400'. using 'BDC_CURSOR' 'RC27X-ENTRY_ACT'. perform bdc_field using 'BDC_OKCODE' '=BU'. perform bdc_field using 'RC27X-ENTRY_ACT' '1'. perform bdc_transaction using 'CA01'.

CLEAR WA_HEADER. ENDLOOP.

perform close_group. ENDFORM. FORM GET_HEADER_MATNR.

IT_HEADER[] = IT_UPLOAD[]. DELETE ADJACENT DUPLICATES FROM IT_HEADER COMPARING MATNR. " INDICATOR1. ENDFORM. FORM GET_HEADER_WORKCENTRES. REFRESH IT_WORK_C_H. LOOP AT IT_UPLOAD INTO WA_UPLOAD WHERE MATNR = WA_HEADER-MATNR AND INDICATOR1 = 'H'." AND * INDICATOR2 = WA_HEADER-INDICATOR2. WA_WORK_C_H = WA_UPLOAD. APPEND WA_WORK_C_H TO IT_WORK_C_H. CLEAR: WA_UPLOAD ,WA_WORK_C_H. ENDLOOP. ENDFORM.

FORM GET_ITEM_HEADER_WORKCENTRES. REFRESH IT_WORK_C_I. LOOP AT IT_UPLOAD INTO WA_UPLOAD WHERE MATNR = WA_HEADER-MATNR AND INDICATOR1 = 'W'." AND * INDICATOR2 = WA_HEADER-INDICATOR2. WA_WORK_C_I = WA_UPLOAD. APPEND WA_WORK_C_I TO IT_WORK_C_I. CLEAR: WA_UPLOAD ,WA_WORK_C_I. ENDLOOP. ENDFORM.