Making Settings for Aggregation
You are able to make various settings for the calculation of columns. The following types of calculation are available:
Calculation Types |
Total Adds all of the column values |
Minimum Gets smallest column value |
Maximum Gets largest column value |
Intersection Gets the mathematical average of all column values |
ALV Tool |
||||
Simple, two-dimensional table |
Yes |
Yes |
Yes |
Yes |
Hierarchical-sequential list |
Yes |
No |
No |
No |
Tree structure |
Yes |
Yes |
Yes |
Yes |
You are able to create a maximum of one calculation for every column. The result of the calculation is then displayed in a separate Results Row.
The settings for calculations (aggregation settings) for a column are represented by an object of type CL_SALV_AGGREGATION. The total of all the aggregation objects is represented by an object of type CL_SALV_AGGREGATIONS.

In addition to the calculation types listed above, you are also able to determine the total data records (see also Columns with Special Technical Meaning, the section on Counter Column to Determine Number of Rows). The result is displayed in the results row. The row count, however, is not represented by an aggregation object.
You can make the following settings for aggregations:
● Getting Aggregation Object
● Creating and Deleting Aggregation Object
● Specifying the Type of Aggregation
● Specifying the Position of the Results Row
● Allow and Forbid Aggregation
● The following is valid for all of these functions:
Display Type ALV Tool |
Classic ABAP List |
Full screen |
In the Container |
Simple, two-dimensional table |
Yes |
Yes |
Yes |
Hierarchical-sequential list |
Yes |
|
|
Tree structure |
|
Yes |
Yes |
The GET_AGGREGATIONS method, which returns all aggregation objects of the ALV output (class CL_SALV_AGGREGATIONS), exists in every main ALV class. Using this object with the methods GET or GET_AGGREGATION, you get the aggregation object for the desired column.
Methods
Function |
Class |
Method |
Get AGGREGATIONS object |
CL_SALV_TABLE CL_SALV_HIERSEQ_TABLE CL_SALV_TREE |
GET_AGGREGATIONS |
Get AGGREGATIONS object for a hierarchy level |
CL_SALV_HIERSEQ_LEVEL |
GET_AGGREGATIONS |
Get all aggregation objects |
CL_SALV_AGGREGATIONS |
GET |
Get a specific aggregation object |
GET_AGGREGATION |
|
Check whether a column will be calculated (has an aggregation object) |
IS_AGGREGATION_ |
You are able to create a maximum of one aggregation object for a column You are able to delete aggregation objects either individually or all at once. You can also delete the settings for an aggregation object without deleting the aggregation object itself.

By default, columns with the numeric text (NUMC or n) data type cannot be aggregated. In these types of columns, you can only create an aggregation object if you expressly permit this.
You can also only forbid aggregation for columns that can be aggregated.
Methods
Function |
Class |
Method |
Create an aggregation object |
CL_SALV_AGGREGATIONS |
ADD_AGGREGATION |
Delete individual aggregation object |
REMOVE_AGGREGATION |
|
Delete all aggregation objects |
CLEAR |
|
Delete aggregation settings for an aggregation object |
CL_SALV_AGGREGATION |
CLEAR |

If you assign a new data table with a new structure to your ALV output, all aggregation objects will be deleted automatically.
Specify which type of calculation you want to perform for an aggregation object (beside the column name): You specify the type of the aggregation object.
Methods
Function |
Class |
Method |
Specifying Aggregation Types |
CL_SALV_AGGREGATIONS |
ADD_AGGREGATION (Parameter AGGREGATION) |
CL_SALV_AGGREGATION |
SET |
|
Get aggregation type |
CL_SALV_AGGREGATION |
GET |
By default, all columns with a numeric data type can be aggregated with the exception of columns of data type NUMC.
You are able to set whether a column can be aggregated as follows:
● In columns that actually have a suitable data type, forbid aggregation
● In columns of data type numeric text, you expressly allow aggregation
Methods
Function |
Class |
Method |
Forbid aggregation in suitable columns |
CL_SALV_AGGREGATIONS |
SET_AGGREGATION_ |
Check whether aggregation is allowed in suitable columns |
IS_AGGREGATION_ |
|
Allow aggregation in numeric text |
SET_NUMERICAL_ |
|
Check whether aggregation is allowed in numeric text |
IS_NUMERICAL_ |