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

problem in FB01

Former Member
0 Likes
2,226

i have developed a BDC program for Tcode FB01.it is working fine if i am reading individual lines from excel but how can i access same line twice from excel for different fields of FB01.

19 REPLIES 19
Read only

Former Member
0 Likes
2,162

This message was moderated.

Read only

0 Likes
2,162

this is not working.i want the same excel line to be read according to document type.

Read only

0 Likes
2,162

Hi Ankan,

In your internal table, you want to re read the same record (two times) based on document type but why?

Please give data example in your internal table and explain the requirement clearly such that we can help.

Regards,

Ankit

Read only

former_member214709
Participant
0 Likes
2,162

Hi Ankan,

You have to put your recording within the loop containing the data which has been uploaded through Excel/text file.

As Sai mentioned itab1[] = itab2[].

This is perfectly fine but instead of using Loop inside loop , i think your purpose can be solved by just using:

Loop at itab1.

Read itab2 with key ............

if sy-subrc eq 0.

endif.

Endloop.

Regards,

Dinesh

Read only

anup_deshmukh4
Active Contributor
0 Likes
2,162

Hello  Ankan ,

I din't got your problem though ,

But Why do you want to read the excel in your internal table you will have to develop logic to fill in the BDC field accoridn to your required by reading it from the internal table.

As suggested by Sai  a bapi will be much better option .

Hope it helps,

Anup

Read only

Former Member
0 Likes
2,162

i have attached the excel sheet which i have used in recording.and below is my required excel sheet for uploading through BDC.now please suggest how to do this.

My excel sheet















DOC_DATE1TYPECOMPCODEPOST_DATE1PERIODCURRENCYEMPIDPOSTKEY1ACCOUNT1AMOUNT1ASNMT1POSTKEY2ACCOUNT2AMOUNT2ASMNT2BUSAREAPFTCTR
30.05.2013SER00330.05.2013
INR531835UP379/34512968 24,733.00408000002968UP379/3451B001PR003
30.05.2013SRR00330.05.2013
INR531835UP379/34512427 24,733.00401081902427UP379/3451B001PR003


































requirement
















Employee No.NamePF NUMBER BASICDED_PFCOMP_PFCOMP_FPFVPF








5318DEEPAK KUMAR AGARWALUP379/3451 24,733.0029682427541










































IF TYPE = SE















FOR POSTKEY1=35















AMOUNT1=DED_PF















ACCOUNT1=PF NO















ASSIGNMENT1=BASIC















FOR POSTKEY2=40















ACCOUNT2 =800000















AMOUNT2=DED_PF















ASSIGNMENT2=PF NO
































IF TYPE = SR















FOR POSTKEY1=35















AMOUNT1=COMP_PF















ACCOUNT1=PF NO















ASSIGNMENT1=BASIC















FOR POSTKEY2=40















AMOUNT2=COMP_PF















ACCOUNT2 =108190















ASSIGNMENT2=PF NO















Read only

0 Likes
2,162

Hi,

If i understand you correctly then you need to combine the records of an internal table on basis of EMP ID. You can achieve the same via Control Break Statements in SAP ABAP. Here you can use 'At NEW EMPID...... Endat'.

I have another question for you, as mentioned in your data, you have one SE and one SR type record for the same Employee but the determination of values for fields like ACCOUNT2 etc is different for both so how do you intend to achieve the same for final record of every employee.

Regards,

Ankit.

Read only

0 Likes
2,162

i dont require the same final record.what i want is for a single line it should create 2 document number.one for doctype 'SE' i.e. for ded_pf column and second is for document type 'SR' i.e. for comp_pf coclumn.i.e. it is reading same line twice based on the document header.

Read only

0 Likes
2,162

Hi,

Your Excel has two rows of data, how? Thats what i asked in first place that how does your input look like - here it seems you have two different rows of input so you need not read the same table twice.

My excel sheet















DOC_DATE1TYPECOMPCODEPOST_DATE1PERIODCURRENCYEMPIDPOSTKEY1ACCOUNT1AMOUNT1ASNMT1POSTKEY2ACCOUNT2AMOUNT2ASMNT2BUSAREAPFTCTR
30.05.2013SER00330.05.2013
INR531835UP379/3451296824,733.00408000002968UP379/3451B001PR003
30.05.2013SRR00330.05.2013
INR531835UP379/3451242724,733.00401081902427UP379/3451B001PR003




KR,

Ankit

Read only

0 Likes
2,162

thanks for the reply,but i dont have two rows,i have a single row only.

i have a format of my input as below.my problem is it should create two document numbers by running BDC for FB01 one for doc type "DED_PF" and second for doc type "COMP_PF"  taking same employee no,pf number,basic.

Employee No.NamePF NUMBERBASICDED_PFCOMP_PF









5318DEEPAK KUMAR AGARWALUP379/345124,733.29682427
Read only

0 Likes
2,162

do not pass document type in your excel....
write your bdc code two times
for example...
PERFORM BDCDATA USING FIELDS whatever you want to pass
here first give TYPE as SE,
now append the data to bdcdata table that you may be forming,
now again write the PERFORM fill bdcdata using fields,
here pass the type as SR
and append to bdcdata...
so for every single record of your excel there will be two BDCDATA records which should solve your problem...

Read only

0 Likes
2,162

thanks,i have done like this only and it is working fine but my requirement is in same line as i am downloading excel from other program and uploading it in this BDC program.i dont want to change excel as records are in a large amount.

Read only

0 Likes
2,162

if i am getting you right then you do not need to change your excel file...
once you receive the file ,
loop in the file

perform fill_bdcdata for doctype SE

(here all the recoring screens should be filled)
once this is done append it to bdc data
call transaction FB01 using BDCDATA

refresh bdcdata and other variables
again write all the performs passing the same data and this time doc type SR

and append it to bdcdata.

again call transaction FB01 using BDCdata

Now endloop.

so main thing is to have call transaction twice

Read only

0 Likes
2,162

but for that also i have to give it in two lines only.otherwise it is excepting first call transaction only and then coming out.

Read only

0 Likes
2,162

after coming out of the first call transaction it would be going onto the second call transaction thus generating two document numbers for the same line... am i missing something here ?

Read only

0 Likes
2,162

i have attached my code for that part.kindly see to it.

IF IT_UPLOAD-TYPE = 'SE'.

perform bdc_dynpro      using 'SAPMF05A' '0100'.

perform bdc_field       using 'BDC_CURSOR'

                              'BKPF-LOTKZ'.

perform bdc_field       using 'BDC_OKCODE'

                              '/00'.

perform bdc_field       using 'BKPF-BLDAT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BKPF-BLART'

                              'SE'.

perform bdc_field       using 'BKPF-BUKRS'

                              'R003'.

perform bdc_field       using 'BKPF-BUDAT' IT_UPLOAD-POST_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BKPF-MONAT'

                              ' '.

perform bdc_field       using 'BKPF-WAERS'

                              'INR'.

perform bdc_field       using 'BKPF-XBLNR' IT_UPLOAD-PERNR.

*                              '5318'.

perform bdc_field       using 'FS006-DOCID'

                              '*'.

perform bdc_field       using 'RF05A-NEWBS'

                              '35'.

perform bdc_field       using 'RF05A-NEWKO' IT_UPLOAD-ACCOUNT1.

*                              'UP379/3451'.

perform bdc_dynpro      using 'SAPMF05A' '0302'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-ZUONR'.

perform bdc_field       using 'BDC_OKCODE'

                              '=BU'.

perform bdc_field       using 'BSEG-WRBTR' IT_UPLOAD-AMNT1.

*                              '2968'.

perform bdc_field       using 'BSEG-ZFBDT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BSEG-ZUONR' IT_UPLOAD-ASNMT1.

*                              'UP379/3451'.

perform bdc_field       using 'RF05A-NEWBS'

                              '40'.

perform bdc_field       using 'RF05A-NEWKO'

                              '800000'.

perform bdc_dynpro      using 'SAPMF05A' '0300'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-ZUONR'.

perform bdc_field       using 'BDC_OKCODE'

                              '=BU'.

perform bdc_field       using 'BSEG-WRBTR' IT_UPLOAD-AMNT1.

*                              '2968'.

perform bdc_field       using 'BSEG-VALUT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BSEG-ZUONR' IT_UPLOAD-ACCOUNT1.

*                              'UP379/3451'.

perform bdc_field       using 'RF05A-NEWBS'

                              '40'.

perform bdc_field       using 'RF05A-NEWKO'

                              '800000'.

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

                              'B001'.

perform bdc_field       using 'COBL-PRCTR'

                              'PR003'.

perform bdc_dynpro      using 'SAPMF05A' '0300'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-WRBTR'.

perform bdc_field       using 'BDC_OKCODE'

                              'BU'.

perform bdc_field       using 'BSEG-VALUT'

                              '30.05.2013'.

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

  CALL TRANSACTION 'FB01'

                 USING BDCDATA

                 MODE  'A'

                 MESSAGES INTO IT_MESSTAB.

ELSEIF IT_UPLOAD-TYPE = 'SR'.

perform bdc_dynpro      using 'SAPMF05A' '0100'.

perform bdc_field       using 'BDC_CURSOR'

                              'BKPF-LOTKZ'.

perform bdc_field       using 'BDC_OKCODE'

                              '/00'.

perform bdc_field       using 'BKPF-BLDAT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BKPF-BLART'

                              'SR'.

perform bdc_field       using 'BKPF-BUKRS'

                              'R003'.

perform bdc_field       using 'BKPF-BUDAT' IT_UPLOAD-POST_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BKPF-MONAT'

                              ' '.

perform bdc_field       using 'BKPF-WAERS'

                              'INR'.

perform bdc_field       using 'BKPF-XBLNR' IT_UPLOAD-PERNR.

*                              '5318'.

perform bdc_field       using 'FS006-DOCID'

                              '*'.

perform bdc_field       using 'RF05A-NEWBS'

                              '35'.

perform bdc_field       using 'RF05A-NEWKO' IT_UPLOAD-ACCOUNT1.

*                              'UP379/3451'.

perform bdc_dynpro      using 'SAPMF05A' '0302'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-ZUONR'.

perform bdc_field       using 'BDC_OKCODE'

                              '=BU'.

perform bdc_field       using 'BSEG-WRBTR' IT_UPLOAD-AMNT1.

*                              '2968'.

perform bdc_field       using 'BSEG-ZFBDT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BSEG-ZUONR' IT_UPLOAD-ASNMT1.

*                              'UP379/3451'.

perform bdc_field       using 'RF05A-NEWBS'

                              '40'.

perform bdc_field       using 'RF05A-NEWKO'

                              '108190'.

perform bdc_dynpro      using 'SAPMF05A' '0300'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-ZUONR'.

perform bdc_field       using 'BDC_OKCODE'

                              '=BU'.

perform bdc_field       using 'BSEG-WRBTR' IT_UPLOAD-AMNT1.

*                              '2968'.

perform bdc_field       using 'BSEG-VALUT' IT_UPLOAD-DOC_DATE1.

*                              '30.05.2013'.

perform bdc_field       using 'BSEG-ZUONR' IT_UPLOAD-ACCOUNT1.

*                              'UP379/3451'.

perform bdc_field       using 'RF05A-NEWBS'

                              '40'.

perform bdc_field       using 'RF05A-NEWKO'

                              '108190'.

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

                              'B001'.

perform bdc_field       using 'COBL-PRCTR'

                              'PR003'.

perform bdc_dynpro      using 'SAPMF05A' '0300'.

perform bdc_field       using 'BDC_CURSOR'

                              'BSEG-WRBTR'.

perform bdc_field       using 'BDC_OKCODE'

                              'BU'.

perform bdc_field       using 'BSEG-VALUT'

                              '30.05.2013'.

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

  CALL TRANSACTION 'FB01'

                 USING BDCDATA

                 MODE  'A'

                 MESSAGES INTO IT_MESSTAB.

and this is the excel i am uploading and it is working fyn.

DOC_DATETYPEPOST_DATEEMPIDACC1AMNT1ASNGMNT1
30.05.2013SE30.05.2013             5,318 UP379/3451296824,733
30.05.2013SR30.05.2013             5,318 UP379/3451242724,733

but how to change it in a format like below to upload properly.

DOC_DATEPOST_DATEEMPIDACC1ASNGMNT1SESR
30.05.201330.05.2013          5,318 UP379/345124,73329682427

I.E. if type is SE save amount1 as SE column value and if it is SR save amount as SR column.

Read only

0 Likes
2,162

From what you wrote, I'm not sure of your requirement, but could you try to sort your internal table by "document split criteria" : DOC_DATE, POST_DATE, EMPID, ACC, ASNGMNT1, (TYPE) and move field TYPE after the "key" fields in the stucture definition of the internal table (so 2 structures may be required, one for the data uploaded, one for the work internal table with same fields but different sequences)

Then loop at the internal table, start/end document AT BEGIN/END OF ASNGMNT1 (last split key), create items of the document depending on TYPE value, and balance the document in the AT END block.

Regards,

Raymond

Read only

0 Likes
2,162

Sorry but not getting your exact requirement...
Initially you said that you are getting one line from excel and want to generate two documents from it ...
Now we see that you have two lines in excel..
do you want something like in SE column the line 1 amount should be copied and
in SR column line 2 amount should be copied....
If yes ,
create a new internal table copying the whole structure and adding two more columns SE and SR amounts

define a key for your internal table so that which can give you two separate rows for SE amount and SR amount once you have got it.
you need to modify your current internal table to have the key fields first in the structure, you can use loop and move corresponding to get your new input table

now sort based on the fields of the key

Loop in the data that you are getting.

move corresponding and see if doc type is SE then set amount to SE amount field.

if doc type is SR set amount in SR amount field.
Do not append here

AT END OF key(last field)

Append the new workare to your final input table.

clear the work area

end at.

Endloop.

then use it in a normal BDC call

Read only

Former Member
0 Likes
2,162

May be the Document at this link can help you.

Here LSMW is created for Multiple Recording ..

http://www.saptechnical.com/Tutorials/LSMW/MultipleRecordings/Index.htm

Hope it helps,

Rajiv Kumar