Making Aggregation Settings

Use

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.

Key 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

Full Screen

Yes

In the Container

Yes

Hierarchical-sequential list

Classic ABAP List

Partial:

Only the sum function is supported (see above)

Tree structure

Full Screen

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

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

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

Specifying Aggregation Types

CL_SALV_AGGREGATIONS

ADD_AGGREGATION (Parameter AGGREGATION)

CL_SALV_AGGREGATION

SET

Get aggregation type

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