SAP LOOP GROUP BY AGGREGATES ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Grouping with LOOP for Aggregates
This example demonstrates a grouping with aggregates.

ABAP_SOURCE_CODE
DEMO CL_DEMO_LOOP_GRP_BY_AGGREGATES

ABAP_DESCRIPTION
In a group loop across an internal table numbers grouping is performed by the content of the column key and, for the groups, the usual SQL aggregates sum, maximum, minimum, and average are calculated for the second column num. The output is the group members and the associated aggregates. The example enables a maximum number of different key values and lines in the internal table to be entered. The values in the second column are random numbers between 1 and 100.
The example above demonstrates an implementation with a member loop. A further executable example shows how the member loop can be replaced by table comprehensions and table reductions while preserving the function. Another executable example demonstrates how the entire group loop can be implemented using expressions.