Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

subtotal in alv report based on the particular field value

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

Tags:
replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question