SAP COND ITERATION REDUCE ABEXA



Get Example source ABAP code based on a different SAP table
  



Creating Values with FOR and REDUCE
This example demonstrates conditional iterations with the operator REDUCE.

ABAP_SOURCE_CODE
DEMO CL_DEMO_REDUCE_COND_ITERATION

ABAP_DESCRIPTION
This example demonstrates the following simple iterations, which can be used to construct elementary data objects and directly display them in a constructor expression using the reduction operator REDUCE:
The first expression constructs a value of the type i for which the total of the iteration variable n is calculated. n is numeric, which means that THEN does not have to be specified. Each iteration step increases the value of n by 1.
The second expression uses the same iteration as the first, but constructs a text string to which each iteration step appends the ch aracter representation of n.
Like the second expression, the third expression constructs a text string, but uses the addition THEN explicitly to decrement the iteration variable instead of incrementing it.
Finally, the fourth expression shows that the iteration variable does not have to be numeric. In this case, THEN must be specified explicitly with a suitable expression. Here, a text string is made longer until it has reached a specific size.