SAP LOOP GROUP BY PACKAGES ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Grouping with LOOP in Packages
This example demonstrates a construction of the group key that does not depend on the line content.

ABAP_SOURCE_CODE
DEMO CL_DEMO_LOOP_GRP_BY_PACKAGES

ABAP_DESCRIPTION
Grouping of an internal table text with representative binding . The group key of the group loop is constructed as a value of the type i, which is calculated from the line index of the current line in sy-tabix. This creates groups of lines with the same definable size.
In the group loop, the lines of each group are placed in an internal table group in a member loop using the value operator with the addition BASE. This table is also displayed. Here, the group is addressed using the work area wa of the original output behavior of the LOOP due to the representative binding.
group could also be filled by the evaluation of a table comprehension using FOR ... IN GROUP, instead of in a member loop LOOP AT GROUP: group = VALUE #( FOR < wa> IN GROUP wa ( < wa> ) ).
The executable example for grouping with FOR demonstrates how the entire group loop can be implemented using expressions.