Application Development 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: 

Issue regarding ALV_GRID_DISPLAY Incorrect Subtotal

Former Member
0 Kudos

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!

4 REPLIES 4

Former Member
0 Kudos

you know you need to sort in order to do subtotals?

Former Member
0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

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.