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: 

comparing two internal tables

Former Member
0 Kudos
2,319

Hi all,

I have two internal tables say itab1 and itab2 as follows.

Itab1

kschl Gl no

Cond1 10229

Cond2 10988

Cond3 1228

Cond4 12977

Cond5 1467

Cond6 86888

Cond7 97008

itab2

Kunwe kschl

111 Cond1

111 Cond2

111 Cond3

112 Cond1

112 Cond4

113 Cond3

113 Cond5

i have to compare these two internal tables and i have to catch the condition types which are missing in itab2 for each kunwe.(for eg. for kunwe=111 the missing condition types are cond4,cond5,cond6,cond7)

kindly help me.

Thanks,

Praveena.

means

1 ACCEPTED SOLUTION

Former Member
101

Hi

declare another itab with kunwe, kschl.

Loop at ITAB2.

read table itab1 with kschl = itab2-kschl.

if sy-subrc = 0.

delete itab1 index sy-tabix.

endif.

endloop.

Now ITAB1 will have the condition types that are missing for ITAB2 KUNWE.

Reward points if useful

Regards

Anji

5 REPLIES 5

Former Member
102

Hi

declare another itab with kunwe, kschl.

Loop at ITAB2.

read table itab1 with kschl = itab2-kschl.

if sy-subrc = 0.

delete itab1 index sy-tabix.

endif.

endloop.

Now ITAB1 will have the condition types that are missing for ITAB2 KUNWE.

Reward points if useful

Regards

Anji

0 Kudos
101

HI,

DATA: itab3 like itab1.

Loop at itab1 into wa_itab1.

READ TABLE itab2 into wa_itab2 with key kschl = wa_itab1-lschl.

if sy-subrc<>0.

append wa_itab1 into itab3.

endif.

endloop.

Regards,

Sesh

Former Member
0 Kudos
101

Hi

Try the following code given below.

delete adjacent duplicates from itab2 comparing kunwe.

loop at itab2.

loop at itab1.

if itab1-kschl <> itab2-kschl.

append itab2-kunwe to temp-kunwe.

append itab1-kschl to temp-kschl.

endif.

endloop.

endloop.

Hope this helps u.

Reward if helpful.

Thanks & regards,

Prakash Ghantasala

Former Member
0 Kudos
101

hi,

create a internal table with required fields as

data; begin of itab3 occurs 0,

lschl like itab2-lschl [ database-field name]

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

end of itab.

Loop at itab1 into wa_itab1.

READ TABLE itab2 into wa_itab2 with key kschl = wa_itab1-lschl.

if sy-subrc<>0.

append wa_itab1 into itab3.

endif.

endloop.

if helpful reward some points.

with regards,

suresh babu aluri.

Former Member
0 Kudos
101

i am giving u the solution as per the example u have given.

itab3 [] = itab2[].

sort itab2 by kunwe.

sort itab3 by kunwe.

loop at itab2.

on change of itab2-kunwe.

loop at itab3

where kunwe <> itab2-kunwe.

endloop.

endon.

endloop.

Please reward some points if Useful.

Regards,

Padmakar