2020 Mar 13 10:58 AM
Hi,
loop at it_final.
perform bdc_dynpro using 'SAPMF05A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT'
it_final-bldat.
perform bdc_field using 'BKPF-BLART'
it_final-blart.
perform bdc_field using 'BKPF-BUKRS'
it_final-bukrs.
perform bdc_field using 'BKPF-BUDAT'
it_final-budat.
*perform bdc_field using 'BKPF-MONAT'
* '12'.
perform bdc_field using 'BKPF-WAERS'
it_final-waers.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
perform bdc_field using 'FS006-DOCID'
'*'.
LOOP AT IT_final WHERE bschl = '35'.
perform bdc_field using 'RF05A-NEWBS'
it_final-bschl.
perform bdc_field using 'RF05A-NEWKO'
it_final-hkont.
perform bdc_dynpro using 'SAPMF05A' '0302'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'AB'.
perform bdc_field using 'BSEG-WRBTR'
w_amount.
perform bdc_field using 'BSEG-BUPLA'
it_final-bupla.
perform bdc_field using 'BSEG-ZUONR'
it_final-zuonr.
perform bdc_field using 'BSEG-SGTXT'
it_final-sgtxt.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
endloop.
LOOP AT IT_final WHERE bschl = '40'.
perform bdc_field using 'RF05A-NEWBS'
it_final-bschl.
perform bdc_field using 'RF05A-NEWKO'
it_final-hkont.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=AB'.
perform bdc_field using 'BSEG-WRBTR'
w_amount.
perform bdc_field using 'BSEG-BUPLA'
it_final-bupla.
perform bdc_field using 'BSEG-ZUONR'
it_final-zuonr.
perform bdc_field using 'BSEG-SGTXT'
it_final-sgtxt.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-PRCTR'.
perform bdc_field using 'BDC_OKCODE'
'ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-KOSTL'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWBS'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
endloop.
CALL TRANSACTION 'FB01' USING bdcdata MODE 'A' UPDATE 'S'
MESSAGES INTO messtab.
*form display-errors
*Check if update was succesful
IF sy-subrc NE 0.
*Retrieve error messages displayed during BDC update
LOOP AT messtab WHERE msgtyp = 'E'.
*Builds actual message based on info returned from Call transaction
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = w_textout.
ENDLOOP.
it_error-bschl = it_final-bschl.
it_error-bldat = it_final-bldat.
it_error-budat = it_final-budat.
it_error-waers = it_final-waers.
it_error-xblnr = it_final-xblnr.
it_error-bktxt = it_final-bktxt.
it_error-blart = it_final-blart.
it_error-bukrs = it_final-bukrs.
it_error-hkont = it_final-hkont.
*it_error-shkzg = it_final-shkzg.
it_error-wrbtr = it_final-wrbtr.
it_error-zuonr = it_final-zuonr.
it_error-kostl = it_final-kostl.
it_error-prctr = it_final-prctr.
it_error-sgtxt = it_final-sgtxt.
it_error-bupla = it_final-bupla.
*it_error-valut = it_final-valut.
it_error-err_msg = w_textout.
*APPEND it_error.
APPEND IT_ERROR.
CLEAR it_error.
ENDIF.
CLEAR: bdcdata.
REFRESH: bdcdata.
ENDLOOP.
Above code which was i developed for uploading data from excel to sap system.
For posting key 35 it was uploading properly.
But when it comes to posting key 40 only one record is processed and remaining records it throughing an error but there are no error records in the excel file .Can you please help me to find out it.
2020 Mar 13 5:57 PM
Please debug your code after CALL TRANSACTION. What is the value of SY-SUBRC?
2020 Mar 13 6:06 PM
Hi,
i didn't see in you program work for posting key 45. your loop running only for posting key 40 and 35.
When your running with the "A" mode, you can see all the screen, may be when you used posting key 45 your screen will be change . kindly check it.
2020 Mar 14 4:12 AM
2020 Mar 14 7:29 AM
2020 Mar 14 9:08 AM
Hi krishnamurthy sir ,
Firstly i would like to tell u i just wrongly typed instead of 40 i typed it as 45
for posting key 35 all the records where uploaded successfully through fb01 t-code via bdc
But when it comes to posting key 40 the data was not uploaded .As shown in below fig when it comes to 40 posting key it just displayed like shown in below

2020 Mar 14 10:21 AM
Hi
I am not able to completely look into your code. However, just try this following
1. Please sort the it_final by posting key before processing. OR
2. Keep two it_final internal table ( 1 for 30 and other for 40) - it looks odd but just try ( bassed on your existing code -do not know why you loop it two times separately)
3.Of add If statement inside each loop ( one for check for 30 and other check for 40) since you use the same loop for both 30 and 40
Regards,
Venkat
2020 Mar 14 11:22 AM
2020 Mar 14 12:20 PM
Hi
I just noticed in your code. You have written main loop and inside two inner loop. But all of them uses the same internal table it_final. That will not work. Please review it again.
2020 Mar 16 6:42 AM
2020 Mar 16 6:52 AM
As shown in below i modified my code with two internal tables but this time only first record in posting key '35' is repeatedly processes inside the loop and no other records were entered into that loop
SORT it_final[] by bschl .
it_final1[] = IT_final[].
start-of-selection.
loop at it_final.
*write it_final-wrbtr to w_amount.
* CONDENSE w_amount.
perform bdc_dynpro using 'SAPMF05A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT'
it_final-bldat.
perform bdc_field using 'BKPF-BLART'
it_final-blart.
perform bdc_field using 'BKPF-BUKRS'
it_final-bukrs.
perform bdc_field using 'BKPF-BUDAT'
it_final-budat.
*perform bdc_field using 'BKPF-MONAT'
* '12'.
perform bdc_field using 'BKPF-WAERS'
it_final-waers.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
perform bdc_field using 'FS006-DOCID'
'*'.
LOOP AT it_final1 where bschl = '35'.
*if it_final-bschl = '35'.
write it_final-wrbtr to w_amount.
CONDENSE w_amount.
perform bdc_field using 'RF05A-NEWBS'
it_final-bschl.
perform bdc_field using 'RF05A-NEWKO'
it_final-hkont.
perform bdc_dynpro using 'SAPMF05A' '0302'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'AB'.
perform bdc_field using 'BSEG-WRBTR'
w_amount.
perform bdc_field using 'BSEG-BUPLA'
it_final-bupla.
perform bdc_field using 'BSEG-ZUONR'
it_final-zuonr.
perform bdc_field using 'BSEG-SGTXT'
it_final-sgtxt.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
endloop.
*elseif it_final-bschl = '50'.
LOOP AT IT_final1 where bschl = '50' .
write it_final-wrbtr to w_amount.
CONDENSE w_amount.
perform bdc_field using 'RF05A-NEWBS'
it_final-bschl.
perform bdc_field using 'RF05A-NEWKO'
it_final-hkont.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=AB'.
perform bdc_field using 'BSEG-WRBTR'
w_amount.
perform bdc_field using 'BSEG-BUPLA'
it_final-bupla.
perform bdc_field using 'BSEG-ZUONR'
it_final-zuonr.
perform bdc_field using 'BSEG-SGTXT'
it_final-sgtxt.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-PRCTR'.
perform bdc_field using 'BDC_OKCODE'
'ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-KOSTL'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWBS'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
endloop.
LOOP AT it_final1 where bschl = '40' .
write it_final-wrbtr to w_amount.
CONDENSE w_amount.
**else .
perform bdc_field using 'RF05A-NEWBS'
it_final-bschl.
perform bdc_field using 'RF05A-NEWKO'
it_final-hkont.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=AB'.
perform bdc_field using 'BSEG-WRBTR'
w_amount.
perform bdc_field using 'BSEG-BUPLA'
it_final-bupla.
perform bdc_field using 'BSEG-ZUONR'
it_final-zuonr.
perform bdc_field using 'BSEG-SGTXT'
it_final-sgtxt.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-PRCTR'.
perform bdc_field using 'BDC_OKCODE'
'ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-KOSTL'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
it_final-kostl.
perform bdc_field using 'COBL-PRCTR'
it_final-prctr.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWBS'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BKPF-XBLNR'
it_final-xblnr.
perform bdc_field using 'BKPF-BKTXT'
it_final-bktxt.
endloop.
2020 Mar 16 7:36 AM
Hi
I think you made it so complicated. I think you are having records for 35,40 and 50 as well.
At this situation , please keep it_final1, it_final2, it_final3 - as three separate internal table for each posting key and process them
I would prefer you look for the option using BAPI instead of BDC ('BAPI_ACC_DOCUMENT_POST') - that will be easier than bdc
2020 Mar 16 11:34 AM
2020 Mar 14 1:12 PM
One thing important to know is that an error in the BDC data will make CALL TRANSACTION return the error code 1001, and the error messages are of type S, not E. See the wiki.
So, debug your code to make sure you're not in that case.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |