DELETE itab - itab_line
These alternatives specify which single row of the internal table
itab is to be deleted.
... TABLE itab table_key
If you use the variant with the
TABLE addition, you specify the row by using
the primary table key
... itab INDEX idx [USING KEY keyname]
INDEX addition is used, the
deletes the row of the row number specified in
idx with respect to a table index.
idx is a
position of the operand type
idx contains a value of 0 or less, an exception is raised that cannot be handled.
Deletes the table row that has the same value as
carrid in the key field
p_carrid, by specifying a primary table index.
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. READ TABLE scarr_tab WITH TABLE KEY carrid = p_carrid TRANSPORTING NO FIELDS. IF sy-subrc = 0. DELETE scarr_tab INDEX sy-tabix. ENDIF.
... USING KEY keyname
If the addition
USING KEY is used, a table key can be declared in
keyname to declare the table index to be used explicitly.
If the primary table
key is specified under the name
primary_key, the table must be an index table, and the behavior is the same as when
USING KEY is not specified.
If a sorted secondary key exists, the
INDEX addition can be used for all table types, if
USING KEY is used.
This variant is only possible within a
across the same internal table. The current table row of the
LOOP is then
deleted implicitly. If the addition USING
KEY is specified in
LOOP, then the variant
USING KEY loop_key must be specified for this variant.
If the current row has already been deleted in the same loop, however, the behaviour is undefined.
This variant is not allowed outside of a
LOOP and raises a warning in the syntax check, if the check cannot detect (statically) its presence in a loop.
We do not recommend that you use this alternative. Instead, use the
INDEX addition to specify the row number explicitly.
The following loop deletes all lines in an internal table, since the short form of the
DELETE statement always deletes the current first line.
DATA itab TYPE TABLE OF i. DATA wa LIKE LINE OF itab. LOOP AT itab INTO wa TO 6. DELETE itab. ENDLOOP.
... USING KEY loop_key
This addition is required if the table key used by the
LOOP is specified
explicitly in the statement
LOOP. It states explicitly that the current table
row is deleted by the
LOOP. No other key can be specified apart from the
If no explicit table key is specified for
LOOP, then the addition
USING KEY loop_key is optional.