Show TOC

Function documentationMaking Settings for Aggregation Locate this document in the navigation structure

 

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

Calculation types

Total

Adds all values for the column

Minimum

Determines the smallest value for the column

Maximum

Determines the largest value for the column

Average

Determines 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 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.

Note Note

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.

End of the note.

Features

You can make the following settings for aggregations:

The following is valid for all of these functions:

Display type

ALV Tool

Classic ABAP List

Fullscreen

In the Container

Simple, two-dimensional table

Yes

Yes

Yes

Hierarchical-sequential list

Partial:

Only the sum function is supported (see above)

Tree Structure

Yes

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 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_ DEFINED

Creating and Deleting Aggregation Object

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.

Note 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.

End of the note.
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

Note Note

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

End of the note.
Specifying the Type of Aggregation

For an aggregation object, you specify - in addition to the column name - which type of calculation you wish to make with it: you set the type of aggregation object.

Methods

Function

Class

Method

Specify aggregation types

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 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_ 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