Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Entries in a single f-02 transaction....BDC pls

Former Member
0 Kudos

Hi All,

I have created a BDC for entries in F-02.

It works for a single debit entry with Posting Key 50 and single credit entry with Posting Key 50.

I need to create a BDC for muliple debit entries and multiple credit entries.

So in order do this how does the data need to be filled and in which way we need to design the program?

Please help me out in creating this BDC as it is an immediate requirement.

regards

PSNG

3 REPLIES 3

Former Member
0 Kudos

Hi,

Normally the F-02 will work only if the total debit and total credit entries are matching.

So you need to create the entries in your itab like this only. Please try posting a document manually and check with amounts not balancing. Then you can understand easily and then post it with balancing amount.

Then use that as your recording and go ahead with the development.

And one more thing is, there is a limit for number of debit and credit entries in a document . That is 999.

So when ever it is crossing 999 documents you need to break the document into more multiples of 999

And you have to check the totals should match for each document being created.

Regards,

Venkatesh.

0 Kudos

Thank you for your kind response...

I have tested the one debit and one credit entries in my BDC and it is working fine.

I want the information where we need to apply the logic for entering multiple entries in a single transaction...

like at new posting key are if header details are empty as such...

when i tried logic with if postky 'eq' 40 perform form1 elseif postky 'eq' 50 perform form2 for the multiple entries but the loop is working only for one entry not multiple....

regars

PSNG

0 Kudos

Hi,

You can apply a small logic using which u need to read the data from your text file into an internal table keep a loop into work area using this you can differentiate between different posting keys from there by checking the condition If posting key = '40' apply the logic for postg key 40 else postg key = 50 apply another logic for posting key 50.

Check this sample one

REPORT ZFI_F02
no standard page heading line-size 255.

include bdcrecx1.

DATA : FNAME TYPE STRING.
DATA : FILENAME TYPE STRING.

DATA : BEGIN OF IT_OUT OCCURS 0,
BLDAT(10) TYPE C,
BLART LIKE BKPF-BLART,
BUKRS LIKE BKPF-BUKRS,
BUDAT(10) TYPE C,
MONAT LIKE BKPF-MONAT,
WAERS LIKE BKPF-WAERS,
XBLNR LIKE BKPF-XBLNR,


KURSF LIKE BKPF-KURSF, 
newbs LIKE RF05A-NEWBS,
NEWKO LIKE RF05A-NEWKO,
NEWUM LIKE RF05A-NEWUM,

NEWBW LIKE RF05A-NEWBW, 
*

NEWUM1 LIKE RF05A-NEWUM, 
NEWBW1 LIKE RF05A-NEWBW, 

WRBTR TYPE BSEG-WRBTR,


BSEG-WRBTR, 
BUPLA like BSEG-BUPLA,
SECCO like BSEG-SECCO,
ZFBDT(10) TYPE C,
SGTXT LIKE BSEG-SGTXT,
*


NEWBS1 LIKE RF05A-NEWBS, 
NEWKO1 LIKE RF05A-NEWKO, 
WRBTR1 TYPE BSEG-WRBTR, 
ZUONR LIKE BSEG-ZUONR, 

KOSTL LIKE COBL-KOSTL,

*

ZUONR1 LIKE BSEG-ZUONR, 
SGTXT1 LIKE BSEG-SGTXT, 
KOSTL1 LIKE COBL-KOSTL, 
END OF IT_OUT .

*DATA: IT_OUT1 LIKE IT_OUT OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK ABC WITH FRAME TITLE TEXT-T01.
PARAMETER : file LIKE IBIPPARMS-PATH OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK ABC.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.

CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'FILE'
IMPORTING
FILE_NAME = FILE
.


start-of-selection.
FNAME = FILE.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FNAME


FILETYPE = 'DAT' 
HAS_FIELD_SEPARATOR = 'X'

HEADER_LENGTH = 0 
READ_BY_LINE = 'X' 
DAT_MODE = ' ' 
CODEPAGE = ' ' 
IGNORE_CERR = ABAP_TRUE 
REPLACEMENT = '#' 
CHECK_BOM = ' ' 
VIRUS_SCAN_PROFILE = 
NO_AUTH_CHECK = ' ' 
IMPORTING 
FILELENGTH = 
HEADER = 
TABLES
DATA_TAB = IT_OUT
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.
ENDIF.

*IT_OUT1] = IT_OUT[.

perform open_group.

LOOP AT IT_OUT.

perform bdc_dynpro using 'SAPMF05A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWUM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT'
IT_OUT-BLDAT.
perform bdc_field using 'BKPF-BLART'
IT_OUT-BLART.
perform bdc_field using 'BKPF-BUKRS'
IT_OUT-BUKRS.
perform bdc_field using 'BKPF-BUDAT'
IT_OUT-BUDAT.
perform bdc_field using 'BKPF-MONAT'
IT_OUT-MONAT.
perform bdc_field using 'BKPF-WAERS'
IT_OUT-WAERS.
perform bdc_field using 'BKPF-XBLNR'
IT_OUT-XBLNR.
perform bdc_field using 'FS006-DOCID'
'*'.

if IT_OUT-NEWBS = '50' .


or IT_OUT-NEWBS1 = '40'. 
*LOOP AT IT_OUT1 WHERE poskey = '39'.

perform bdc_field using 'RF05A-NEWBS'
IT_OUT-NEWBS.
perform bdc_field using 'RF05A-NEWKO'
IT_OUT-NEWKO.
perform bdc_field using 'RF05A-NEWUM'
IT_OUT-NEWUM.
perform bdc_dynpro using 'SAPMF05A' '0304'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-WRBTR'
IT_OUT-WRBTR.
perform bdc_field using 'BSEG-BUPLA'
IT_OUT-BUPLA.
perform bdc_field using 'BSEG-SECCO'
IT_OUT-SECCO.
perform bdc_field using 'BSEG-ZFBDT'
IT_OUT-ZFBDT.
perform bdc_field using 'BSEG-SGTXT'
IT_OUT-SGTXT.

endif.
*ENDLOOP.


IF IT_OUT-newbs = '40'.
LOOP at IT_OUT.
perform bdc_field using 'RF05A-NEWBS'
IT_OUT-NEWBS.
perform bdc_field using 'RF05A-NEWKO'
IT_OUT-NEWKO.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-WRBTR'
IT_OUT-WRBTR.
perform bdc_field using 'DKACB-FMORE'
'X'.
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_OUT-KOSTL.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-WRBTR'.
perform bdc_field using 'BDC_OKCODE'
'=BS'.
perform bdc_field using 'BSEG-WRBTR'
'500.00'.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-GSBER'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
'9300'.
perform bdc_field using 'COBL-PRCTR'
'SERVICE'.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWBS'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_transaction using 'F-02'.

*endif.

ENDLOOP.
*ENDLOOP.
endif.
ENDLOOP.
perform close_group.

Regards

Pavan