2012 Sep 04 3:42 PM
Hi,
I use ALV-OO and sum some value fields. The total line is set before.
Now i set a field as subtotal. This works OK.
Now my question: is it possible to get all subtotal-lines allso before the list?
Thanks,
Regards, Dieter.
2012 Sep 04 5:26 PM
Hi Dieter,
Yes, its possible.
Firstly, you need to set the 'KEY on the field based on which you want to make the sub total.
example: I have 5 different quantities for the same material and I want to 'sub total' the quantities based on that material.
So if My list has to show sub totals for every different material.
So in my above example I set the KEY = 'X' in field catalog for MATNR.
Secondly, now I pass do_sum = 'X' in field catalog for the field on which I want to make the SUM (in my example its quantity).
Now third point is to sort on Key field passing the below parameters as example.
data: dt_sort TYPE lvc_t_sort,
ds_sort LIKE LINE OF dt_update_sort,
ds_sort-fieldname = 'MATNR'.
ds_sort-spos = 1.
ds_sort-up = 'X'.
ds_sort-subtot = 'X'.
APPEND ds_sort TO dt_sort.
And pass this dt_sort table in SET_TABLE_FOR_FIRST_DISPLAY for the changing parameter it_sort.
regards,
Ashwin
2012 Sep 04 6:27 PM
Hi Dieter,
You cannot get all subtotal lines before the detail item list. You can have the sub-totals (aggregations) before the listing their corresponding line item details using method SET_AGGREGATION_BEFORE_ITEMS of class CL_SALV_AGGREGATIONS. Before calling this method, call GET_AGGREATIONS from CL_SALV_TABLE.
Regards, Vinod
P.S: Hope you are using ALV - OM using SALV class (SAP Library - SAP List Viewer (ALV))
Message was edited by: Vinod Kumar
2012 Sep 06 11:49 AM
Hi Vinod,
thanks for your answer.
I use CL_GUI_ALV_GRID, but there is also a field in layout, called: TOTALS_BEF.
But this is not where i'm looking for.
But i find a little trick: i set in fieldcat for the summend field QFIELDNAME with this Fieldname
where i need subtotal. I know thats not really correct, but i don't need the real QFIELDNAME,
because the values are all in hours.
Regards, Dieter