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

using sum function

Former Member
0 Likes
685

hi experts,

i want to sum the total of opening stock for a particular raw material alone.but that raw material is used for manufaturing many finished goods.

what i ahev to do .

eg)

material1

mat1 100

mat2 200

material2

mat1 50

mat3 300

material3

mat1 100

mat2 400

so i want to get the total of each material.

what shall i do.

5 REPLIES 5
Read only

gopi_narendra
Active Contributor
0 Likes
590

Use the collect statement for each Material...See F1 for help

Regards

Gopi

Read only

Former Member
0 Likes
590

hi,

Loop at itab.

at end of MATNR.

sum.

write:total.

endat.

endloop.

Reward points if helpful

Regards,

Imran

Read only

Former Member
0 Likes
590

here is the sample code ....

sort  itab by  material  mat  .
Loop at itab  .

at end of   material1.
sum .
write  :  itab-material , itab-mat , itab-amount.   " for sub-total .
endat .
endat.
atlast material .
sum.
write  :  itab-material , itab-mat , itab-amount.  "for total
endat .
endloop.

rewardpoints if it is usefull

Girish

Read only

0 Likes
590

thanx for replies.

i am not getting the total for each material.it is displaying the total for all materials while using at last.

if i give

at last matnr.

it is throwing an error like this

. or with expected after last.

Read only

Former Member
0 Likes
590

DATA : WTAB LIKE ITAB.

SORT ITAB BY MATNR.

LOOP AT ITAB.

MOVE-CORRESPONDING ITAB TO WTAB.

AT LAST.

SUM.

WRITE : / WTAB-MATNR, ITAB-QUANTITY.

ENDAT.

REGARDS

SHIBA DUTTA