Get Example source ABAP code based on a different SAP table
• IN GROUP FOR
FOR ... IN GROUP>
ABAP_SYNTAX ... FOR ${ wa$|<(><)> IN GROUP group $[ • INTO idx$] $[ WHERE ( log_exp )>$] $} $| ${ GROUPS OF wa$|<(><)> IN GROUP group $[ • INTO idx$] $[ WHERE ( log_exp )>$] GROUP BY group_key> $[ASCENDING$|DESCENDING $[AS TEXT$]$] $[WITHOUT MEMBERS$] $} $[let_exp>$] ...>
ABAP Addition ... • INTO idx>
What does it do? These variants of an iteration expression> for table iterations> using FOR>> evaluate a line group group> sequentially like a member loop> LOOP AT GROUP>>. These FOR> expressions can only be specified in those places in which a group group> can be accessed, that is:
in a constructor expression after an expression FOR GROUPS ... OF>>,
in a LOOP> with the addition GROUP BY>>. where in both cases
the internal table must be specified directly and not specified as the result of an expression or a function,
the addition WITHOUT MEMBERS> must not be specified. group> is used to specify the group to be evaluated using the data object or field symbol to which the group is bound.
In the variant FOR ... IN GROUP> without GROUPS OF>, the expression evaluates the members of the current group in the same way as the variant FOR ... IN itab>> evaluates the lines of the internal table itab>. The result is the lines of the group.
In the variant FOR GROUPS OF ... IN GROUP>, the expression evaluates the members of the current group in the same way as the variant FOR GROUPS ... OF>>. The current group is grouped again and the result is either representatives or group keys of the subgroups. The condition WHERE ( log_exp )>> can be used to restrict the lines of the group to be evaluated. Conditions other than this static WHERE> condition cannot be specified.
Latest notes: As in LOOP AT GROUP>>, access to the groups is optimized internally. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Display of a list of the total occupied seats for each airline. A LOOP> with the addition GROUP BY>> evaluates its groups in a table reduction using FOR flight IN GROUP < carrier>>. Here, the total for each group is calculated for the column seatsocc>. ABEXA 01036 ABAP_EXAMPLE_END
ABAP Addition
What does it do? For each read line of the associated FOR> expression, this addition sets the helper variable idx> to the value to which the system field sy-tabix> would be set in a corresponding LOOP AT GROUP>> loop. The same applies to the local data object idx> as in the variant FOR ... IN itab>>.