Ansicht
Dokumentation
ABENFOR_GROUPS_OF - FOR GROUPS OF
RFUMSV00 - Advance Return for Tax on Sales/Purchases rdisp/max_wprun_time - Maximum work process run timeThis documentation is copyright by SAP AG.
FOR GROUPS ... OF
... FOR GROUPS $[group$|group>$] OF wa$|<fs> IN itab
$[INDEX INTO idx$] $[cond$]
GROUP BY group_key
$[ASCENDING$|DESCENDING $[AS TEXT$]$]
$[WITHOUT MEMBERS$]
$[let_exp$] ...
Addition:
Effect
This variant of an iteration expression for table iterations with FOR evaluates an internal table itab in the same way as a LOOP with the addition GROUP BY in two phases:
- Grouping of all lines that meet the condition in cond by the group key specified in group_key. The same applies to group_key as in LOOP AT ...GROUP BY. In this phase, each line read is either written to the local work area wa or assigned to the local field symbol <fs> and can then be evaluated when the group key is constructed.
- Evaluation of the groups. Specifying group or group> (optional) results in the group key binding in which the current group key is written to the local data object group or assigned to the local field symbol group>. If group or group> is not specified, the representative binding applies, in which the first line of a group is written to the local work area wa or assigned to the local field symbol <fs>. In the group key binding, wa or <fs> are initial after the FOR expression.
itab is a functional operand position. The same applies to the additions ASCENDING, DESCENDING, and WITHOUT MEMBERS as in LOOP AT ... GROUP BY. In particular, WITHOUT MEMBERS can be specified only if a group key binding is defined after GROUPS by specifying group or group>.
Depending on the type of binding, the work area wa or group or the field symbol <fs> or group> after the FOR expression can either be used in further subexpressions or to construct the result of a table comprehension or table reduction. In particular, it can be specified in the expression FOR ... IN GROUP to evaluate the members of the current group.
Note
If a constructor expression contains a FOR expression with group key binding and the group key is to be used as the result of the constructor expression, a suitable data type or a data object with this type must exist for this expression explicitly. It is not possible to derive this type here using an inline declaration as in LOOP AT.
Example
Display of all values of the column carrid that occur in spfli. The result of the
table comprehension
is a single-column internal table that contains all group key values. The FOR loop works with a group key binding. Here, each group key is assigned to the local data object carrier.
Addition
... INDEX INTO idx
Effect
For each evaluated group, this addition sets the helper variable idx as follows:
- In the case of representative bindings, to the value that would be set by the addition INDEX INTO in evaluations using FOR ... IN itab for the representative line.
- In the case of group key bindings, the groups are counted from the value 1.
The same applies to the local data object idx as in the variant FOR ... IN itab.
idx cannot be addressed in group_key.
Example
Grouping and sorting of an internal table with random numbers by the numbers and sorts it. The differences between the group number in i and the random number demonstrate the deviation from the uniform distribution.
TXBHW - Original Tax Base Amount in Local Currency BAL Application Log Documentation
This documentation is copyright by SAP AG.
Length: 6575 Date: 20240329 Time: 130610 sap01-206 ( 103 ms )