2009 Feb 18 5:38 PM
Hi all,
Our requirement is to show the sum of amount for line items specific to date and then sum for all the
items for the month.
We are able to get the sum based on date using SORT an dAGGREGATION functions.
But how can we get the sum for each month.
REgards,
Vivek
Edited by: vivek pandey on Feb 18, 2009 11:09 PM
Hi all,
Our requirement is to show the sum of amount for line items specific to date and then sum for all the
items for the month.
We are able to get the sum based on date using SORT an dAGGREGATION functions.
But how can we get the sum for each month.
REgards,
Vivek
Edited by: vivek pandey on Feb 18, 2009 11:09 PM
2009 Feb 18 5:42 PM
You need to use the object reference of the CL_SALV_AGGREGATIONS to get the aggregation.
* For total on Amount
DATA: lo_agg TYPE REF TO cl_salv_aggregations.
lo_agg = lo_salv->get_aggregations( ).
TRY.
lo_agg->add_aggregation(
columnname = 'AMOUNT'
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.
* subtotal on date
DATA: lo_sorts TYPE REF TO cl_salv_sorts.
lo_sorts = lo_salv->get_sorts( ).
lo_sorts->clear( ).
TRY.
lo_sorts->add_sort(
EXPORTING
columnname = 'DATE'
position = 1
subtotal = 'X'
).
CATCH cx_salv_not_found. "#EC NO_HANDLER
CATCH cx_salv_existing. "#EC NO_HANDLER
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
Regards,
Naimesh Patel
2009 Feb 18 5:43 PM
Hi ,
We can sort and add based on date but how can I get the sum for the month.
Regards,
Vivek
2009 Feb 18 6:58 PM
You need to pass the column on which you want to have a sum in the ADD_AGGREGATION method in the above code snippet.
Regards,
Naimesh Patel
2009 Feb 28 1:31 PM
Hi naimesh,
i too have a got same pblmas this.
If i try as u said, i am getting the total value for the complete list.
but what is required is for a particular month(not for the entire month column).
how can we do that.
2016 Jan 20 7:34 AM
Hi Naimesh,
What if we want to display subtotals at the end of ALV report?
Due to code provided by you I am not getting subtotals at the end.
Thanks,
Onkar