... { FROM wa }
| { WITH TABLE KEY {comp_name1|(name1)} = dobj1
{comp_name2|(name2)} = dobj2
...
} ... .
You can specify the values of the search key either implicitly after FROM
in a work area wa or by explicitly listing the components of the table key after TABLE KEY.
1. ... FROM wa ...
2. ... WITH TABLE KEY ...
... FROM wa ...
The work area wa must be a data object that is compatible
with the row type of the internal table. The statement deletes the first internal table row whose values
in the columns of the table key match those of the corresponding components of
wa. If the key fields in wa are empty, no entry is deleted.
Outside of classes, you can omit the FROM wa addition if the internal table has an identically named
header line itab. The statement then implicitly uses the header line as the work area.
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.
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.
... WITH TABLE KEY ...
Each component of the table key must be specified either directly as comp_name1 comp_name2 ... or as a character-type data object in parentheses name1 name2 ..., which contains the name of the component in uppercase when the statement is executed. If name contains only blank characters, this component entry is ignored when the statement is executed. Every component must be assigned a data object dobj1 dobj2 ... that is compatible with or convertible to the data type of the component. The statement deletes the first internal table row whose values in the columns of the table key match those in the assigned data objects dobj1 dobj2 .... If necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison.
The individual table kinds are accessed as follows:
If a table has a non-structured row type and the entire table row is defined as the table key, you can specify the
pseudo component table_line as the component.
By explicitly specifying the 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.