Ansicht
Dokumentation
ABAPDELETE_ITAB_INDEX - DELETE ITAB INDEX
General Material Data BAL_S_LOG - Application Log: Log header dataThis documentation is copyright by SAP AG.
DELETE itab, index
... ${ itab INDEX idx $[USING KEY keyname$] $}
$| ${ itab $[USING KEY loop_key$]$} ...
Alternatives:
1. ... itab INDEX idx $[USING KEY keyname$]
2. ... itab $[USING KEY loop_key$]
Effect
These alternatives specify the lines to be deleted using the specification of a line number relating to a table index.
Alternative 1
... itab INDEX idx
Addition:
Effect
If the INDEX addition is used, the DELETE statement deletes the line in the line number specified in idx in a table index. idx is a numeric expression position with the operand type i. If idx contains the value 0 or less, an uncatchable exception is raised.
If the addition USING KEY is not used, the addition INDEX can only be used with
index tables and determines the line to be deleted from the
primary table index.
Example
Deletion of the table line that has the same value as the input field carrid in the key field carrid, by using the primary table index.
Addition
... USING KEY keyname
Effect
The addition USING KEY can be used to specify a table key can be specified in keyname to specify the table index to be used explicitly.
If the table has a sorted secondary key, this can be specified in keyname. The line to be deleted is then determined from its secondary table index. A secondary hash key cannot be specified.
If the primary table key is specified under its name primary_key, the table must be an index table, and the behavior is the same as when USING KEY is not specified.
Note
If a sorted secondary key exists, the INDEX addition can be used for all table types, if USING KEY is used.
The DELETE statement deletes the third line of the internal table, since this has the line number 1 in the secondary table index belonging to the secondary table key skey.
Alternative 2
... itab
Addition:
Effect
This variant is only possible within a LOOP across the same internal table. The current table line of the LOOP is then deleted implicitly. If the addition USING KEY is specified in LOOP, the addition USING KEY loop_key must be specified for this variant.
If the current line was already deleted in the same loop, however, the behavior is undefined.
This variant is not allowed outside of a LOOP and raises a warning in the syntax check if it is not known statically that is executed in a loop.
Note
This alternative is not recommended. Instead, use the addition INDEX to specify the line number explicitly.
The following loop deletes all lines of an internal table, since the short form of the statement DELETE always deletes the current first line.
Addition
... USING KEY loop_key
Effect
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 line is deleted by the LOOP. No other
key can be specified apart from the predefined name loop_key.
If no explicit table key is specified for LOOP, the addition USING KEY loop_key is optional.
Since the primary table key is specified explicitly for the LOOP loop, USING KEY loop_key must be specified for DELETE as well.
General Material Data CPI1466 during Backup
This documentation is copyright by SAP AG.
Length: 6185 Date: 20240328 Time: 190255 sap01-206 ( 93 ms )