1. DELETE
itab.
2. DELETE
TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
3. DELETE
TABLE itab [FROM wa].
4.
DELETE itab INDEX idx.
5.
DELETE itab FROM idx1 TO idx2.
6.
DELETE itab WHERE logexp.
7. DELETE ADJACENT DUPLICATES FROM itab.
See Short forms of line operations not allowed.
Deletes one or more lines from an internal table.
If you delete lines within a LOOP ... ENDLOOP block, the deletion affects subsequent loop passes.
DELETE itab.
Deletes the current entry from an internal table in a
LOOP. You can only use this variant with index tables (standard or sorted tables).
Return Code is set to 0.
Once you have deleted the current entry of an internal table in a
LOOP, the effect of subsequent changes to the current
entry without specifying the INDEX cannot be guaranteed, and the behavior may change in future releases.
DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
Deletes generically from an internal table. You can use this variant for
any tables. The variant is a single command that deletes the table line with the key values
k1 = v1 ....kn = vn. If there is more than one line with
the specified key, only the first one is deleted. The table key must be specified fully. If the type
of a value and the type of the associated key are not compatible, the system converts the value into
the type of the component before the statement is executed, using
MOVE logic. If a component is not known until runtime,
you can specify it dynamically as the contents of the field fi
in the expression WITH TABLE KEY ... (fi) = vi ....
The costs for deleting one entry depend on the table type with which the table is defined:
DELETE TABLE itab [FROM wa].
Behaves similarly to variant 2. The values for the table key are taken from the corresponding components
of the (structured) field wa. The field must be compatible
with the table line of itab. This method allows you to
delete from a table without the table key having to be known in advance. If the internal table has a
header line, you can leave out the FROM wa addition; the system then takes the key values from the header line.
DELETE itab INDEX idx.
Deletes the
idx-th entry of the internal table itab. This
variant is only allowed with index tables (standard or sorted tables).
The Return Code is set as follows:
DELETE itab FROM idx1 TO idx2.
Deletes the range of lines from index
idx1 to idx2
from the internal table itab. You can only use this variant
with index tables (standard or sorted tables). You must specify at least one of the parameters
FROM idx1 or TO idx2.
If you omit the FROM parameter, the system deletes the
lines from the start of the table to idx2. If you omit
the
TO parameter, the system deletes from line idx1
to the end of the table. The starting line idx1 must be greater than 0.
The Return Code is set as follows:
DELETE itab WHERE logexp.
1. ... FROM
idx1
2. ... TO idx2
Deletes all of the entries from the internal table itab
that satisfy the condition
logexp. The condition logexp
can be almost any logical expression. The only restriction is that the
first field in each comparison must be a component of the line structure of the internal table
itab.
The Return Code is set as follows:
... FROM idx1
Restricts the area searched to the set of lines beginning at index idx1.
If you omit the addition FROM idx1, the system searches
from the start of the table.
The FROM addition must occur before the WHERE condition.
... TO idx2
Restricts the area searched to the set of lines up to index idx2.
If you omit the addition TO idx2, the system searches
to the end of the table.
The TO addition must occur befor the WHERE condition.
Example to delete all of the lines between 5 and 36 in a table of names where the entry begins with
one of the letters 'A' to 'C'.
TYPES: BEGIN OF NAMETAB_TYPE,
NAME(30) TYPE C,
END OF NAMETAB_TYPE.
DATA: NAMETAB TYPE STANDARD TABLE
OF NAMETAB_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 100.
...
DELETE NAMETAB FROM 5 TO 36 WHERE NAME CA 'ABC'.
DELETE ADJACENT DUPLICATES FROM itab.
1. ... COMPARING
f1 f2 ...
2. ... COMPARING ALL FIELDS
Deletes adjacent duplicate entries from the internal table itab.
If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries
are deleted.
Two lines are regarded as duplicates if their keys are identical.
The Return Code is set as follows:
... COMPARING f1 f2 ...
Two lines of the internal table itab are regarded as duplicates
if they have identical contents in the fields f1, f2, ...
... COMPARING ALL FIELDS
Two lines of the internal table are regarded as duplicates if all of their field contents are identical.
Performance:
Deleting Table Lines
Deleting Table Lines Using the Index