06-20-2006 11:06 AM
HI all!
I have two internal tables with single field values as below :
1st Internal Table : A,B,C,D
2nd Internal Table : A,B,C,D,E,F,G,
Now I want to compare these two Int. tables and delete the second int. table with values which are not there in the first int. table.Any simple logic to get this.
Regards
Pavan
06-20-2006 11:09 AM
loop at itab_old.
DELETE TABLE itab WITH TABLE KEY k1 = itab_old-k1 ... kn = itab_old-kn.
endloop.
06-20-2006 11:09 AM
loop at itab_old.
DELETE TABLE itab WITH TABLE KEY k1 = itab_old-k1 ... kn = itab_old-kn.
endloop.
06-20-2006 11:10 AM
Hi
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY FIELD = ITAB2-FIELD.
IF SY-SUBRC <> 0. DELETE ITAB2. ENDIF.
ENDLOOP.
max
06-20-2006 11:10 AM
hi
DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
or
loop at itab2.
read table itab1 with key f1 = itab2-f1.
if sy-subrc <> 0.
delete itab2.
endif.
endloop.
06-20-2006 11:10 AM
loop at itab2.
read table itab1 with key colum1 = itab2-column1 column2 = column2.
if sy-subrc = 0.
delete itab2.
endif.
endloop.
Regards,
Ravi
Note : Please mark the helpful answers
06-20-2006 11:13 AM
Sort internal table 1 by A B C D.
Now ..
copy contents of 2nd table to a temp table.
loop at 2nd internal table.
read 1st internal table with key a = 2internal table a
b = 2internal table b
c = 2internal table c
d = 2internal table d.
if sy-subrc ne 0.
delete entry from temp table.
now refresh table 2.
copy contents of temp to table 2.
Guys,
I guess DELETING THE SAME TABLE WITHIN A LOOP .. ENDLOOP is not advisable.Please correct me if i m wrong.
endif.
endloop.
Message was edited by: Nishanth Bhandar
Message was edited by: Nishanth Bhandar
06-20-2006 11:36 AM
HI Kumar,
Try with following code.
ITAB1 FIELD1 FIELD2 FIELD3 FIELD4
1stIT A B C D
ITAB2 FIELD1 FIELD2 FIELD3 FIELD4 FIELD5 FIELD6 FIELD7
2ndIT A B C D E F G
<b>LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY FIELD1 = ITAB1-FIELD1 FIELD2 = ITAB1-FIELD2 FIELD3 = ITAB1-FIELD3 FIELD4 = ITAB1-FIELD4.
IF SY-SUBRC <> 0.
DELETE ITAB2.
ENDIF.
ENDLOOP.</b>
Thanks,
Vinay
06-20-2006 12:01 PM
Hi pavan,
Please check this code.
loop at tab1.
read table tab2 with key field1 = tab1-field1.
if sy-subrc ne 0.
delete tab2.
modify tab2.
endif.
endloop.
Hope this will help u.
06-20-2006 12:14 PM
Hi pavan,
I hope this works for ur criteria...
Loop at itab1.
Delete Itab2 where field_1 <> itab1-field_1
and field_2 <> itab1-field_2
and field_3 <> itab1-field_3
Endloop.
regards,
Kiran B
06-20-2006 12:26 PM
Hi,
try this,,
sort: it1 , it2 ,
loop at it1.
read table it2 with key pernr = it1-pernr
FAC_C = it1-FAC_C
binary search.
if sy-subrc eq 0.
write: / it1-pernr, it1-fac_c.
endif.
endloop.
or
User Corresponding field option
or
if it1[] = it2[].
If it helps reward points
Regards,
Nandha