Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

REG: ALV display using CL _ SALV _ TABLE : (Aggregation

Former Member
0 Likes
1,828

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

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
1,299

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

Read only

0 Likes
1,299

Hi ,

We can sort and add based on date but how can I get the sum for the month.

Regards,

Vivek

Read only

0 Likes
1,299

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

Read only

0 Likes
1,299

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.

Read only

0 Likes
1,299

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