Show TOC

Making Aggregation Settings Locate this document in the navigation structure

Use

You can make various settings for the calculation of columns. The following types of calculation are available:

Calculation types

Total

Sums up all values of the column

Minimum

Calculates the smallest value of the column

Maximum

Calculates the largest value of the column

Average

Calculates the mathematical average of all values of the column

ALV Tool

Simple, two-dimensional table

Yes

Yes

Yes

Yes

Hierarchical-sequential list

Yes

No

No

No

Tree structure

Yes

Yes

Yes

Yes

You can create one calculation only for every column. The result of the calculation is displayed in a separate Results Row.

The calculation settings (aggregation settings) of a column are represented by an object of type CL_SALV_AGGREGATION. The total of all aggregation objects is represented by an object of type CL_SALV_AGGREGATIONS.

Note

In addition to the calculation types listed above, you can also calculate the total number of data records (see also Columns with Special Technical Meaning, the section on Counter Column to Calculate Number of Rows). The result is displayed in the results row. The row count, however, is not represented by an aggregation object.

Features

You can make the following settings for aggregations:

The following is valid for all of these functions:

ALV Tool

Display Type

Function Available

Simple, two-dimensional table

Classic ABAP List

Yes

Fullscreen

Yes

In the Container

Yes

Hierarchical-sequential list

Classic ABAP List

Partial:

Only the sum function is supported (see above)

Tree structure

Fullscreen

Yes

In the Container

Yes

Getting Aggregation Object

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 selected column.

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 aggregated (has an aggregation object)

IS_AGGREGATION_ DEFINED

Creating and Deleting Aggregation Object

You can create a maximum of one aggregation object for a column You can 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.

Note

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.

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

Note

If you assign a new data table with a new structure to your ALV output, all aggregation objects will be deleted automatically.

Specifying the Type of Aggregation

In addition to the column name, specify what type of calculation you want to use for the aggregation object. You define the type of aggregation object.

Function

Class

Method

Specify aggregation type

CL_SALV_AGGREGATIONS

ADD_AGGREGATION (Parameter AGGREGATION)

CL_SALV_AGGREGATION

SET

Get aggregation type

CL_SALV_AGGREGATION

GET

Allow and Forbid Aggregation

By default, all columns with a numeric data type can be aggregated with the exception of columns of data type NUMC.

You can 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

Function

Class

Method

Forbid aggregation in suitable columns

CL_SALV_AGGREGATIONS

SET_AGGREGATION_ ALLOWED

Check whether aggregation is allowed in suitable columns

IS_AGGREGATION_ ALLOWED

Allow aggregation in numeric text

SET_NUMERICAL_ AGGREGATION

Check whether aggregation is allowed in numeric text

IS_NUMERICAL_ AGGREGATION_ON