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: 

subtotal in alv report based on the particular field value

Former Member
0 Kudos

Hi,

As per my requirement, i need to do subtotal of quntity field based on the material number field value in alv report.

Ex: if material number falls 1 to 10 then i need to be calculate and display subtotal qty amount with text " total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with text "total of the mat2". similarily i need to display the details.

<removed_by_moderator>

Regards

Nagendra

1 ACCEPTED SOLUTION

Former Member

Hi,

Ex: if material number falls 1 to 10 then i need to be calculate and display subtotal qty amount with text " total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with text "total of the mat2". similarily i need to display the details.

What you can do is in your output table, you will have to create an auxilary field, lets call it as material group (groupid). Now you can do a subtotal on the material group. However the logic to determine what materials belong to which group should be coded. I guess you might be having some logic for that.

So lets say that material 1 to 10 as G1 ( group 1 ) and material 11 to 20 as G2 ( group 2 )

The output of the internal table would be

Groupid matnr ...

1 1

1 2

1 3.....and so on

2 11

2 12

2 13....upto 20.

Now in the fieldcatalog assign an 'X' to the 'dosum' parameter to the field Groupid

In the sort info do the following :

gs_sort-fieldname = 'GROUPID'.

gs_sort-spos = 1.

gs_sort-up = 'X'.

gs_sort-subtot = 'X'. ***CRUCIAL STATEMENT****

append gs_sort to gt_sort.

Now pass all this data to the alv grid function. And you are done.

regards,

Advait

2 REPLIES 2

Former Member

Hi,

Ex: if material number falls 1 to 10 then i need to be calculate and display subtotal qty amount with text " total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with text "total of the mat2". similarily i need to display the details.

What you can do is in your output table, you will have to create an auxilary field, lets call it as material group (groupid). Now you can do a subtotal on the material group. However the logic to determine what materials belong to which group should be coded. I guess you might be having some logic for that.

So lets say that material 1 to 10 as G1 ( group 1 ) and material 11 to 20 as G2 ( group 2 )

The output of the internal table would be

Groupid matnr ...

1 1

1 2

1 3.....and so on

2 11

2 12

2 13....upto 20.

Now in the fieldcatalog assign an 'X' to the 'dosum' parameter to the field Groupid

In the sort info do the following :

gs_sort-fieldname = 'GROUPID'.

gs_sort-spos = 1.

gs_sort-up = 'X'.

gs_sort-subtot = 'X'. ***CRUCIAL STATEMENT****

append gs_sort to gt_sort.

Now pass all this data to the alv grid function. And you are done.

regards,

Advait

Former Member
0 Kudos

hi,

I need to display the subtotal text for each group as " Total of the mat1" in alv report and i do not need any grand total at last and similary i dont want subtotal for other than above group.