cancel
Showing results for 
Search instead for 
Did you mean: 

Totals in ALV WD4A

Former Member
0 Kudos

I am searching for a method /methods in order to show totals in an ALV in WD4A.

The individual lines contain prices and I would like to show the client the total of the individual lines (dynamically).

Is there a way to accomplish this?

Regards,

Henry

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hendry,

You can use calculations for totaling field values. Add the below code to the WDDOINIT() method of the view. It will create aggregation rule that will display the total at the end of the ALV.

* declare field and field settings object
data:
  lr_field_settings type ref to if_salv_wd_field_settings.
data:
  lr_field          type ref to cl_salv_wd_field,
  lr_aggr_rule      type ref to cl_salv_wd_aggr_rule.

* get field and create aggregation rule of type total
lr_field = lr_field_settings->get_field( 'FIELDNAME' ).
lr_field->if_salv_wd_aggr~create_aggr_rule( ).
lr_aggr_rule = lr_field->if_salv_wd_aggr~get_aggr_rule(  ).
lr_aggr_rule->set_aggregation_type( if_salv_wd_c_aggregation=>aggrtype_total ).

Hope it helps

Regards

Rakesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Works just fine.

Thanks