DELETE itab - table_key
Short Reference
ABAP Syntax ... { FROM wa [USING KEY keyname
] }
| { WITH TABLE KEY [ keyname COMPONENTS]
{comp_name1|(name1)} = operand1
{comp_name2|(name2)} = operand2
... } ... .
ABAP_ALTERNATIVES:
1 ... FROM wa [USING KEY keyname]
2 ... WITH TABLE KEY [keyname COMPONENTS] ...
Latest notes: When deleting a row from a standard table using a secondary
key, the entire runtime depends linearly on the number of table rows. Al
though the rows to be deleted are found quickly, when updating the
primary index a linear search for the entry to be deleted must be
carried out.
ABAP_ALTERNATIVE_1 ... FROM wa [USING KEY keyname]
If the primary table key is used to
access a standard table and the key is
empty , then the first row of the internal
table is deleted. If this is statically identifiable, the syntax check
produces a warning.
Latest notes: When using the primary table key, note that this key can
be the standard key , which can also have
unexpected consequences:
For structured row types, the standard key covers all character-like and
byte-like components.
The standard key of a standard table can be
empty .
Outside of classes, an obsolete short form
is also possible where FROM wa can be omitted if the internal
table has a header line itab with
the same name. The statement then uses the header line as the work area
implicitly. Furthermore, USING KEY cannot be specified without
USING KEY .
Example ABAP Coding A work area scarr_wa is used to delete the table
row that has the same value as p_carrid in the key field
carrid of the primary table.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA: scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid,
scarr_wa LIKE LINE OF scarr_tab.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
IF sy-subrc = 0.
scarr_wa-carrid = p_carrid.
DELETE TABLE scarr_tab FROM scarr_wa.
ENDIF.
ABAP_ALTERNATIVE_2
... WITH TABLE KEY [keyname COMPONENTS] ...
Example ABAP Coding By explicitly declaring the primary table key, the table
row is deleted that has the same value as p_carrid in the key
field carrid .
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
DELETE TABLE scarr_tab WITH TABLE KEY carrid = p_carrid.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved