
By default, all values in a field are used in the calculation during aggregation. However, you can also generate intermediate results. When you do this, you group together data records containing the values for an intermediate result and display the intermediate result in a separate results row.
To generate intermediate results, you have to make certain settings:
To specify which field contains the values that you want to use to calculate the intermediate results, you create an aggregation condition for the relevant field. The overall result is displayed in the results row.
To specify which data records are to be included in an intermediate result, you group together the data records: You sort the ALV output by the field that contains the criterion for the intermediate result.
To generate the intermediate results, you use the field that contains the criterion to calculate the intermediate results.
To display the intermediate results, you switch on the display for the intermediate results.
If internediate results need more than one row, for example, because they are displayed for different currencies, and you have defined the table to be displayed hierarchically then the intermediate results cannot be displayed.
With intermediate results, you can:
Generate intermediate results
Display intermediate results
Specifying Levels for Drilling Down Intermediate Results
Set the position of the results rows (see Settings for Aggregation )
Disallow generation of intermediate results
Prerequisites
You have created an aggregation condition for at least one field that can be aggregated.
The field with the criterion for intermediate results cannot be aggregated and has an alphanumeric data type.
Generating Intermediate Results
To generate intermediate results in a field that already has an aggregation condition, you generate a sort condition for the field of a column (another column) (see Sorting ).
In this sort condition, you specify whether intermediate results are to be generated. To do this, you use the methods of class CL_SALV_WD_SORT_RULE.
Methods for generating intermediate results
|
Function |
Method |
|
Generate intermediate results |
SET_GROUP_AGGREGATION |
|
Check whether intermediate results are displayed |
GET_GROUP_AGGREGATION |
Displaying Intermediate Results
Once you have made all settings, to generate intermediate results you have to activate the display of these intermediate results. To do this, you use the methods of interface class IF_SALV_WD_FIELD_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).
Methods for displaying intermediate results
|
Function |
Method |
|
Display intermediate results |
SET_GROUP_AGGR_DISPLAYED |
|
Check whether intermediate results are displayed |
GET_GROUP_AGGR_DISPLAYED |
Specifying Levels for Drilling Down Intermediate Results
If you have defined intermediate results for multiple alphanumeric fields, this results in multiple levels of subtotals: The intermediate results are displayed hierarchically and are marked with a specific number of points according to their levels. The user can use these points to show and hide the entries for each of the intermediate results. In your application, you can show or hide entries for one or more subtotal levels.
You can also collapse to intermediate results: In doing this, you hide all data records and any corresponding lower subtotal levels. Only the results rows of the highest subtotal level and the results row with the overall result remain visible.
For these functions, you use the methods of interface class IF_SALV_WD_FIELD_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).
Methods for levels in drilldown of subtotals
|
Function |
Method |
|
Specify highest subtotal level displayed |
SET_EXPAND_LEVEL |
|
Get current subtotal level displayed |
GET_EXPAND_LEVEL |
|
Collapse to intermediate result |
SET_GROUP_AGGR_COLLAPSED |
|
Check whether data is collapsed to intermediate results |
GET_GROUP_AGGR_COLLAPSED |
Disallow generation of intermediate results
By default, intermediate results are automatically displayed in the ALV output as soon as a calculation is made in at least one field. All sorted fields with alphanumeric data types are interpreted as possible criteria for intermediate results and are therefore provided with intermediate results.
You can disallow the generation of intermediate results for specific fields. This has the following effects:
If you generate intermediate results for this field in your application, these settings have no effect in the ALV output.
The user can later specify for which columns he or she wants to display intermediate results. If you disallow the generation of intermediate results for a field, the particular column is not displayed for the user.
To disallow the generation of intermediate results for a field, you use the methods of interface class IF_SALV_WD_SORT (implementing class CL_SALV_WD_FIELD).
Methods for disallowing intermediate results
|
Function |
Method |
|
Disallow generation of intermediate results |
SET_GROUP_AGGREGATION_ALLOWED |
|
Check whether generation of intermediate results is permitted |
IS_GROUP_AGGREGATION_ALLOWED |