2012 Nov 27 10:21 AM
Hello Abap experts,
I am generating a csv file from an internal table trouph an abap Program.
I am looking for the correct abap syntax to perform this treatment:
Delete FROM internal Table records where both field A and field B are equal to 0.
Do I have to use a loop or an IF or Delete records where?
Thanks.
Amine
Junior BW consultant
Moderator message: very basic and covered by ABAP documentation -> un-marked as question.
Message was edited by: Thomas Zloch
Hello Abap experts,
I am generating a csv file from an internal table trouph an abap Program.
I am looking for the correct abap syntax to perform this treatment:
Delete FROM internal Table records where both field A and field B are equal to 0.
Do I have to use a loop or an IF or Delete records where?
Thanks.
Amine
Junior BW consultant
Moderator message: very basic and covered by ABAP documentation -> un-marked as question.
Message was edited by: Thomas Zloch
2012 Nov 27 10:29 AM
No you do not require loop and if statements , delete command takes care of it.use
DELETE itab WHERE field A EQ 0 AND field B eq 0.
if field A and field B initial values are 0 . you can also use fieldA is INITIAL AND filedb IS INITIAL.
DELETE itab WHERE fieldA is INITIAL AND filedb IS INITIAL.
use whichever suits you.
hope it helps...
2012 Nov 27 10:44 AM
In addition to Maverick's reply following all usages of the DELETE statement:
Single line deletion:
DELETE itab INDEX idx (only for standard and sorted tables)
Multiple lines deletion:
DELETE itab FROM idx1 TO idx2 (only for standard and sorted tables)
DELETE itab WHERE <logical condition> (as Maverick said)
Multiple lines deletion from an internal table that is sorted:
DELETE ADJACENT DUPLICATES FROM TABLE itab [COMPARING <fields>]
Multiple lines deletion using the table key:
DELETE TABLE itab WITH TABLE KEY keyfield1 = value1 keyfield2 = value2
Hope it helps
2012 Nov 27 12:28 PM
Hi Friends,
Thanks to all for your great suggestions.
Issue solved.
Cheers.
Amine
2012 Nov 27 10:36 AM
Hi Amine ,
Delete FROM internal Table records where both field A and field B are equal to 0.
As what I have understood you need to use all three statements i.e LOOP and IF-ENDIF and DELETE as well.
LOOP for accessing the Internal Table records one by one ,
IF_ENDIF for checking conditions on the value of fields from the work area(record)
and DELETE for deleting the record based on IF-ENDIF result.
2012 Nov 27 10:44 AM
try.
DELETE FROM ITABLE WHERE FIELDA EQ 0 OR FIELDB EQ 0.
regards
avirat
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |