Get Example source ABAP code based on a different SAP table
• FOR ABAP_EXPRESSION
FOR>, Iteration Expressions
ABAP_SYNTAX ... REDUCE>$| NEW>$| VALUE> type( ... FOR ... UNTIL$|WHILE ...> $| ... IN ...> ...) ...>
What does it do? 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 iteratively create the results of any data types using REDUCE> or to create lines of internal tables using NEW> or VALUE>. The iteration steps can be defined as required.
Iteration expressions with IN>> for table iterations>. These expressions are used for table reductions> using REDUCE> or table comprehensions> using NEW> or VALUE>. The iteration steps here evaluate an existing internal table.
Latest notes:
Any FOR> variants can be used in any way in a constructor expression and 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 on the expression-oriented variants helps to avoid helper variables. Furthermore, they also enable certain tasks, such as creating values iteratively, to be expressed more concisely and more elegantly. NON_V5_HINTS ABAP_HINT_END