ABAP DELETE table statements

Here you can see the usage of DELETE statements for deleting lines from database tables, cluster tables, index tables and internal tables.

Delete lines from the database tables

Syntax

  • DELETE FROM <dbtab> WHERE <cond>.

Here all the lines matching the condition (<cond>) in the database table (<dbtab>) will be deleted.

  • DELETE <dbtab> FROM <wa>.

Here the line in the database table that matching the primary key with specified work area (<wa>) will be deleted.

  • DELETE <dbtab> FROM TABLE <itab>.

Here all the lines in the database table that matching the primary keys in the specified internal table will be deleted.

Delete from the Cluster database tables

Syntax

  • DELETE FROM DATABASE <dbtab>(<ar>) ID <key>.

Here the cluster area (<ar>) with the specified name (<key>) will be deleted from the Cluster database table (<dbtab>).

  • DELETE FROM SHARED BUFFER <dbtab>(<ar>) ID <key>.

Here it deletes the data cluster for the area <ar> with the specified name <key> stored in the cross-transaction application buffer for the table <dbtab>.

Delete lines from the internal table.

Syntax

  • DELETE TABLE <itab> FROM <wa>.

Here the line in the internal table that matching the primary key with the specified work area will be deleted.

  • DELETE TABLE <itab> WITH TABLE KEY <k1> = <f 1>… <k n> = <f n>.

Here the lines in the table with the specified table keys will be deleted.

  • DELETE <itab> WHERE <cond>.

Here the lines in the table that matching the specified conditions will be deleted.

  • DELETE ADJACENT DUPLICATE ENTRIES FROM <itab> [COMPARING… ].

Deletes adjacent duplicate entries, either by comparing the key fields or the comparison fields specified explicitly in the COMPARING addition.

Delete lines from an Index table

  • DELETE <itab> [INDEX <idx>].

Here the line with the specified index will be deleted. We can use the same statement without INDEX addition within a loop. That time it will delete the current line.

  • DELETE <itab> [FROM <n1>] [TO <n 2>] [WHERE <cond>].

This statement is used to specify for deleting the lines between the index <n1> and <n2> and matching the condition <cond>

Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes