Application Development 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: 

Compare two internal tables

Former Member
0 Kudos

Hi,

Could please help me by comparing two internal tables i have to get data into one of the internal table which do not have the data of other internal table. How to do this?

for example: itab has 2 records.

a b

c d

itab1 has 2 records

z n

s g

now my itab should have

a b

c d

z b

s b

z d

s d

how to write the code for this.

Thanks in advance.

9 REPLIES 9

vinod_vemuru2
Active Contributor
0 Kudos

Hi Srilatha,

Do like this.

APPEND LINES OF itab1 TO itab.

Thanks,

Vinod.

Former Member
0 Kudos

hi,

pass data of one iternal table into another by

itab1 = itab2

thanks &regards,

pankaj vashista

Former Member
0 Kudos

Move the 2 internal table data to one internal table & delete the duplicate entries.

ex:

append lines of itab2 to itab1.

sort itab1 by field1 field2.

delete adjacent duplicates from itab1 comparing field1 field2.

Former Member
0 Kudos

Hi,

Check this out..


itab2[] = itab[].

loop at itab into wa.
loop at itab1 into wa1.

wa-fld1 = wa1-fld1.
append wa to itab2.
endloop.
endloop.

now the itab2 will have the values like you require.

Itab2 ,and the workareas should have the type of itab.

Reward if helpful.

Regards.

Edited by: Akshay Raj on Mar 24, 2008 8:24 AM

0 Kudos

Hi,

Do like this.

itab2 [ ] = itab [ ].

loop at itab into wa.

loop at itab1 into wa1 where fld1 NE wa-fld1 AND fld2 NE wa-fld2.

wa-fld1 = wa1-fld1.

append wa to itab2.

endloop.

endloop.

by this no duplicates will come into table itab2.

Please reward if useful.

Regards,

Ramesh

Edited by: Ramesh Jakkula on Mar 24, 2008 8:58 AM

Former Member
0 Kudos

I understand the following. you have internal tables itab itab1. Also that they have two fields, lets call them x and y.

we will declare a work area wa_tab, wa_tab1 of the same type as the internal table.

Now:

>Your requirement:

>itab has 2 records.

>a b

>c d

>itab1 has 2 records

>z n

>s g

>now my itab should have

>a b

>c d

>z b

>s b

>z d

>s d

Suggestion:

loop at itab1 into wa_tab1.

loop at itab into wa_tab.

wa_tab-x = wa_tab1-x.

append wa_tab to itab.

endloop.

endloop.

Former Member
0 Kudos

Hi Srilatha,

Do like this .

itab2[] = itab[].

loop at itab2 into wa2.

loop at itab1 into wa1.

wa2-field1 = wa1-field1

append wa2 to itab.

endloop.

endloop.

Hope this will help you.

0 Kudos

Hi Srilatha,

Do like this .

take another internal table itab2.

itab2[ ] = itab[ ].

loop at itab2 into wa2.

loop at itab1 into wa1.

wa2-field1 = wa1-field1

append wa2 to itab.

endloop.

endloop.

Hope this will help you.

Former Member
0 Kudos

Using append itab into itab1 stetement we can populate the datas from one internal table to another.

to delete the duplicate entries please use this statement DELETE ADJACENT DUPLICATES FROM itab.