‎2010 Mar 04 7:39 AM
Hai i am having flatfile like this format
H text1 1000 plant_name 10 short_text X X
20 short_text X X
30 short_text X X
H text1 1000 plant_name 10 short_text X X
20 short_text X X
30 short_text X X
now this H indicates new record. In each new record number of line items are there.
How to proceed using internal tables. please help me.
‎2010 Mar 04 8:04 AM
Hello,
Try splitting your flat file data into 2 separate internal tables. One will hold the header data and one will hold the line item data. Both the internal tables would be linked with a set of common columns to identify the set of line item data related to the header data.
Suppose you have created 2 internal tables say int_h and int_i (for header and line items respectively).
loop across the header table and run your BDC. As soon as you reach the screen where line item data is used, run another loop in the line item table with the where condition on the common fields from header table and continue with your BDC. Save data before next header data starts. Check the following pseudo code
loop at int_h into wa_h.
perform BDC for header data.
loop at int_i into wa_i where f1 = wa_h-f1 "assuming f1 is the linking field
perform BDC for line items.
endloop.
perform save
endloop.
Hope this helps.
Regards,
Sachin
‎2010 Mar 04 7:51 AM
Hi,
Try to use EXTRACT data set , as in that u can use different structure in a single table.
[http://help.sap.com/saphelp_nw70ehp1/helpdata/en/9f/db9ed135c111d1829f0000e829fbfe/content.htm]
lemme know the BDC code which u are using in case of confusion...
‎2010 Mar 04 7:58 AM
hi,
arrange your flat file like this...
H text1 1000 plant_name 10 short_text X X
H text1 1000 plant_name 20 short_text X X
H text1 1000 plant_name 30 short_text X X
H1 text1 1000 plant_name 10 short_text X X
H1 text1 1000 plant_name 20 short_text X X
H1 text1 1000 plant_name 30 short_text X X
now make an internal table having all the fields present in your flat file
and loop at that internal table and on change of field H call your function module and pass the value for record H......
similarly it will work for H1.....H2.....
for eg...
LOOP AT "Your internal table" INTO "Work area of your internal table".
AT END OF "field name for H".
CALL FUNCTION ''Your function module"
‎2010 Mar 04 8:02 AM
Hi
Use the Control Break statments for your requirements.
If you want make one record per line, the record which is start with H you can separate the below way.
LOOP
AT END OF H ( H - The new record start with H)
use the move statement to make one record per line.
ENDAT.
ENDLOOP.
‎2010 Mar 04 8:04 AM
Hello,
Try splitting your flat file data into 2 separate internal tables. One will hold the header data and one will hold the line item data. Both the internal tables would be linked with a set of common columns to identify the set of line item data related to the header data.
Suppose you have created 2 internal tables say int_h and int_i (for header and line items respectively).
loop across the header table and run your BDC. As soon as you reach the screen where line item data is used, run another loop in the line item table with the where condition on the common fields from header table and continue with your BDC. Save data before next header data starts. Check the following pseudo code
loop at int_h into wa_h.
perform BDC for header data.
loop at int_i into wa_i where f1 = wa_h-f1 "assuming f1 is the linking field
perform BDC for line items.
endloop.
perform save
endloop.
Hope this helps.
Regards,
Sachin
‎2010 Mar 08 5:50 AM
Thank you for your answers
Edited by: Prabu S on Mar 8, 2010 6:51 AM