You are on page 1of 6

*15 1000 1000 0001 AMAR AVM IN 31000 A2 ADP

*15 IN 125452 1234567891 AMAR AVM IN 31000 A2


ADP
*15 IN 143483 1234567891 AMAR AVM IN 31000 A2
ADP
*16 1000 1000 0001 AMAR AVM IN 31000 A2 ADP
*16 IN 125452 1234567891 AMAR AVM IN 31000 A2
ADP
*16 IN 143483 1234567891 AMAR AVM IN 31000 A2
ADP
REPORT ZMM_IDD0080_VENDOR_UPLOAD_B40
NO STANDARD PAGE HEADING LINE-SIZE 255.
*&---------------------------------------------------------------------*
*& STRUCTURE DECLARATION
*&---------------------------------------------------------------------*
* Structure declaration for header
TYPES:BEGIN OF TY_HEADER,
LIFNR TYPE RF02K-LIFNR,
BUKRS TYPE RF02K-BUKRS,
EKORG TYPE RF02K-EKORG,
KTOKK TYPE RF02K-KTOKK,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
LAND1 TYPE LFA1-LAND1,
AKONT TYPE LFB1-AKONT,
FDGRV TYPE LFB1-FDGRV,
WAERS TYPE LFM1-WAERS,
END OF TY_HEADER,
* Structure declaration for item
BEGIN OF TY_ITEM,
LIFNR TYPE RF02K-LIFNR,
BANKS TYPE LFBK-BANKS,
BANKL TYPE LFBK-BANKL,
BANKN TYPE LFBK-BANKN,
KOINH TYPE LFBK-KOINH,
END OF TY_ITEM,
* Structure declaration for source
BEGIN OF TY_UPLOAD,
F1 TYPE CHAR16,
F2 TYPE CHAR4,
F3 TYPE CHAR15,
F4 TYPE CHAR18,
F5(60) TYPE C,
F6 TYPE LFA1-SORTL,
F7 TYPE LFA1-LAND1,
F8 TYPE LFB1-AKONT,
F9 TYPE LFB1-FDGRV,
F10 TYPE LFM1-WAERS,
END OF TY_UPLOAD.
*&---------------------------------------------------------------------*
*& Internal table DECLARATION
*&---------------------------------------------------------------------*
* Internal table declaration for header stru
DATA: T_HEADER TYPE STANDARD TABLE OF TY_HEADER INITIAL SIZE 0,
* Internal table declaration for item stru
T_ITEM TYPE STANDARD TABLE OF TY_ITEM INITIAL SIZE 0,
* Internal table declaration for Source stru
T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,
* Internal table declaration for target
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0,
*&---------------------------------------------------------------------*
*& Work area DECLARATION
*&---------------------------------------------------------------------*
* Work area declartion for header
W_HEADER TYPE TY_HEADER,
* work area declaration for item
W_ITEM TYPE TY_ITEM,
* work area declartion for source
W_UPLOAD TYPE TY_UPLOAD,
W_UPLOAD1 TYPE TY_UPLOAD,
* work area declaration for target
W_BDCDATA TYPE BDCDATA.
*&---------------------------------------------------------------------*
*& Selection screen DECLARATION
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_FLNAME TYPE FILENAME-FILEINTERN.
SELECTION-SCREEN END OF BLOCK B1.
*&---------------------------------------------------------------------*
*& Initialization DECLARATION
*&---------------------------------------------------------------------*
INITIALIZATION.
* Clear work area
CLEAR:W_UPLOAD,
W_HEADER,
W_ITEM,
W_BDCDATA.
* Refresh table
REFRESH:T_UPLOAD,
T_HEADER,
T_ITEM,
T_BDCDATA.
*&---------------------------------------------------------------------*
*& Start of selection DECLARATION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* upload the data
PERFORM SUB_UPLOAD_DATA.
* Call the trans
PERFORM SUB_CALL_TRANS.
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
DATA : L_FLNAME TYPE STRING.
L_FLNAME = P_FLNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FLNAME
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_UPLOAD.
LOOP AT T_UPLOAD INTO W_UPLOAD1.
W_UPLOAD = W_UPLOAD1.
AT NEW F1.
* Moving header records
W_HEADER-LIFNR = W_UPLOAD-F1.
W_HEADER-BUKRS = W_UPLOAD-F2.
W_HEADER-EKORG = W_UPLOAD-F3.
W_HEADER-KTOKK = W_UPLOAD-F4.
W_HEADER-NAME1 = W_UPLOAD-F5.
W_HEADER-SORTL = W_UPLOAD-F6.
W_HEADER-LAND1 = W_UPLOAD-F7.
W_HEADER-AKONT = W_UPLOAD-F8.
W_HEADER-FDGRV = W_UPLOAD-F9.
W_HEADER-WAERS = W_UPLOAD-F10.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CONTINUE.
ENDAT.
* Moving item records
W_ITEM-LIFNR = W_UPLOAD-F1.
W_ITEM-BANKS = W_UPLOAD-F2.
W_ITEM-BANKL = W_UPLOAD-F3.
W_ITEM-BANKN = W_UPLOAD-F4.
W_ITEM-KOINH = W_UPLOAD-F5.
APPEND W_ITEM TO T_ITEM.
CLEAR W_ITEM.
ENDLOOP.
ENDFORM. " SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form SUB_CALL_TRANS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_CALL_TRANS .
DATA:L_FIELD TYPE CHAR40,
L_N TYPE CHAR2,
OPT TYPE CTU_PARAMS.
LOOP AT T_HEADER INTO W_HEADER.
REFRESH T_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0100'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RF02K-LIFNR'
W_HEADER-LIFNR.
PERFORM BDC_FIELD USING 'RF02K-BUKRS'
W_HEADER-BUKRS.
PERFORM BDC_FIELD USING 'RF02K-EKORG'
W_HEADER-EKORG.
PERFORM BDC_FIELD USING 'RF02K-KTOKK'
W_HEADER-KTOKK.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0110'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LFA1-NAME1'
W_HEADER-NAME1.
PERFORM BDC_FIELD USING 'LFA1-SORTL'
W_HEADER-SORTL.
PERFORM BDC_FIELD USING 'LFA1-LAND1'
W_HEADER-LAND1.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE LIFNR = W_HEADER-LIFNR.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFBK-KOINH(02)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
CLEAR L_FIELD.
CONCATENATE 'LFBK-BANKS(0' L_N ')' INTO L_FIELD.
PERFORM BDC_FIELD USING L_FIELD "'LFBK-BANKS(01)'
W_ITEM-BANKS.
CLEAR L_FIELD.
CONCATENATE 'LFBK-BANKL(0' L_N ')' INTO L_FIELD.
PERFORM BDC_FIELD USING L_FIELD "'LFBK-BANKL(01)'
W_ITEM-BANKL.
CLEAR L_FIELD.
CONCATENATE 'LFBK-BANKN(0' L_N ')' INTO L_FIELD.
PERFORM BDC_FIELD USING L_FIELD "'LFBK-BANKN(01)'
W_ITEM-BANKN.
CLEAR L_FIELD.
CONCATENATE 'LFBK-KOINH(0' L_N ')' INTO L_FIELD.
PERFORM BDC_FIELD USING L_FIELD "'LFBK-KOINH(01)'
W_ITEM-KOINH.
L_N = L_N + 1.
ENDLOOP.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0210'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LFB1-AKONT'
W_HEADER-AKONT.
PERFORM BDC_FIELD USING 'LFB1-FDGRV'
W_HEADER-FDGRV.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0215'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0220'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0310'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LFM1-WAERS'
W_HEADER-WAERS.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0320'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
OPT-DISMODE = 'A'.
OPT-DEFSIZE = 'X'.
CALL TRANSACTION 'XK01' USING T_BDCDATA OPTIONS FROM OPT.
ENDLOOP.
ENDFORM. " SUB_CALL_TRANS
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR W_BDCDATA.
W_BDCDATA-PROGRAM = PROGRAM.
W_BDCDATA-DYNPRO = DYNPRO.
W_BDCDATA-DYNBEGIN = 'X'.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR W_BDCDATA.
W_BDCDATA-FNAM = FNAM.
W_BDCDATA-FVAL = FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_FIELD