SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation →
ABAP - Reference →
Program Flow Logic →
Iteration Expressions →
FOR - Iteration Expressions
Syntax
... REDUCE|
NEW|
VALUE type( ... FOR ... UNTIL|WHILE ...|
... IN ... ... ) ...
Effect
The language element FOR introduces an
iteration expression as a subexpression in
constructor expressions
with the reduction operator REDUCE
and in the variants of the instance operator
NEW and the value operator VALUE for creating internal tables.
There are two main variants of iteration expressions:
- Iteration expressions with UNTIL
or WHILE for conditional
iterations. These expressions are used to create (iteratively) the results of any data types using
REDUCE or to create rows of internal tables using NEW or VALUE. The iteration steps can be defined as required.
Notes
- Any FOR variants can be combined in a single constructor expression, where they produce nested iterations.
- The reduction operator REDUCE
must contain at least one iteration expression. The variants of the instance operator
NEW and the value operator
VALUE for creating internal tables can contain iteration expressions.
- The conditional iterations using UNTIL
or WHILE provide an expression-oriented
alternative to the loop statements DO
and WHILE. The same applies to the
table iterations using IN and
the statement LOOP.
The direct use of operand positions by the expression-oriented variants helps to avoid using auxiliary
variables. Furthermore, they also enable certain tasks, such as creating values iteratively, to be expressed more concisely and more elegantly.
Continue
FOR - Conditional Iteration
Examples of Iteration Expressions