SAP LOOP GROUP BY LEVELS ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Grouping with LOOP in Group Levels
This example demonstrates simple group level processing using GROUP BY.

ABAP_SOURCE_CODE
DEMO CL_DEMO_LOOP_GRP_BY_LEVELS

ABAP_DESCRIPTION
This example works in the same way as the executable example for group level processing. Here, the group key is constructed explicitly using the value of the column col1 and, unlike in group level processing, does not depend on the structure of the table and its sorting.
The statement SUM is replaced by a functional method that replaces the implicit behavior of the statement with an explicit and self-definable function.
group and sum could also be filled by the evaluation of a table comprehension or table reduction using FOR ... IN GROUP, instead of in a member loop LOOP AT GROUP: sum = REDUCE #( INIT s = VALUE line( )
FOR line IN GROUP < line>
NEXT s = sum( EXPORTING line = line
base = s ) ).
group = #( FOR < wa> IN GROUP < line> ( < wa> ) ).
The executable example for grouping with FOR demonstrates how the entire group loop can be implemented using expressions.