Ansicht
Dokumentation
ABENFOR_IN_GROUP - FOR IN GROUP
PERFORM Short Reference PERFORM Short ReferenceThis documentation is copyright by SAP AG.
FOR ... IN GROUP
... FOR ${ wa$|<fs> IN GROUP group $[INDEX INTO idx$] $[WHERE ( log_exp )$] $}
$| ${ GROUPS OF
wa$|<fs> IN GROUP group $[INDEX INTO idx$] $[WHERE ( log_exp )$]
GROUP BY group_key
$[ASCENDING$|DESCENDING $[AS TEXT$]$]
$[WITHOUT MEMBERS$] $} $[let_exp$] ...
Addition:
Effect
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.
Note
As in LOOP AT GROUP, access to the groups is optimized internally.
Example
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.
Addition
... INDEX INTO idx
Effect
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.
General Data in Customer Master BAL Application Log Documentation
This documentation is copyright by SAP AG.
Length: 4654 Date: 20240419 Time: 031823 sap01-206 ( 65 ms )