Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

FB01 BDC not uploading data properly

Dear Friends,

The following BDC Code for FB01, involving 3 posting keys..40-Debit, 50-Credit & 31-Vendor uploads Debit entries(40) and Credit entries(50) quite well, but if there is an entry for Vendor(31 posting key) in the file it doesn't upload a credit entry(50) immediatlely after uploading the vendor entry(31).

Can you please have a look at the code and help me in finding the bug.

DATA: BDCDATA1 LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA : VF_INDEX TYPE I.

*************

DATA: TEMP(8),

DOCDATE(8),

SPLGL(1),

PKEY(2),

GL(17),

VCHAMT(13),

BUSAREA(4),

SECCODE(4),

FBDT(8),

ZZUONR(18),

COSTCEN(10),

AUFNR(3),

SGTXT(50).

*********************************

LOOP AT FINAL_MAIN.

REFRESH BDCDATA1.

WRITE: / FINAL_MAIN-SLNO,

FINAL_MAIN-PK ,

FINAL_MAIN-GL_CODE ,

FINAL_MAIN-EARNED_AMOUNT ,

FINAL_MAIN-BUPLA ,

FINAL_MAIN-GSBER ,

FINAL_MAIN-KOSTL ,

FINAL_MAIN-TEXT ,

FINAL_MAIN-ZUONR .

ENDLOOP.

BDCDATA1-PROGRAM = 'SAPMF05A' .

BDCDATA1-DYNPRO = '0100'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '/00'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-PROGRAM = 'BDC_CURSOR' .

BDCDATA1-DYNPRO = 'RF05A-NEWKO'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

TEMP = '20070509'.

DOCDATE = TEMP+6(2).

DOCDATE2(2) = TEMP4(2).

DOCDATE4(4) = TEMP0(4).

BDCDATA1-FNAM = 'BKPF-BLDAT'.

BDCDATA1-FVAL = DOCDATE.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BKPF-BLART'.

BDCDATA1-FVAL = 'SA'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BKPF-WAERS'.

BDCDATA1-FVAL = 'INR'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BKPF-BUDAT'.

BDCDATA1-FVAL = DOCDATE.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BKPF-XBLNR'.

BDCDATA1-FVAL = SAHIB.

APPEND BDCDATA1.

CLEAR BDCDATA1.

*PERFORM BDC_FIELD USING 'BKPF-BKTXT' .

BDCDATA1-FNAM = 'BKPF-BKTXT'.

BDCDATA1-FVAL = SAHIB2.

APPEND BDCDATA1.

CLEAR BDCDATA1.

LOOP AT FINAL_MAIN.

IF FINAL_MAIN-SLNO = '1'.

BDCDATA1-FNAM = 'RF05A-NEWBS'.

BDCDATA1-FVAL = FINAL_MAIN-PK.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'RF05A-NEWKO'.

BDCDATA1-FVAL = FINAL_MAIN-GL_CODE.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BKPF-BUKRS' .

BDCDATA1-FVAL = 'SCL'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-PROGRAM = 'SAPMF05A' .

BDCDATA1-DYNPRO = '0300'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '/00'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_CURSOR' .

BDCDATA1-FVAL = 'RF05A-NEWKO'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

ELSE.

BDCDATA1-FNAM = 'BSEG-WRBTR' .

BDCDATA1-FVAL = VCHAMT.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BSEG-SGTXT' .

BDCDATA1-FVAL = SGTXT.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'RF05A-NEWBS' .

BDCDATA1-FVAL = FINAL_MAIN-PK.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'RF05A-NEWKO' .

BDCDATA1-FVAL = FINAL_MAIN-GL_CODE.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'bdc_subscr' .

BDCDATA1-FVAL = 'saplkacb'

& ' 0001block' .

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-PROGRAM = 'SAPLKACB' .

BDCDATA1-DYNPRO = '0002'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_CURSOR' .

BDCDATA1-FVAL = 'COBL-KOSTL'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '=ENTE'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'bdc_cursor' .

BDCDATA1-FVAL = 'cobl-gsber'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'COBL-GSBER' .

BDCDATA1-FVAL = BUSAREA.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'bdc_cursor' .

BDCDATA1-FVAL = 'cobl-kostl'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'COBL-kostl' .

BDCDATA1-FVAL = COSTCEN.

APPEND BDCDATA1.

CLEAR BDCDATA1.

IF FINAL_MAIN-PK = '31'.

BDCDATA1-PROGRAM = 'SAPMF05A' .

BDCDATA1-DYNPRO = '0302'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '/00'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BSEG-WRBTR' .

BDCDATA1-FVAL = VCHAMT.

APPEND BDCDATA1.

CLEAR BDCDATA1.

ELSE.

BDCDATA1-PROGRAM = 'SAPMF05A' .

BDCDATA1-DYNPRO = '0300'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '/00'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BSEG-WRBTR' .

BDCDATA1-FVAL = VCHAMT.

APPEND BDCDATA1.

CLEAR BDCDATA1.

ENDIF.

ENDIF.

PKEY = FINAL_MAIN-PK.

GL = FINAL_MAIN-GL_CODE.

VCHAMT = FINAL_MAIN-EARNED_AMOUNT.

BUSAREA = FINAL_MAIN-GSBER.

ZZUONR = FINAL_MAIN-ZUONR.

COSTCEN = FINAL_MAIN-KOSTL.

SGTXT = FINAL_MAIN-TEXT.

ENDLOOP.

bdcdata1-fnam = 'bseg-wrbtr' .

bdcdata1-fval = vchamt.

APPEND bdcdata1.

clear bdcdata1.

bdcdata1-fnam = 'bseg-sgtxt' .

bdcdata1-fval = sgtxt.

APPEND bdcdata1.

clear bdcdata1.

if splgl ne ' '.

bdcdata1-fnam = 'bseg-gsber' .

bdcdata1-fval = busarea.

APPEND bdcdata1.

clear bdcdata1.

else.

BDCDATA1-FNAM = 'bdc_subscr' .

BDCDATA1-FVAL = 'saplkacb'

& ' 0001block' .

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-PROGRAM = 'SAPLKACB' .

BDCDATA1-DYNPRO = '0002'.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

BDCDATA1-FNAM = 'BDC_OKCODE' .

BDCDATA1-FVAL = '=BU'.

APPEND BDCDATA1.

CLEAR BDCDATA1.

bdcdata1-fnam = 'bseg-gsber' .

bdcdata1-fval = busarea.

APPEND bdcdata1.

clear bdcdata1.

ENDIF.

CALL TRANSACTION 'FB01' USING BDCDATA1 MODE 'A'.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

GENNO = SY-MSGV1.

IF GENNO+0(3) = '210'.

UPDATE ZPAYPAYROLL_DATA

SET VOUCHER_FLAG = 'Y'

FI_DOC = GENNO

FI_YEAR = RYR

WHERE COMP_CODE = RCOMP AND

MTH = RMTH AND

YR = RYR .

COMMIT WORK.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question