2006 Oct 17 9:50 AM
Hi ,
I need to get the Common data from Two Internal Tables with same structure with using the looping method.
For e.g.
I have two internal table say ITAB1 and ITAB2.
ITAB1 has values A,B,C,D,E,F
ITAB2 has values A,H,B,Y,O
Output at runtime should be : A,B
2006 Oct 17 9:53 AM
Hi mohit,
1. If u want to compare all fields,
for matching purpose,
then we can do like this.
2.
report abc.
data : a like t001 occurs 0 with header line.
data : b like t001 occurs 0 with header line.
loop at a.
LOOP AT B.
IF A = B.
WRITE 😕 'SAME'.
ENDIF.
endloop.
ENDLOOP.
regards,
amit m.
2006 Oct 17 9:51 AM
Do you mean, you want to know the common columns between these tables?
Regards,
Ravi
2006 Oct 17 9:52 AM
Hi,
Say itab1 and itab2 has the common field f1.
loop at itab1.
loop at itab2 where f1 = itab1-f1.
write : / itab2-f1.
endloop.
endloop.
2006 Oct 17 9:52 AM
Hello Mohit,
Use this code.
loop at itab1.
read table itab2 with key f1 = itab1-f1.
if sy-subrc = 0.
write: f1.
endif.
endloop.
If useful reward.
Vasanth
2006 Oct 17 9:53 AM
Hi mohit,
1. If u want to compare all fields,
for matching purpose,
then we can do like this.
2.
report abc.
data : a like t001 occurs 0 with header line.
data : b like t001 occurs 0 with header line.
loop at a.
LOOP AT B.
IF A = B.
WRITE 😕 'SAME'.
ENDIF.
endloop.
ENDLOOP.
regards,
amit m.
2006 Oct 17 9:53 AM
Hi Mohit
If you can use the looping then itz simple to extract the details.
loop at itab1.
read table itab2 with key fld1 = itab-fld1.
if sy-subrc ne 0.
delete itab where fld1 = itab-fld1.
endif.
endloop.
By end of this loop you will have all the entries in itab1 which are common both in itab1 and itab2.
Kind Regards
Eswar
2006 Oct 17 9:58 AM
Sorry my mistake i want it wiothout using the LOOPING Method.
Something like ITAB1 IN ITAB2 etc...
2006 Oct 17 10:02 AM