09-24-2010 8:59 AM
Hi Experts,
I have problem with ALV Grid Subtotal, it is not getting the sum of all the entries within the key.
I have two keys: KUNNR1(sold-to) and KUNNR2 (ship-to). My report should show the total amount of NETWR of KUNNR1 and a subtotal amount of KUNNR2.
Sample:
KUNNR1 KUNNR2 VBELN FKDAT FKIMG MEINS NETWR
1234 112233 1 02022010 2 PC 40
1234 112233 1 02022010 1 PC 20
1234 112234 2 02022010 500 PC 23
So the subtotal of KUNNR2 should be:
For 112233, Subtotal NETWR = 60
And for 112234, Subtotal NETWR = 23
And the Total of KUNNR1 should be: 83
But my reports shows:
For 112233, Subtotal NETWR = 40
Subtotal NETWR = 20
And for 112234, Subtotal NETWR = 23
For 112234, Total: 60
23
Why is it so?
Thanks a lot!
09-24-2010 9:06 AM
09-24-2010 9:09 AM
Hi, Yes I already did the standard ALV sorting rituals:
CLEAR gs_sort.
gs_sort-spos = '01'.
gs_sort-group = 'UL'.
gs_sort-fieldname = 'KUNNR1'.
gs_sort-tabname = 'IT_MAIN'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
CLEAR gs_sort.
gs_sort-spos = '02'.
gs_sort-fieldname = 'KUNNR2'.
gs_sort-tabname = 'IT_MAIN'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
Also the in the fieldcat when its 'NETWR', we change the do_sum to 'X'.
It is displaying subtotals but it is still not adding up the same KUNNR1 or KUNNR2 keys.
09-24-2010 9:20 AM
i dont really understand why you coded this since the ALV can handle this tuff itself by maintaining the layout properly.
I suspect it will work once you go this way.
09-24-2010 9:48 AM
Thanks for your help...I have solved it by adding the WAERS (currency field in the ALV View). This allows the correct values to be subtotalled.