Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Abap Syntax for Deletion

Former Member
0 Likes
891

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

5 REPLIES 5
Read only

former_member193464
Contributor
0 Likes
849

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...

Read only

0 Likes
849

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

Read only

0 Likes
849

Hi Friends,

Thanks to all for your great suggestions.

Issue solved.

Cheers.

Amine

Read only

Sijin_Chandran
Active Contributor
0 Likes
849

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.

Read only

Former Member
0 Likes
849

try.

DELETE FROM ITABLE WHERE FIELDA EQ 0 OR FIELDB EQ 0.

regards

avirat