‎2005 Jul 07 11:13 PM
Hi people,
There are itab1, itab2 and itab3. Itab3 is the final table. Now if I am writing data from both itab1 and itab2 to itab3, there are some entries which exist both in itab1 and itab2 although I am trying apply an if endif condition to eliminate entries from going into itab 2. Both times i am appending values from itab1 and itab2 to itab3.
Can somebody suggest something?
Thanks,
AM
‎2005 Jul 08 4:31 AM
Hi,
If you are talking about dupilcate entries,then you can do the following.After getting records from both itab1 and itab2,use the following.
sort itab3.
delete adjacent duplicates from itab3.
‎2005 Jul 08 4:33 AM
Hi,
If the structures of internal table are same,then you can do the following if you want to combine both the internal tables.
Append lines of itab1 to itab2.
sort itab2.
delete adjacent duplicates from itab2.
‎2005 Jul 12 3:08 AM
Hey people,
This did not solve my problem.
What i am doing is getting information from itab1 into ftab. Then I am manipulating itab2 to put data into itab 3 and then finally from itab3 the data goes into ftab. So there are values coming to ftab from itab1 which are also coming into ftab from itab3 which I want to keep in ftab but delete the values coming in from itab1 for the same customer. kunnr is a field in ftab. and values from itab1 are written before values from itab3 as follows:
123 itab1 values
123 itab3 values
234 itab1 values
234 itab1 values
235 itab1 values
--
--
--
342 itab3 values
and so on.
So can somebody help.
thanks,
AM
‎2005 Jul 12 4:48 AM
Hi,
In your internal table ftab,make use of one more field flag.
Set the flag = '' if you are populating ftab from itab1.
Set the flag = 'X' if you are populating ftab from itab3.
After you get the values in ftab,
sort ftab by kunnr flag.
delete adjacent duplicates from ftab comparing kunnr flag.
This will delete the similar kunnr which you already populated using itab1.
‎2005 Jul 08 4:59 AM
Hi,
I will give u a sample code
LOOP AT itab1 into w_itab1.
READ itab2 into w_itab2 with key
fieldname = w_itab1-fieldname(common field from both the table)
if sy-subrc = 0.
MOVE-CoREESPONDING w_itab1 to w_itab3.
MOVE-CoREESPONDING w_itab2 to w_itab3.
Append w_itab3 to itab3.
endif.
clear: w_itab1, itab2, itab3.
Endloop.
Hope this helps , if u want more clarification do get back to me.
Thanks & Regards,
Judith.
‎2005 Jul 08 5:21 AM
Hi ,
The previous logic is correct but if we are deleting the entries in the itab1 and itab2 after appending it to itab3.Then it will be easy to append those records which are not common.
Sample code
LOOP AT itab1
READ itab2 with key
fieldname = w_itab1-fieldname(common field from both the table)
if sy-subrc = 0.
move-corresponding itab1 to itab3.
Append itab3.
delete itab1.
delete itab2.
endif.
append lines of itab1 to itab3.
append lines of itab2 to itab3.
Endloop.
I think it will help u.
With Regards,
Ranganathan.