cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Aggregation line with custom calculation

Former Member
0 Kudos

The ALV has a very nice function for aggregating results as minimum, maximum, total, average and no aggragetion. This is achieved with:


DATA : lo_field TYPE REF TO cl_salv_wd_field.
  lo_field =  lo_alv_config_table->if_salv_wd_field_settings~get_field( 'CONNID' ) .
 " choose one from below
  lo_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =  if_salv_wd_c_aggregation=>aggrtype_minimum ).
  lo_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =  if_salv_wd_c_aggregation=>aggrtype_maximum ).
  lo_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =  if_salv_wd_c_aggregation=>aggrtype_total ).  
  lo_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =  if_salv_wd_c_aggregation=>aggrtype_average ).
  lo_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type =  if_salv_wd_c_aggregation=>aggrtype_none ).

This will display the nice yellow line below the ALV with either minimum, maximum, total, etc.

BUT, what can you do when you need an aggregation type which is not part of the standard, but is a custom one? I wouldn't need something very complex, I would need a weighed average aggregation function. Any ideas how this can be accomplished?

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

It would be nice to have an answer for thit topic. I am also intrested in custom aggregaion function in ALV.

I would like to modify the "total" function to CEIL the value on each sumarization row. Do you have any idea? Thanks

Former Member
0 Kudos

Unfortunately I did not find a custom function for the aggregation line. I tried to use a second ALV that was displayed as a simple line - no header, no status bar, no functions - but this solution has the problem that the ALV colums resize either automatically or manually by user, and if you resize the first ALV, the second ALV containing the aggregation line does not resize, and building a synchronization between the two ALV is rather difficult and not worth the effort.

The customer however accepted  a solution in which I added a regular line at the end of the list in which I put in the custom calculation. I colored the line using cell variants, and this was the only line that was displayed differently. I disabled scrolling so the entire ALV is shown at once, this way a user did not have to scroll down in the ALV to see the aggregation line. Finally I disabled the selection for the aggregation line.Whenever it was selected, I reinitialiezed the lead selection on the ALV. .