DELETE itab - itab_lines
To delete several lines at once, you have to specify at least one of the additions
WHERE. USING KEY
keyname is used to determine the the table key to which the additions refer.
If you specify more than one of the additions, those rows are deleted that result from the intersection of the individual additions.
... USING KEY keyname
USING KEY addition can be used to specify a table key in
keyname used to carry out the processing. The specified table key influences the order in which the table rows are accessed, and the evaluation of the remaining conditions.
If the primary table key is specified, the processing behaves in the same way as when no key is explicitly specified. If a secondary table key is specified, the order in which the rows are accessed is as follows:
Sorted key specified
The rows are processed by ascending row number in the secondary table index
Hash key specified
The rows are processed in the order in which they were inserted into the table.
Unlike the processing of a hash table when a primary key is used, a preceding sort using the
SORTstatement has no influence on the processing sequence when a secondary hash key is specified.
If a secondary table key is specified, any
WHEREcondition also specified must be optimizable. Otherwise a syntax error occurs or an exception is raised.
... [FROM idx1] [TO idx2]
These additions have the effect that only table rows from row number
or up to row number
idx2, are taken into account in the table index used.
FROM is specified, all rows of the table from row number
up to and including the last row are taken into account. If only
TO is specified,
all rows in the table from the first row up to row number
idx2 are taken into account.
If the addition
USING KEY is not used, or the
primary table key
is specified in
keyname, the additions
TO can only be used for
index tables. In this case, they refer to the row numbers of the
primary table index.
numerical expression positions of operand type
i. The following limitations apply:
If the value of
idx1is less than 0, it is set to 1 in the
LOOPstatement and causes a runtime error in every other statement. If the value of
idx1is greater than the total number of table rows, no processing takes place.
If the value of
idx2is less than 0, the
LOOPstatement is not carried out and in every other statement it leads to a runtime error. If the value of
idx2is greater than the number of table rows, it is set to the number of table rows.
If the value of
idx2is less than the value of
idx1, no processing takes place.
... WHERE log_exp
WHERE condition. All rows are processed for which the condition after
WHERE is met. You can specify
WHERE for all table categories.
You can specify a logical
WHERE in which the first operand of each operation is a
component of the internal table. You cannot specify a
The components of the internal table must be specified as individual operands and not as part of an
expression. You cannot use parenthesized character-like data objects to specify a component dynamically here. The remaining operands of a comparison are
general expression positions at which any
suitable inidividual operands or
expressions can be specified,
but no components of the internal table. All logical expressions are possible except
IS ASSIGNED, IS
SUPPLIED, and the obsolete
IS REQUESTED. The specified components can have any data type. The relevant
comparison rules apply to the evaluation.
- When standard tables
are accessed without a secondary key being specified, the access is not optimized. This means that all
rows of the internal table are tested for the logical expression of the
- When using a sorted key or a
hash key (that is, when accessing a
sorted table, a
hashed table, or a
secondary table key),
an attempt is made to optimize the access as described under
Optimization of the
WHERECondition. If the corresponding prerequisites are not met:
- the logical expression cannot be transformed to a key access
- the logical expression has the same result as the resulting key access
WHEREcondition cannot contain any duplicate or overlapping key specifications.
When using a
WHEREcondition, note that the comparison rules for incompatible data types apply when comparing incompatible data objects. Here, the data types involved determine which operand is converted. If the additions
WITH TABLE KEYand
WITH KEYof the statement
READare used, however, the content of the specified data objects is always converted to the data type of the columns before the comparison. This can produce varying results.
If possible, all operands of the logical expression should be in
compatible pairs, so enabling
WHEREcondition to be optimized.
If a selection table
is specified after
INas a logical expression, note that the expression at the initial table is always true and then all rows are edited.
... WHERE (cond_syntax)
WHERE condition. You can declare a character-type data object or
standard table with
character-type data type for
cond_syntax. This data object or standard table
is initial or contains the syntax of a logical expression (in accordance with the rules of the static
WHERE condition) when the statement is executed.
As in ABAP Editor, the syntax in
cond_syntax is not case-sensitive. When
you declare an internal table, you can distribute the syntax across multiple rows. If
is initial when the statement is executed, the logical expression is true. An invalid logical expression raises an exception of the class CX_SY_ITAB_DYN_LOOP.
The obsolete logical operators
=<) are not supported by
- Of the calculation expressions, only arithmetic expressions are currently supported. The string expressions and bit expressions are not supported. You cannot specify string functions or bit functions currently either.
For optimization reasons, the dynamic
WHEREcondition is not evaluated for empty tables. This means that an exception is not raised for empty internal tables if the logical expression contains an error.
Deletes all rows in an internal table from row 4. The result is the same as in the example for
APPEND ... SORTED BY. The column
is not required by the
SELECT statement but is filled by the program. For this reason, the associated syntax check warning is hidden by the appropriate
PARAMETERS: p_carrid TYPE sflight-carrid, p_connid TYPE sflight-connid. DATA: BEGIN OF seats, fldate TYPE sflight-fldate, seatsocc TYPE sflight-seatsocc, seatsmax TYPE sflight-seatsmax, seatsfree TYPE sflight-seatsocc, END OF seats. DATA seats_tab LIKE STANDARD TABLE OF seats. SELECT fldate seatsocc seatsmax FROM sflight INTO TABLE seats_tab WHERE carrid = p_carrid AND connid = p_connid ##too_many_itab_fields. LOOP AT seats_tab INTO seats. seats-seatsfree = seats-seatsmax - seats-seatsocc. MODIFY seats_tab INDEX sy-tabix FROM seats. ENDLOOP. SORT seats_tab BY seatsfree DESCENDING. DELETE seats_tab FROM 4.