ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Expressions and Functions for Internal Tables → FOR - Table Iterations
FOR ... IN itab
Other versions:
7.31 | 7.40 | 7.54
Syntax
... FOR wa|<fs> IN itab [INDEX INTO idx] [cond] [let_exp] ...
Addition
Effect
This variant of an iteration expression for
table iterations using
FOR
evaluates an internal table itab
sequentially, like a
row variant of a LOOP
. itab
is a
functional operand
position. cond1
,
cond2
, ... can be used to set conditions for the evaluation. For each
read row, the result is either assigned to a local work area wa1
, wa2
,
... or to a field symbol <fs1>
, <fs2>
,
... The work area or the field symbol is declared implicitly with the row type of the internal table
and bound locally to the FOR
expression as a subexpression of the full constructor
expression. The same applies to the namespace and visibility as to the auxiliary fields declared in
LET
expressions. After the FOR
expression, the work area or the field symbol can either be used in further subexpressions or to construct the result of a
table comprehension or table reduction.
Notes
- Instead of using directly specified internal tables
itab1
,itab2
, this variant ofFOR
expressions can also be created using mesh paths, whereFOR
expressions from both categories can be used together in the same constructor expression.
- Changes to the content of the internal table specified after
IN
within theFOR
expression can only be made using method calls. Deleting or replacing the table in full always produces a runtime error.
Addition
... INDEX INTO idx
Effect
For each row of the associated FOR
expression, this addition sets the auxiliary
variable idx
to the value to which the system field sy-tabix
would be set in a corresponding LOOP
.
The auxiliary variable idx
is declared implicitly with the type i
and bound locally to the FOR
expression as a subexpression of the full constructor
expression. The same applies to the namespace and visibility as to the auxiliary fields declared in LET
expressions.