‎2008 Dec 12 5:26 AM
Hi all,
I have three loops under a main loop
Loop at maintable .
loop at table1.
endloop.
loop at table2.
endloop.
loop at table3.
endloop.
endloop.
my question is that i have mutiple records in the table 1,2,3
i dont know where to use my append maintable as if i use in the main loop only one record of the table
is updated
anyone there to help me
please
‎2008 Dec 12 5:30 AM
Hi Sridhar,
Declare one work area for maintable and use it at the end of all three loops, as given below.
Loop at maintable .
loop at table1.
" WA_MAINTABLE-field
endloop.
loop at table2.
" WA_MAINTABLE-field
endloop.
loop at table3.
" WA_MAINTABLE-field
endloop.
" APPEND WA_MAINTABLE to MAINTABLE.
endloop.
Instead you can even use READ statement if possible, based on your requirement.
Best Regards,
Ram.
‎2008 Dec 12 5:34 AM
i have used read table only but , it is getting only record , i have used workarea ,
and the table1,2,3 has muliple records , where is it is overwriten and the final value is updated to the fiinal tale
‎2008 Dec 12 5:39 AM
Hi Sridhar,
1. Is it necessary for you to LOOP in table 1, 2 and 3, inside your MAINTABLE. Are you using any condition in your inner loops?
2. If yes, and if you want all those records to be updated then you need to use APPEND inside your inner loop.
KIndly let us know your requirement.
Best Regards,
Ram.
‎2008 Dec 12 5:45 AM
yes i need to use loop inside the maintable , and one more thing , can i use multiple append in my loops , casue i am afraid it might lead to duplicate records or some error
‎2008 Dec 12 5:57 AM
Hi Sridhar,
In case you are worrying about duplicate records, you can always use, Delete adjacent duplicates statement on your main table to remove it.
I think i am not very clear on what you are trying to acheive.
First, You want records from your MAINTABLE to be filled from itab1, itab2 and itab3. Hope this is correct.
To acheive this,
First
loop at itab1.
" Append entries to your maintable.
endloop.
Now, based on these entries, if you want to fill records from itab2 and itab3. If yes, then
loop at itab2.
" read maintable with key. If found, modify, else, append to maintable
endloop.
loop at itab3.
" read maintable with key. if found, modify, else append to maintable.
endloop.
Hope this is what you want. If otherwise, please let us know.
Best Regards,
Ram.
‎2008 Dec 12 5:33 AM
Hi,
Can you please explain your question more clearly?
Regards,
Aruna
‎2008 Dec 12 5:35 AM
Hi
try to using read statement instead
READ TABLE <table> INTO <wa?WITH KEY <key>
‎2008 Dec 12 5:35 AM
Hi Loganadhan,
Please note if you are appending rows to an internal table which you are looping will result in ENDLESS LOOP.
First you collect the records from each internal table into a temporary itab then pass them to main loop.
or
loop each itab separately and append them to main table.
loop at itab1
append itab from itab1.
endloop
loop at itab2
append itab from itab2
endloop
loop at itab3
append itab from itab3
endloop
Regards
Ramchander Rao.K
‎2008 Dec 12 5:43 AM
sorry ram chandran,
i am not clear with ur concept casue append itab from itab1 it is showing me syntax error
‎2008 Dec 12 5:48 AM
Hi,
May be their line types are incompatible( not equal).
check the components of your internal tables( are they having same names and types)
loop at itab1.
move-correspondign itab1 to itab.
append itab.
endloop.
loop at itab2.
move-corresponding itab2 to itab.
append itab.
endloop.
loop at itab3.
move-corresponding itab3 to itab.
append itab.
endloop.
Best Regards
Ramchander Rao.K
‎2008 Dec 12 6:07 AM
loop at itab1.
move-corresponding itab1 to maintable.
append maintable.
endloop.
loop at itab2.
move-corresponding itab2 to maintable.
append maintable.
endloop
loop at itab3.
move-corresponding itab3 to maintable.
append maintable.
endloop
‎2008 Dec 12 6:18 AM
Hi,
What's your requirement?
So many loops in a main loop will effect the performance.
Regards,
Chris Gu
‎2008 Dec 12 10:19 AM
changed the loop with item level and read the header table using read statement and appended , the final table
i was not having any eror by doing this