‎2007 Mar 23 11:33 AM
Hi,
I Have two internal tables with Objnr as the common field in that. Not i need to delete the records from the first internal table where the OBJNR of the second internal table is not in the first internal table. Pls let me know how to do this.
Regards,
Ramesh.
‎2007 Mar 23 11:36 AM
loop at itab2.
read table itab1 where objnr = itab2-objnr.
if sy-subrc <> 0.
delete itab1 index sy-tabix.
endif.
endloop.
‎2007 Mar 23 11:37 AM
Hi,
Please try this.
loop at itab1.
read table itab2 with key objnr = itab1-objnr.
if sy-subrc <> 0.
delete itab1.
else.
continue.
endif.
endloop.
Regards,
Ferry Lianto
‎2007 Mar 23 12:11 PM
Hi,
Unable to delete the records from the first table with the logic given.
For example i have around 200 records in the first internal table. And in my second internal table i have 30 records. These 30 records are available in my first internal table also. Now i need to delete the remaining 170 records from the first internal table. The common field in these table is OBJNR. Based on this i need to delete the records.
Regards,
Ramesh
‎2007 Mar 23 12:45 PM
Hi..try this..
data:
w_index type i.
loop at itab1 into fs_itab1.
w_index = sy-tabix.
read table itab2 with key objnr = fs_itab1-objnr into fs_itab2.
if sy-subrc eq 0.
delete itab1 index w_index.
endif.
endloop.
reward...if it helpss u...
-Rammohan
‎2007 Mar 23 1:30 PM
Hi ram,
check this code.this will solve ur problem with out adding extra field.
data:itab1 like mara occurs 0 with header line.
data:itab2 like mara occurs 0 with header line.
select * from mara into table itab1.
select * from mara into table itab2 up to 2 rows.
loop at itab1.
write:/ itab1-matnr.
endloop.
skip 2.
loop at itab2.
write:/ itab2-matnr.
endloop.
skip 2.
loop at itab1.
read table itab2 with key matnr = itab1-matnr.
if sy-subrc <> 0.
delete itab1 where matnr = itab1-matnr.
endif.
endloop.
loop at itab1.
write:/ itab1-matnr.
endloop.
reward if helpful.
‎2007 Mar 23 2:03 PM
Hi,
Try this code.
*&---------------------------------------------------------------------*
DATA: l_index LIKE sy-tabix.
SORT: itab1 BY objnr,
itab2 BY objnr.
LOOP AT itab1.
l_index = sy-tabix.
READ TABLE itab2 WITH KEY objnr = itab1-objnr.
IF sy-subrc <> 0.
DELETE itabl INDEX i_index.
ENDIF.
ENDLOOP.
*&---------------------------------------------------------------------*Let me know if you need any other information.
Regards,
RS
‎2007 Mar 23 2:03 PM
Hi RamMohan,
SORT ITAB1 BY OBJNR.
SORT ITAB2 BY OBJNR.
LOOP AT ITAB2 INTO WA_ITAB1.
READ TABLE ITAB1 WITH KEY OBJNR = WA_ITAB1-OBJNR.
IF SY-SUBRC = 0.
LV_INDEX = SY-TABIX.
DELETE ITAB1 INDEX LV_INDEX.
ENDIF.
ENDLOOP.
Thanks,
Vinay
‎2007 Mar 23 11:38 AM
Hi,
loop at itab1.
delete itab2 where table key objjr = itab1-objjr.
endloop.
regards,
bharat.
‎2007 Mar 23 12:37 PM
Hi..
Try this code.
Loop at itab2.
read table itab1 with key objnr = itab2-objnr.
if sy-subrc EQ 0.
Append itab1 to itab3.
endif.
endloop.
U may process the itab3 now..
Regards
Bala.