10-05-2009 5:05 PM
Hi,
I have two internal tables itab1 and itab2.
I need to delete records from itab1 comparing the data from itab2. I tried to use the read statement within the main table.
My problem is itab2 and itab1 has multiple records and all the records need to be checked from itab2 with itab1 before deleting the records from itab1.
itab1 and itab2 have a common field 'runid' between them.
How can this be accomplished?
Thanks,
VG
10-05-2009 5:23 PM
Hi VG,
Try this way.
Thanks
Venkat.O
data: tabix type sy-tabix.
loop at itab1.
tabix = sy-tabix.
LOOP at itab2 where runid = itab1-runid.
if sy-subrc NE 0.
delete itab1 index tabix.
endif.
endloop.
10-05-2009 5:08 PM
loop at itab1 into is1.
read table itab2 into is2 with key runid = is1-runid.
if sy-subrc NE 0.
delete itab1.
endif.
endloop.
10-05-2009 5:11 PM
Can you provide a example of the internal table values and how you are expecting to delete the records?
10-05-2009 5:23 PM
Hi,
The records appear like this,
itab1
3464, 0100, PP, 1855
3475, 0100,PP,1864
3455,0100,PP,1877
3488,0100,PP,1866
itab2 records
3464,0100,PP,1855
3488,0100,PP,1866
I need to delete the records 1864 and 1877.
Thanks again,
VG
10-05-2009 5:40 PM
10-05-2009 5:57 PM
10-05-2009 5:23 PM
Hi VG,
Try this way.
Thanks
Venkat.O
data: tabix type sy-tabix.
loop at itab1.
tabix = sy-tabix.
LOOP at itab2 where runid = itab1-runid.
if sy-subrc NE 0.
delete itab1 index tabix.
endif.
endloop.
10-05-2009 5:31 PM
>
> Hi VG,
> Try this way.
>
> data: tabix type sy-tabix.
> loop at itab1.
> tabix = sy-tabix.
> _LOOP at itab2 where runid = itab1-runid._
_> if sy-subrc NE 0._
> delete itab1 index tabix.
> endif.
> endloop.
>
> Thanks
> Venkat.O
Venkat, inside a loop a IF SY-SUBRC NE 0 doesn't make sense because you are in the loop only after the condition in WHERE clause is satisfied (which means SY-SUBRC is always 0). Also you are missing another ENDLOOP.
10-05-2009 5:36 PM
Hey thanks for highlighting my mistake. I just wrote without system.
Thanks
Venkat.O
data: tabix type sy-tabix.
loop at itab1.
tabix = sy-tabix.
Read table itab2 with key runid = itab1-runid.
if sy-subrc NE 0.
delete itab1 index tabix.
endif.
endloop.