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

comparing two internal tables

Former Member
0 Likes
450

Hi frnds,

I have two internal tables it1,it2.

it1 has 50 records,it2 has 20 records. These 20 record are common for both the tables.But i don't know the order of the fields . I need the records of table it1 other than that 20 records.i.e.,I need only the remaining 30 records.Please give the logic for this requirement.

Thanks in advance

4 REPLIES 4
Read only

Former Member
0 Likes
430

hi,

go to the following link

Surely help u.

https://www.sdn.sap.com/irj/sdn/advancedsearch?query=comparing%20two%20internal%20tables&cat=sdn_all

<b>plz reward if useful.</b>

Swati

Read only

Former Member
0 Likes
430

Let both it1 and it2 be internal tables with header lines(work area)

loop at it1.

read table it2 with key field1 = it1-field2......

if sy-subrc = 0.

delete it1.

endif.

endloop.

Now it1 will contain you required data

......................

for the read stmt u must give the all fields in the table.

Reward if useful

Message was edited by:

Arjun Puthuruthy

Read only

Former Member
0 Likes
430

hi,

loop at it1 into workarea1.

read table it2 into workarea2 where it2-fld1 = it1-fld1.(COMMON RECORD)

IF SY-SUBRC NE 0.

APPEND workarea1 to it3.

endif.

endloop.

Regards,

Srinivas

Read only

Former Member
0 Likes
430

Hi

SORT the both internal tables by the key fields and read the it2 table with the linking fields of it1

data l_tabix like sy-tabix.

loop at it1.

l_tabix = sy-tabix.

read table it2 with key f1 = it1-f2 and f2 = it1-f4.

if sy-subrc = 0.

delete it1 index l_tabix.

endif.

endloop.

Now it1 will have those 30 records which are not there in it2.

<b>Reward points for useful Answers</b>

Regards

Anji