‎2007 Sep 04 9:55 PM
Hi Gurus,
I have a conditon where in I have two internal tables tab1 and tab2, tab 2 has the following records:
custid material date
101 123 01/01/2008
101 456 01/01/2008
102 123 01/01/2008
102 456 01/01/2008
102 789 01/01/2008
103 111 01/01/2008
103 112 01/01/2008
now I need to move only the unique cusid in table tab1, so basically tab1 shld have one field custid with the following records:
101
102
103
can you please help me how to write this one.
Thanks
Rajeev Gupta
‎2007 Sep 04 10:09 PM
Hi,
Move tab2 to tab1 , sort and delete adjacent duplicates comparing custid.
Code:
tab1 = tab2.
SORT tab1 BY custid.
DELETE ADJACENT DUPLICATES from tab1 comparing custid.
Regards
Sri
‎2007 Sep 04 10:01 PM
Hi Rajeev,
I think you can achieve this by using the At NEW control statement within the loop for internal table. The pseudo code for this looks something like below:
loop at tab2 into wa2.
at new custid.
move wa2 into wa1.
append wa1 to tab1.
endloop.
Here, wa1 and wa2 are work areas for tab1 and tab2 respectively.
Hope this helps.
Thanks and Regards
Subray Hegde
‎2007 Sep 04 10:07 PM
the easist and the best way to get this is.
itab1[] = itab2[].
Sort itab1 with key custid.
Delete adjacent duplicates from itab1 comparing custid.
Shreekant
‎2007 Sep 04 10:09 PM
Hi,
Move tab2 to tab1 , sort and delete adjacent duplicates comparing custid.
Code:
tab1 = tab2.
SORT tab1 BY custid.
DELETE ADJACENT DUPLICATES from tab1 comparing custid.
Regards
Sri
‎2007 Sep 04 10:10 PM
for the answer i specified above, ITAB1 and ITAB2 should have the same structure.
SORT ITAB1 by CUSTID.
and then delete adjacent duplicates.
However if ITAB1 and ITAB2 dont have the same structure use control commands like at new.
Shreekant