‎2005 Jun 08 3:11 PM
Hi Guys,
Need to know something. I have this following code:
LOOP at tab1
-
-
LOOP at tab2
Append ftab.
endloop
LOOP at tab3
Append ftab.
endloop
LOOP at tab4
Append ftab.
endloop
LOOP at tab5
Append ftab.
endloop
Append ftab
Endloop
Now the problem is that my final table ftab is giving repeated values.
Can somebody help?
I really need help on this asap.
Thanks in advance.
‎2005 Jun 08 3:15 PM
‎2005 Jun 08 3:16 PM
Hi,
As you are looping on each table based on the condition which is derived from tab1 and appending at each loop for the same key data, also finally after these entire process you append at the last which might have the entries same as that of the last loop for tab5. try to clear the header if required at each sucessive loop statements.
Regards,
Jagath
‎2005 Jun 08 3:24 PM
Hi Minal,
if your probles is the presence of repeted values, try to make a DELETE ADJACENTS .
More, what do you do in the inner loop?
Does ftab have always value of tab1?
Put all the code, problably I coul'd help you better.
Bye
‎2005 Jun 08 3:36 PM
Hi Minal,
You can do 2 things:
(1) decide whether to append ftab before 'append' statement: Use "read table ftab into wa_ftab with key keyfield = value" for this. If you get a returncode 0, the record is already in ftab.
(2) always append and delete double entries afterwards (like suggested by Enzo). You will have to sort the table first. "sort ftab by key. delete adjacent duplicates from ftab comparing key."
I think, I'd prefer the second option...
Hope this helps, regards, Kathrin!
‎2005 Jun 08 4:08 PM
Hi Minal,
If it is so that ftab table is taking some fields form each of the tables u are looping at then what u need to take care of in addition to the above advice(s) is clear the internal tables u are looping at, at the end of every loop ... if not what it will do is carry forward the values even if not populate in the record of the next itab iteration.
Hope this makes sense.
Regards,
Aditya