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

copying internal table

Former Member
0 Likes
642

hi,

iam having two internal tables itab1 and itab2.i have to copy contents of table itab1 to itab2 and delete the duplicate entries in itab2.

please provide the code for this.

thanks in advance

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
591

If you have defined your tales with the OCCURS 0.


data: itab1 like mara occurs 0 with header line,
itab2 like mara occurs 0 with header line.
itab1[] = itab2[].
sort itab2.
delete adjacent duplicates from itab2.

If you have defined tables with the types than:


data: itab1 type standard table of mara ,
itab2 type standard table of mara .
itab1 = itab2.
sort itab2.
delete adjacent duplicates from itab2.

Regards,

Naimesh Patel

Message was edited by:

Naimesh Patel

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
592

If you have defined your tales with the OCCURS 0.


data: itab1 like mara occurs 0 with header line,
itab2 like mara occurs 0 with header line.
itab1[] = itab2[].
sort itab2.
delete adjacent duplicates from itab2.

If you have defined tables with the types than:


data: itab1 type standard table of mara ,
itab2 type standard table of mara .
itab1 = itab2.
sort itab2.
delete adjacent duplicates from itab2.

Regards,

Naimesh Patel

Message was edited by:

Naimesh Patel

Read only

Former Member
0 Likes
591

Hi Surya,

itab2[] = itab1[].

or

Loop at itab1.

move-corresponding itab1 to itab2.

append itab2.

Endloop.

Note : Ensure that two internal tables must contains the same structure.

Delete duplicate values :

DELETE ADJACENT DUPLICATES FROM ITAB.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
591

Hi,

You have the copy the values of itab1 to itab2 as below :

itab2[] = itab1[]

or

append lines of itab1 to itab2.

To delete the duplicate entries.

sort itab --> Sort the itab with necessary fields.

delete adjacent duplicates from itab comparing <fieldnames>.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
591

Hi,

Make sure itab1 & itab2 are of same structure.

itab2[] = itab1[].

delete adjacent duplicates from itab2.

Bye,

kc

Read only

Former Member
0 Likes
591

Hi,

Do like this

itab2[] = itab1.

sort itab2 by key field.

delete adjacent duplicates from itab2 comparing keyfield.

Regards,

Satish