‎2006 Nov 13 9:13 PM
Hello friends,
I have to delete a record from an Internal table based on comparing two fields from the same line in the Internal table.
I am using this code.
LOOP AT itab.
IF itab-01_kschl = 'ZBX1'.
IF itab-02_kschl <> 'ZAXS' OR
itab-02_kschl <> 'ZRON' OR
itab-02_kschl <> 'ZTIS' .
DELETE itab index sy-tabix.
ENDIF
ENDIF.
ENDLOOP.
I am kind of worried to delete using the sy-tablx as the index. Is there a bettew way to handel this issue.
Thanks.
Shejal.
‎2006 Nov 13 9:18 PM
‎2006 Nov 13 9:18 PM
‎2006 Nov 13 9:20 PM
Hi,
Try this..
DELETE ITAB WHERE 01_KSCHL = 'ZBX1' AND
( 02_KSCHL <> 'ZAXS' AND
02_KSCHL <> ZRON' AND
02_KSCHL <> 'ZTIS' ).
Thanks,
Naren
‎2006 Nov 13 9:20 PM
Hi,
Move the condition values to a range and use syntax
delete itab where kschl in r_range.
aRs
‎2006 Nov 13 9:23 PM
Thanks Rich, Naren and Mony.
Thanks again for your advice and help.
Shejal.
‎2006 Nov 13 9:23 PM
I'm not sure your logic is correct. Do you want to:
delete itab
where 01_kschl = 'ZBX1'
and 02_kschl <> 'ZAXS'
and 02_kschl <> 'ZRON'
and 02_kschl <> 'ZTIS'.
Rob
‎2006 Nov 13 9:24 PM
Hello Shejal
You could simplify your DELETE statement like this:
DELETE itab WHERE ( 01_kschl = 'ZBX1' )
AND NOT ( 02_kschl = 'ZAXS' OR
02_kschl = 'ZRON' OR
02_kschl = 'ZTIS' ).
Regards
Uwe