By default, all values in a field are used in the calculation during aggregation. However, you are also able to generate intermediate results. You group the data records that contain the values for an intermediate result and display each intermediate result in its own result row.
To generate intermediate results, you have to provide certain information:
● To specify in which field the values from which the intermediate results are calculated are located, generate an aggregation condition for the desired field. The overall result is displayed in the result row.
● To specify which data records are contained in an intermediate result, group the data records: You sort the ALV output by the field that includes the criterion for the intermediate result.
● To then generate the intermediate results, calculate the intermediate results using the field with the criterion.
● To then display the intermediate results, switch on the display of intermediate results.
The most common way of generating intermediate results is to use subtotals. That is way you often find this term in place of intermediate results for all aggregation types. Nevertheless you can of course generate intermediate results (or “subtotals”) for all other aggregation types.
You are able to make the following settings for intermediate results:
● Generate intermediate results
● Display intermediate results
● Setting levels for drilling down intermediate results
● Set the position of the result rows (see Settings for Aggregation)
● Forbid the generation of intermediate results
● You have generated an aggregation object for at least one aggregatable field.
● The field with the criterion for intermediate results is not an aggregatable field, and therefore has an alphanumeric data type.
To generate intermediate results in a field that already has an aggregation condition, generate a sort condition for the field of a column (another column) (see Sorting).
In this sort condition, define whether intermediate results are to be generated. To do this, use the methods of the 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 |
Once you have made all settings, to generate intermediate results you have to switch on the display of these intermediate results. You use the methods of the interface class IF_SALV_WD_FIELD_SETTINGS for this (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 |
If you have defined intermediate results for several alphanumeric fields, there are multiple levels of subtotals: The intermediate results are subdivided hierarchically and are marked with a different number of points according to their level. The user can use these points to show and hide the entries for the individual intermediate results. You can use your application to show or hide the entries of one or more complete subtotal levels.
You can also aggregate intermediate results: You hide all data records and any existing lower subtotal levels. Only the results rows of the highest subtotal level and the results row with the overall result remains visible.
You use the methods of the interface class IF_SALV_WD_FIELD_SETTINGS for this (implementing class CL_SALV_WD_CONFIG_TABLE).
Methods for Steps for Expanding Subtotals
Function |
Method |
Set highest subtotal level to be displayed |
SET_EXPAND_LEVEL |
Get current subtotal level being displayed |
GET_EXPAND_LEVEL |
Aggregate intemediate result |
SET_GROUP_AGGR_COLLAPSED |
Check whether intermediate results are aggregated |
GET_GROUP_AGGR_COLLAPSED |
By default, intermediate results are automatically displayed in the ALV output as soon as a calculation is performed in at least one field: all sorted fields with alphanumeric data types are interpreted as a possible criterion for intermediate results and are thus given intermediate results.
You can forbid the generation of intermediate results for individual 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.
Afterwards, the user can determine for which columns he or she wants intermediate results. If you forbid the generation of intermediate results for a field, the particular column is not offered the to user.
To forbid the generation of intermediate results for a field, use the methods of the interface class IF_SALV_WD_SORT (implementing class CL_SALV_WD_FIELD).
Methods for Forbidding Intermediate Results
Function |
Method |
Forbid the generation of intermediate results |
SET_GROUP_AGGREGATION_ALLOWED |
Check whether generating intermediate results is permitted |
IS_GROUP_AGGREGATION_ALLOWED |