Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal table

Former Member
0 Likes
431

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
411

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

4 REPLIES 4
Read only

Former Member
0 Likes
411

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

Read only

Former Member
0 Likes
411

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

Read only

Former Member
0 Likes
412

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

Read only

Former Member
0 Likes
411

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