ABAP Keyword Documentation →  ABAP - Reference →  Program Flow Logic →  Iteration Expressions → 

REDUCE - Reduction Operator


... REDUCE type(
      INIT {x1 = rhs1}|{<x1> = wrexpr1}|{x1|<x1> TYPE dtype1}
           {x2 = rhs2}|{<x2> = wrexpr2}|{x2|<x2> TYPE dtype2}
      FOR for_exp1
      FOR for_exp2
      NEXT ...
           {x1 = rhs1}|{<x1> = wrexpr1}
           {x2 = rhs2}|{<x2> = wrexpr2}
           ... ) ...


A constructor expression with the reduction operator REDUCE creates a result of a data type specified using type from one or more iteration expressions. The following can be specified for type:

The parameters and arguments of the constructor expression must be specified as follows:

At least one variable or one field symbol must be specified. The variables or field symbols declared after INIT can only be used after NEXT. In particular, they cannot be used to declare other variables or field symbols.
The assignments can be specified in any order and they are evaluated from to left to right. Each non-structured variable or field symbol declared after INTIT can be specified precisely once as the left side. In the case of structured variables or field symbols, either the full structure can be specified as the left side or each component once. Alongside the data objects of the program, all local variables and field symbols of the expression visible after the last FOR expression can be used in the operand positions on the right side:
Any auxiliary fields declared after INTIT can only be specified in reader positions on the right side.

After the full evaluation, the content of the first variable x1 or the memory area pointed to by the first field symbol <x1> is assigned to the temporary result of the expression of type type in accordance with the assignment rules.