‎2013 May 31 10:49 AM
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.
‎2013 May 31 12:48 PM
‎2013 May 31 12:56 PM
this is not working.i want the same excel line to be read according to document type.
‎2013 Jun 01 3:55 AM
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
‎2013 May 31 12:57 PM
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
‎2013 May 31 11:07 PM
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
‎2013 Jun 01 5:58 AM
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_DATE1 | TYPE | COMPCODE | POST_DATE1 | PERIOD | CURRENCY | EMPID | POSTKEY1 | ACCOUNT1 | AMOUNT1 | ASNMT1 | POSTKEY2 | ACCOUNT2 | AMOUNT2 | ASMNT2 | BUSAREA | PFTCTR |
| 30.05.2013 | SE | R003 | 30.05.2013 | INR | 5318 | 35 | UP379/3451 | 2968 | 24,733.00 | 40 | 800000 | 2968 | UP379/3451 | B001 | PR003 | |
| 30.05.2013 | SR | R003 | 30.05.2013 | INR | 5318 | 35 | UP379/3451 | 2427 | 24,733.00 | 40 | 108190 | 2427 | UP379/3451 | B001 | PR003 | |
| requirement | ||||||||||||||||
| Employee No. | Name | PF NUMBER | BASIC | DED_PF | COMP_PF | COMP_FPF | VPF | |||||||||
| 5318 | DEEPAK KUMAR AGARWAL | UP379/3451 | 24,733.00 | 2968 | 2427 | 541 | ||||||||||
| 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 |
‎2013 Jun 01 8:50 AM
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.
‎2013 Jun 01 9:55 AM
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.
‎2013 Jun 01 4:15 PM
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_DATE1 | TYPE | COMPCODE | POST_DATE1 | PERIOD | CURRENCY | EMPID | POSTKEY1 | ACCOUNT1 | AMOUNT1 | ASNMT1 | POSTKEY2 | ACCOUNT2 | AMOUNT2 | ASMNT2 | BUSAREA | PFTCTR |
| 30.05.2013 | SE | R003 | 30.05.2013 | INR | 5318 | 35 | UP379/3451 | 2968 | 24,733.00 | 40 | 800000 | 2968 | UP379/3451 | B001 | PR003 | |
| 30.05.2013 | SR | R003 | 30.05.2013 | INR | 5318 | 35 | UP379/3451 | 2427 | 24,733.00 | 40 | 108190 | 2427 | UP379/3451 | B001 | PR003 | |
KR,
Ankit
‎2013 Jun 03 6:21 AM
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. | Name | PF NUMBER | BASIC | DED_PF | COMP_PF | ||||||||||
| 5318 | DEEPAK KUMAR AGARWAL | UP379/3451 | 24,733. | 2968 | 2427 |
‎2013 Jun 03 6:30 AM
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...
‎2013 Jun 04 11:12 AM
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.
‎2013 Jun 04 11:34 AM
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
‎2013 Jun 04 12:42 PM
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.
‎2013 Jun 04 2:59 PM
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 ?
‎2013 Jun 05 6:00 AM
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_DATE | TYPE | POST_DATE | EMPID | ACC1 | AMNT1 | ASNGMNT1 |
| 30.05.2013 | SE | 30.05.2013 | 5,318 | UP379/3451 | 2968 | 24,733 |
| 30.05.2013 | SR | 30.05.2013 | 5,318 | UP379/3451 | 2427 | 24,733 |
but how to change it in a format like below to upload properly.
| DOC_DATE | POST_DATE | EMPID | ACC1 | ASNGMNT1 | SE | SR |
| 30.05.2013 | 30.05.2013 | 5,318 | UP379/3451 | 24,733 | 2968 | 2427 |
I.E. if type is SE save amount1 as SE column value and if it is SR save amount as SR column.
‎2013 Jun 05 7:33 AM
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
‎2013 Jun 05 9:12 AM
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
‎2013 Jun 05 7:45 AM
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