Application Development and Automation 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: 
Read only

FB01 Recording

Former Member
2,029

Hi Experts!

We need to post documents by recording FB01 in LSMW. In this I have a few doubts.

1. How feasible it is to record FB01? I feel it is mostly not recommended. But for our requirement, we can't go for standard batch input method.

2. Suppose, we record FB01 with 2 line items, then can we use the same recording to post a doc with >2 line items?

3. We created a recording with 2 line items, but when we were uploading a file, it was taking the data in incorrect way. In other words, I recorded by posting a document with 2 line itens. And in file also I am giving 2 entries for one document. But this is trying to post a document for each entry in the file and hence we are getting some errors. How can this be solved?

Kindly suggest on these.

Thanks a lot.

Note: Same posted in ABAP General, so posting in the correct

Hi Experts!

We need to post documents by recording FB01 in LSMW. In this I have a few doubts.

1. How feasible it is to record FB01? I feel it is mostly not recommended. But for our requirement, we can't go for standard batch input method.

2. Suppose, we record FB01 with 2 line items, then can we use the same recording to post a doc with >2 line items?

3. We created a recording with 2 line items, but when we were uploading a file, it was taking the data in incorrect way. In other words, I recorded by posting a document with 2 line itens. And in file also I am giving 2 entries for one document. But this is trying to post a document for each entry in the file and hence we are getting some errors. How can this be solved?

Kindly suggest on these.

Thanks a lot.

Note: Same posted in ABAP General, so posting in the correct

9 REPLIES 9
Read only

nirajgadre
Active Contributor
0 Likes
1,602

Hi,

1. you can do the recording for FB01 and you can use the same recording for more than two line items.

2. for this you required to populate the BDC screens for line item details in the loop based on the number of line items you have.

3. in FB01 the line item screen number gets changed based on the type of gl account you are using e.g for customer line item item screen number is 300 and for customer line item screen number is 301. so while populating the item data in the bdc code you need to take the account type into the consideration.

4. In order to insure that all the line item belong to single document got posted one document you must call the save button BDC code at the end of the population of the each line item.

Try to modify the BDC code in LSMW based on this

Read only

dhirendra_pandit
Active Participant
0 Likes
1,602

Hi Srinivas,

This transaction is tedious to record, as per my recommendation you can use the idoc method within LSMW tool.

The IDOC details is as follows:

Message Type:-CTRACDOCUMENT_CREATE

Basic Type:-CTRACDOCUMENT_CREATE

Regards

Dhirendra

Read only

Former Member
0 Likes
1,602

Hi Srinivas,

It would really be very tough to cover all the scenarios in your recording for FB01. Because the field status changes based on different factors. By the way what is your requirement exactly what are the documents you are creating in FB01? Is it AR/AP/G/L Balances or uploading Journal Entries. The best way would be using LSMW with object - 0100 Financial documents. If this does not meet your requirements you can try this BAPI , BAPI_ACC_DOCUMENT_POST .

Read only

0 Likes
1,602

Hi I have pasted the code below for fb01 bdc.Its realy tedious job as depending on each posting key and G/L account the screen changes. Anyway try to go through the code.sorry for not putting any comments... anyway..i hope this will be helpful...

i am cutting the code into two posts as the maximum words permitted is exceeding

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

report zfb01_upload no standard page heading.

tables:ska1.

type-pools: truxs.

data :gi_raw_data type truxs_t_text_data.

data: bdcdata like bdcdata occurs 0 with header line.

data:bdcmess like bdcmsgcoll occurs 0 with header line.

data:begin of record occurs 0,

stat(2),

bldat(10),

blart type bkpf-blart,

bukrs type bkpf-bukrs,

budat(10),

waers(3),

wwert(10),

xblnr type bkpf-xblnr,

bktxt type bkpf-bktxt,

docid type fs006-docid,

newbs(2) type n," TYPE rf05a-newbs,

newko type rf05a-newko,

newum type rf05a-newum,

wrbtr type bseg-wrbtr,

zterm type bseg-zterm,

*zbd1t TYPE bseg-zbd1t,

zfbdt(10),

prctr type bseg-prctr,

kostl type bseg-kostl,

mwskz type bseg-mwskz,

sgtxt type bseg-sgtxt,

zuonr type bseg-zuonr, "assg

end of record.

clear:bdcdata,record.

refresh:bdcdata,record.

data:h_wrbtr type bseg-wrbtr ,

s_wrbtr type bseg-wrbtr ,

flag,

v_40,

v_01,

v_21,

post,

v_tabix ,

v_mwskz,

t_40.

data: v_bldat(10),

v_blart type bkpf-blart,

v_bukrs type bkpf-bukrs,

v_budat(10),

v_waers(3), "TYPE bkpf-waers,

v_wwert type bkpf-wwert,

v_xblnr type bkpf-xblnr,

v_sgtxt type bseg-sgtxt,

v_bktxt type bkpf-bktxt,

v_zuonr type bseg-zuonr,

v_docid type fs006-docid,

v_wrbtr type bseg-wrbtr,

v_zterm type bseg-zterm,

v_kostl type bseg-kostl,

v_newum type rf05a-newum,

v_zfbdt(10),

v_prctr type bseg-prctr.

data:cost.

data:v_newbs(2) type n," TYPE rf05a-newbs,

v_newko type rf05a-newko.

selection-screen begin of block b1 with frame title text-001.

parameters:file type rlgrap-filename .

selection-screen end of block b1.

at selection-screen on value-request for file.

call function 'F4_FILENAME'

exporting

field_name = 'file'

importing

file_name = file.

Read only

0 Likes
1,602

start-of-selection.

call function 'TEXT_CONVERT_XLS_TO_SAP'

exporting

i_field_seperator = 'X'

i_line_header = 'X'

i_tab_raw_data = gi_raw_data

i_filename = file

tables

i_tab_converted_data = record

  • EXCEPTIONS

  • CONVERSION_FAILED = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

endif.

  • PERFORM open_group.

data:v_xbilk like ska1-xbilk,

v_saknr like ska1-sakan.

data:rec_no type i.

data:begin of error occurs 0,

record type i,

end of error.

clear v_wrbtr.

loop at record.

  • MOVE sy-tfill TO rec_no.

select single saknr xbilk from ska1 into (v_saknr,v_xbilk)

where sakan = v_newko.

if v_xbilk = '' and v_saknr <> ''." sy-subrc <> 0.

cost = 'X'.

endif.

if record-stat = 'c' or record-stat = 'H' or record-stat = 'C' or record-stat = 'h'.

h_wrbtr = h_wrbtr + record-wrbtr .

elseif record-stat = 'd' or record-stat = 'S' or record-stat = 'D' or record-stat = 's'.

s_wrbtr = s_wrbtr + record-wrbtr.

endif.

if post = 'X' or sy-tabix = 1.

rec_no = sy-tabix + 1.

clear post.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

if record-bldat = ''.

perform bdc_field using 'BKPF-BLDAT'

v_bldat.

else.

perform bdc_field using 'BKPF-BLDAT'

record-bldat.

move record-bldat to v_bldat.

endif.

if record-blart = ''.

perform bdc_field using 'BKPF-BLART'

v_blart.

else.

perform bdc_field using 'BKPF-BLART'

record-blart.

move record-blart to v_blart.

endif.

if record-bukrs = ''.

perform bdc_field using 'BKPF-BUKRS'

v_bukrs.

else.

perform bdc_field using 'BKPF-BUKRS'

record-bukrs.

move record-bukrs to v_bukrs.

endif.

if record-budat = ''.

perform bdc_field using 'BKPF-BUDAT'

v_budat.

else.

perform bdc_field using 'BKPF-BUDAT'

record-budat.

move record-budat to v_budat.

endif.

Read only

0 Likes
1,602
  • PERFORM close_group.

write:/'Documents posted'.

loop at bdcmess .

if bdcmess-msgnr = '312' and bdcmess-msgtyp = 'S'.

write:/ bdcmess-msgv1.

endif.

endloop.

if error[] is not initial.

write:/ 'Line numbers ended in error'.

loop at error.

write:/ error-record.

endloop.

endif.

  • WRITE : /'Please Prosess the Session', 'FB01',' in SM35'.

&----


*& Form bdc_dynpro1

&----


  • text

----


  • -->PROGRAM text

  • -->DYNPRO text

----


form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform. "bdc_dynpro1

&----


*& Form bdc_field1

&----


  • text

----


  • -->FNAM text

  • -->FVAL text

----


form bdc_field using fnam fval.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

shift bdcdata-fval left deleting leading space.

append bdcdata.

endform. "bdc_field1

&----


*& Form bdc_transaction1

&----


  • text

----


  • -->TCODE text

----


form bdc_transaction using tcode.

call function 'BDC_INSERT'

exporting

tcode = tcode

tables

dynprotab = bdcdata.

endform. "bdc_transaction1

Read only

0 Likes
1,602

&----


*& Form open_group

&----


  • text

----


form open_group.

  • open batchinput group

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = 'fb01'

user = sy-uname

keep = 'X'.

  • holddate = holddate.

endform. "open_group

&----


*& Form close_group

&----


  • text

----


form close_group.

call function 'BDC_CLOSE_GROUP'.

endform. "close_group

&----


*& Form POST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form post .

clear cost.

clear: v_xbilk,v_saknr.

select single sakan xbilk from ska1 into (v_saknr,v_xbilk)

where sakan = record-newko.

if v_xbilk = '' and v_saknr <> ''." sy-subrc <> 0.

cost = 'X'.

endif.

if record-newbs = '40'.

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 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'BSEG-WRBTR'

record-wrbtr.

  • PERFORM bdc_field USING 'BSEG-MWSKZ'

  • 'v0'.

perform bdc_field using 'BSEG-SGTXT'

record-sgtxt.

perform bdc_field using 'BSEG-ZUONR'

record-zuonr."ass

  • IF cost = 'X' and record-kostl <> ''.

  • PERFORM bdc_field USING 'COBL-KOSTL'

  • record-kostl.

  • ENDIF.

if record-zfbdt <> ''.

perform bdc_field using 'BSEG-ZFBDT'

record-zfbdt.

endif.

if cost = 'X' and record-mwskz <> ''."record-newbs = '21' OR record-newbs = '31' OR cost = 'X'.

perform bdc_field using 'BSEG-MWSKZ'

record-mwskz.

endif.

perform bdc_field using 'BDC_OKCODE'

'=ENTE' .

elseif flag = 'X'.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

Read only

0 Likes
1,602

if cost = 'X' and record-mwskz <> ''.

perform bdc_field using 'BSEG-MWSKZ'

record-mwskz.

endif.

perform bdc_field using 'BDC_OKCODE'

'=ENTE' .

  • IF cost = 'X'.

  • PERFORM bdc_field USING 'COBL-KOSTL'

  • record-kostl.

  • ENDIF.

  • IF cost = 'X'."record-newbs = '21' OR record-newbs = '31' OR cost = 'X'.

  • PERFORM bdc_field USING 'BSEG-MWSKZ'

  • v_mwskz.

  • ENDIF.

elseif record-newbs = '39' or record-newbs = '29' or record-newbs = '19' or record-newbs = '09'.

perform bdc_dynpro using 'SAPMF05A' '0304'.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

perform bdc_field using 'BSEG-WRBTR'

record-wrbtr.

if record-zfbdt <> ''.

perform bdc_field using 'BSEG-ZFBDT'

record-zfbdt.

endif.

perform bdc_field using 'RF05A-NEWUM'"check

record-newum.

perform bdc_field using 'BSEG-SGTXT'

record-sgtxt.

perform bdc_field using 'BSEG-ZUONR'

record-zuonr."ass

if record-zterm <> ''.

perform bdc_field using 'BSEG-ZTERM'

record-zterm.

endif.

perform bdc_field using 'BDC_OKCODE'

'=ENTER'.

  • IF cost = 'X'.

  • PERFORM bdc_field USING 'COBL-KOSTL'

  • record-kostl.

  • ENDIF.

    • IF cost = 'X'."record-newbs = '21' OR record-newbs = '31' OR cost = 'X'.

    • PERFORM bdc_field USING 'BSEG-MWSKZ'

    • v_mwskz.

    • ENDIF.

perform bdc_field using 'BDC_OKCODE'

'=ENTE' .

endif.

perform bdc_field using 'BDC_OKCODE'

'=ENTE' .

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-PRCTR'.

perform bdc_field using 'COBL-PRCTR'

record-prctr.

if cost = 'X' and record-kostl <> ''.

perform bdc_field using 'COBL-KOSTL'

record-kostl.

endif.

perform bdc_dynpro using 'SAPLSPO4' '300'.

perform bdc_field using 'BDC_OKCODE'

'/ECANC'.

perform bdc_dynpro using 'SAPMF05A' '0700'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE' .

perform bdc_field using 'BDC_OKCODE'

'=BU'.

  • PERFORM bdc_transaction USING 'FB01'.

call transaction 'FB01' using bdcdata mode 'E' messages into bdcmess.

if sy-subrc <> 0.

move rec_no to error-record.

append error.

endif.

post = 'X'.

clear bdcdata.

refresh bdcdata.

  • CLEAR record.

endform. " POST

Read only

Former Member
0 Likes
1,602

Closing the thread.