2007 May 07 4:42 AM
hi all,
i had to develop bdc program to upload data to ml10. and also i had to upload data
to multiple line items
multiple line items include activity number and quantity correspondingly.
can any body tell me hou to upload data to ml10 multiple line items, and also sample code.
thanks in advance
siva
2007 May 07 4:59 AM
go to transaction SHDB->new recording->give t-code (ex: ml10).and start recording.
enter all required line item once for the recording.
copy ur recording to ur report program.
************************
sample program for recoding of t-code FD01
report ZSUR_REC_PROG
no standard page heading line-size 255.
DATA: begin of MAIN_TAB OCCURS 5,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
STRAS LIKE KNA1-STRAS,
ORT01 LIKE KNA1-ORT01,
PSTLZ LIKE KNA1-PSTLZ,
END OF MAIN_TAB,
BEGIN OF BANK_TAB OCCURS 5,
KUNNR LIKE KNA1-KUNNR,
BANKS LIKE KNBK-BANKS,
BANKL LIKE KNBK-BANKL,
BANKN LIKE KNBK-BANKN,
END OF BANK_TAB,
MFILE TYPE STRING,
BFILE TYPE STRING,
CNT TYPE I,
CNTS(3) TYPE C,
STR1(40) TYPE C,
STR2(40) TYPE C.
include bdcrecx1.
PARAMETERS: PMFILE(45) TYPE C DEFAULT 'C:\sap_abap_ppts\sm\MAIN.TXT',
PBFILE(45) TYPE C DEFAULT 'C:\sap_abap_ppts\sm\BANK.TXT'.
start-of-selection.
MFILE = PMFILE.
BFILE = PBFILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = MFILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = MAIN_TAB
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.
EXIT.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = BFILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = BANK_TAB
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.
EXIT.
ENDIF.
perform open_group.
LOOP AT MAIN_TAB.
perform bdc_dynpro using 'SAPMF02D' '0105'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-BUKRS'
'0001'.
perform bdc_field using 'RF02D-KTOKD'
'0004'.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-SPRAS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-ANRED'
'Company'.
perform bdc_field using 'KNA1-NAME1'
MAIN_TAB-NAME1.
SPLIT MAIN_TAB-NAME1 AT ' ' INTO STR1 STR2.
perform bdc_field using 'KNA1-SORTL'
STR1.
perform bdc_field using 'KNA1-STRAS'
MAIN_TAB-STRAS.
perform bdc_field using 'KNA1-ORT01'
MAIN_TAB-ORT01.
perform bdc_field using 'KNA1-PSTLZ'
MAIN_TAB-PSTLZ.
perform bdc_field using 'KNA1-LAND1'
'IN'.
perform bdc_field using 'KNA1-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMF02D' '0120'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKN(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
CNT = 0.
LOOP AT BANK_TAB WHERE KUNNR = MAIN_TAB-KUNNR.
CNT = CNT + 1.
CNTS = CNT.
CONDENSE CNTS.
CONCATENATE 'KNBK-BANKS(' CNTS ')' INTO STR1.
perform bdc_field using STR1
bank_tab-banks.
CONCATENATE 'KNBK-BANKL(' CNTS ')' INTO STR1.
perform bdc_field using STR1
BANK_TAB-BANKL.
CONCATENATE 'KNBK-BANKN(' CNTS ')' INTO STR1.
perform bdc_field using STR1
BANK_TAB-BANKN.
ENDLOOP.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0210'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-AKONT'
'140000'.
perform bdc_dynpro using 'SAPMF02D' '0215'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-ZTERM'
'0002'.
perform bdc_dynpro using 'SAPMF02D' '0220'.
perform bdc_field using 'BDC_CURSOR'
'KNB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB5-MAHNA'
'0003'.
perform bdc_dynpro using 'SAPMF02D' '0230'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-VRSNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_transaction using 'FD01'.
ENDLOOP.
perform close_group.