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: 

finding unavailable records

Former Member
0 Kudos

I have 2 itabs with the following struc

itab1 - f1 f2 f3

itab2 - f1 f3 f2

now i want to find the records in itab1 which are not in itab2. How can we do this... is there any funcs available ?

4 REPLIES 4

Former Member
0 Kudos

Loop at itab1.

read table itab2 with key field1 = itab1-field1

itab1-field2

itab1-field3.

If sy-subrc ne 0.

append fileds of itab1 to itab3.

endif.

endloop.

Former Member
0 Kudos

Hi,

try this

sort itab2 by field.

loop at itab1.

read table itab2 with key field = itab1-field binary search.

if sy-subrc eq 0.

same record exists.

else.

same record doesnot exists

endif.

endloop.

reward points if helpful

thanks & regards,

venkatesh

Former Member
0 Kudos

Hi Suresh,

There is no function module avialable for this requirement but you can achieve this using LOOP...ENDLOOP with READ statement combination.

Check this code.

itab1 - f1 f2 f3

itab2 - f1 f3 f2

itab1_only - f1 f2 f3

SORT ITAB2 BY F1 F2 F3.

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1 F2 = ITAB1-F3 F3 = ITAB1-F2.

IF SY-SUBRC = 0.

APPEND ITAB1 TO ITAB1_ONLY.

ENDIF.

CLEAR ITAB1.

ENDLOOP.

Thanks,

Vinay

Former Member
0 Kudos

hi babu,

i have send you the code and the logic to your is hope it is useful for you.

run that code in se38 you will understand the logic.

give points if it is useful.