‎2010 Aug 23 11:19 AM
Hi,
I am using CL_SALV_TABLE. I want the function aggregate (totals) to be enabled.
Though the following is done, the aggreagte totals does not get enabled at the top of the ALV.
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
I even tried this
call METHOD gr_functions->SET_AGGREGATION_TOTAL
exporting
VALUE = 'X'.
Still no results.
Can anyone please direct as to how to get the aggregation total enabled in SALV.
Regards,
Madhura Lobo
‎2010 Aug 23 11:33 AM
Hi,
Go to SE 38...Put salv* and press f4..u will get list of sample salv program....
For your info:
http://www.se80.co.uk/sapreports/s/salv/salv_test_table_refresh.htm
http://www.se80.co.uk/sapreports/s/salv/salv_demo_tree_metadata.htm
May it helps you.
Regards,
DS.
‎2010 Aug 23 11:47 AM
METHOD set_aggregations.
DATA: lf_aggrs TYPE REF TO cl_salv_aggregations.
lf_aggrs = pc_alv->get_aggregations( ).
TRY.
CALL METHOD lf_aggrs->add_aggregation
EXPORTING
columnname = 'NETPR'
aggregation = if_salv_c_aggregation=>total.
CALL METHOD lf_aggrs->add_aggregation
EXPORTING
columnname = 'LFIMG'
aggregation = if_salv_c_aggregation=>total.
CATCH cx_salv_data_error . "#EC NO_HANDLER
CATCH cx_salv_not_found . "#EC NO_HANDLER
CATCH cx_salv_existing . "#EC NO_HANDLER
ENDTRY.
ENDMETHOD. "set_aggregations
Edited by: Keshav.T on Aug 23, 2010 4:18 PM
‎2010 Aug 23 12:08 PM
Thanks for the reply.
But this does not work. Have already tried it.
‎2010 Aug 23 1:00 PM
Are there columns in your field catalog that can be aggregated at all, i.e. amount fields? Otherwise the aggregate functions will not show up despite SET_ALL = true.
Thomas
‎2010 Aug 23 1:27 PM
Using the code provided by Keshav.T, and if you have fields to aggregate the totals should show up at the very bottom of the grid.
To have the totals show at the top, add this line:
lf_aggrs->set_aggregation_before_items( 'X' ).