‎2007 May 01 6:29 PM
Hi,
I have following doubt. I am using a BAPI to get details regarding particular Object number. The list of object numbers are in internal table it_tab
Loop at it_tab.
Call Function 'ZCUSTOM'
EXPROTING
NUMBER = IT_TAB-NUMBER
TABLES
TAB1 = TAB1[]
TAB2 = TAB2[]
TAB3 = TAB3[].
Now the Data from TAB1 table, TAB2 table and Tab3 table should be written in a flat file1, fil2 and file3.
My doubt, is when the next number is passed to BAPI ZCUSTOM while looping, the data tables for that next number should be written in respective files but on next line (keeping the previous data intact)
So,
Data returned when NUMBER1 :- TAB1 - AAA,11; TAB2 - BBB,12; TAB3 - CCC,13
Data returned when Number2 :- TAB1 - YYY,10; TAB2 - ZZZ,09; TAB3 - TTT,08
Flat file1 Content should be:
AAA,11
YYY,10
-
Flat file2 Content should be:
BBB,12
ZZZ,09
-
Flat file3 Content should be:
CCC,13
TTT,08
How can I achieve this ?
Regards,
Rajesh.
‎2007 May 01 6:38 PM
transfer the contents of internal table inside the loop itself.
else,
move contents of those internal tables to another internal table
Loop at it_tab.
Call Function 'ZCUSTOM'
EXPROTING
NUMBER = IT_TAB-NUMBER
TABLES
TAB1 = TAB1[]
TAB2 = TAB2[]
TAB3 = TAB3[].
move tab1 to tabA.
move tab2 to tabb.
... tab3 to tabc .
append : taba,. tabb, tabc.
endloop.
‎2007 May 01 6:37 PM
If you are using OPEN DATASET, use the option FOR APPENDING. See below.
OPEN DATASET p_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
If you are using GUI_DOWNLOAD, then set the parameter "append = 'X' ".
‎2007 May 01 6:38 PM
‎2007 May 01 6:38 PM
transfer the contents of internal table inside the loop itself.
else,
move contents of those internal tables to another internal table
Loop at it_tab.
Call Function 'ZCUSTOM'
EXPROTING
NUMBER = IT_TAB-NUMBER
TABLES
TAB1 = TAB1[]
TAB2 = TAB2[]
TAB3 = TAB3[].
move tab1 to tabA.
move tab2 to tabb.
... tab3 to tabc .
append : taba,. tabb, tabc.
endloop.
‎2007 May 01 7:00 PM
‎2007 May 01 7:03 PM
Ok, so again, I would build internal tables for you files. Then when done in the LOOP and calling the custom BAPI, simply download the internal tables to the PC once. see the pseudo code below.
Loop at itab.
call function 'ZCUSTOM'
......
append lines of ttab1 to itab1.
append lines of ttab2 to itab2.
append lines of ttab3 to itab3.
append lines of ttab4 to itab4.
endloop.
call function 'GUI_DOWNLOAD'
.....
tables
data_tab = itab1.Regards,
Rich Heilman