Skip to Content
0

How to generate only one document no for multiple line item post in FB01 through BDC.

Feb 11, 2017 at 04:07 AM

59

avatar image

Hi Experts,

i have developed one BDC for FB01 to post the documents.My Requirement is to generate the only one document no based on Reference doc no.In my case it is generating the document no based on line item.How to restrict it to generate the only one document for all line item is their XBLNR is same.

LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWUM'. "GL INDICATOR
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.

PERFORM bdc_field USING 'BKPF-BLDAT'
itab-bldat.
PERFORM bdc_field USING 'BKPF-BUDAT'
itab-budat.
PERFORM bdc_field USING 'BKPF-BLART'
itab-blart.
PERFORM bdc_field USING 'BKPF-BUKRS'
itab-bukrs.
PERFORM bdc_field USING 'BKPF-WAERS'
itab-waers. "CURR
PERFORM bdc_field USING 'BKPF-KURSF'
itab-kursf. "EXC RATE

PERFORM bdc_field USING 'BKPF-XBLNR'
itab-xblnr. "REF DOC
PERFORM bdc_field USING 'BKPF-BKTXT'
itab-bktxt. "HEADER TEXT
PERFORM bdc_field USING 'RF05A-NEWBS'
itab-newbs. "POST KEY
PERFORM bdc_field USING 'RF05A-NEWKO'
itab-newko. "CUSTOMER
PERFORM bdc_field USING 'RF05A-NEWUM'
itab-newum. ""GL INDICATOR

* Dynamic Screen
IF itab-newbs EQ '01' OR itab-newbs EQ '11' OR itab-newbs EQ '17'.
scrn = '301'.
ELSEIF itab-newbs EQ '09' OR itab-newbs EQ '19'.
* OR itab-newbs EQ '29' OR itab-newbs EQ '39'.
scrn = '304'.
ENDIF.

PERFORM bdc_dynpro USING 'SAPMF05A' scrn.
.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
itab-wrbtr. " AMOUNT
IF itab-newbs NE '19'.
PERFORM bdc_field USING 'BSEG-ZFBDT'
itab-bldat.
ENDIF.
PERFORM bdc_field USING 'BSEG-SGTXT'
itab-sgtxt. "LINE TEXT

IF itab-newbs EQ '01' OR itab-newbs EQ '09' ."OR itab-newbs EQ '17'.
* OR itab2-newbs EQ '29'.
newbs1 = '50'.
ELSEIF itab-newbs EQ '11' OR itab-newbs EQ '19' OR itab-newbs EQ '17'.
* OR itab2-newbs EQ '39'.
newbs1 = '40'.
ENDIF.

PERFORM bdc_field USING 'RF05A-NEWBS'
newbs1.
PERFORM bdc_field USING 'RF05A-NEWKO'
p_gla.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_field USING 'BSEG-WRBTR'

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_transaction USING 'FB01'.
ENDAT.
ENDLOOP.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Jelena Perfiljeva
Feb 13, 2017 at 09:19 PM
0

Why can't you just use BAPI_ACC_DOCUMENT_POST?

Share
10 |10000 characters needed characters left characters exceeded