Application Development and Automation 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: 
Read only

SUM Grouping

Former Member
0 Likes
893

Hi,

I have an internal table with fields to be summed up. I require that the sum be grouped by field taxcode first then by field matnr. And then at the end of the report, sum everything.

Any ideas on how to do this?

Thanks in advance.

Kenny

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
850

how are the values stored kenny?

regds,

kiran

7 REPLIES 7
Read only

Former Member
0 Likes
850

use control break events....

like

at end of <taxcode>

sum.

endat.

at end of <matnr>

sum.

endat.

at last.

sum.

endat.

at each above stage the value will get summed.

regds,

kiran

Read only

0 Likes
850

Hi Kiran,

I have tried AT THE END OF, ON CHANGE, and AT NEW but I cant seem to make it work.

Please help.

Kenny

Read only

Former Member
0 Likes
851

how are the values stored kenny?

regds,

kiran

Read only

0 Likes
850

Hi Kiran,

Both matnr and taxcode are fields of an internal table. I have a loop into a workarea for sum to work.

Thanks.

Kenny

Read only

0 Likes
850

what i mean to say is.

the control break events depends upon the order of the fields declare in the internal table.

can u please give the fields in the order of the internal table.

regds,

kiran

Read only

0 Likes
850

declare the itab in such a way that the first field is tax code and next field is matnr.

then sort itab by taxcode matnr.

loop at itab.

move: itab to wa .

at end of taxcode.

SUM.

endat .

write:/ wa , itab-amount fields.

at end of matnr.

SUM

endat.

write:/ wa, itab-amount fields.

endloop.

Raja

Read only

0 Likes
850

Thanks to both of you.

Raja, that does the trick. Didnt realize the order of the fields.

Its working now. Thanks to both of you again.

Regards,

Kenny