SAP LOOP GROUP BY COMPARISON ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Grouping with LOOP Using a Comparison
This example demonstrates the construction of the group key using comparison expressions.

ABAP_SOURCE_CODE
DEMO CL_DEMO_LOOP_GRP_BY_COMPARISON

ABAP_DESCRIPTION
Grouping of an internal table numbers with group key binding . The group key of the group loop is constructed as a value of the type string, which is calculated from the content of each table line using the conditional operator cond. This creates groups of lines whose content is either less than or equal to or greater than an entered value.
The group key that is bound to a field symbol < group> is produced in the group loop. In a member loop, the lines of each group are placed in an internal table members using the value operator with the addition BASE . This table is also displayed.
members could also be filled by evaluating a table comprehension using FOR ... IN GROUP, instead of in a member loop LOOP AT GROUP: members = VALUE #( FOR < member> IN GROUP < group> ( <(> <<)>member> ) ).
The executable example for grouping with FOR demonstrates how the entire group loop can be implemented using expressions.