cancel
Showing results for 
Search instead for 
Did you mean: 

How to sum one field in internal table

Former Member
0 Kudos
99

Hi experts ,

I am passing intermal table from program to smartforms .

but i want to calculate the Quantatiy(mseg-menge) base on the material nu (MSEG-MATNR) .

am display at end of page . if data into internal table have

matnr menge unit

mat1 30 PC

mat1 40 PC

mat2 10 Kg

mat2 30. Kg

in my smartform out put display at last .

Total

Mat1 : 70 PC

Mat2 : 40 kg

Please if any body have input , you are welcome for solve this issue.

Regards

Ajay Pandey

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

data: w_sum type menge, w_matnr like matnr.

loop at itab.

w_sum = w_sum + itab-menge.

w_matnr = itab-matnr.

at new matnr.

write: w_matnr, w_sum.

clear: w_matnr, w_sum.

endat.

endloop.

plzz reward if helpfull for any further quiries

my mailid is mutyalasunilkumar@gmail.com

plzz dont forget to reward.

thanks and regards.

Answers (4)

Answers (4)

Former Member
0 Kudos

thatks all of you:)

Former Member
0 Kudos

Thanks for your Quick reply ,

But how i can write it into Smartform in main window table node.

Former Member
0 Kudos

HI

with in Table -


> Rows -


>Cell in this cell (with text element) create a CODE then put code like this modified accordingly ur internal table/field name.

after completion of ROW create one more row put variables containg totals in this to display.

Former Member
0 Kudos

hi

try this may help

create code in CELL where u want SUM

use ON CHANGE OF ITAB-MATNR.

clear ITAB-TOTMENGE.

ENDON.

ITAB-TOTMENGE = TOTMENGE + ITAB-MENGE.

reward if helpful

former_member223537
Active Contributor
0 Kudos

loop at itab into watab.

if wanew-matnr ne watab-matnr.

append wanew to inew.

clear wanew.

wanew-matnr = watab-matnr.

wanew-qty = watab-qty.

else.

wanew-qty = wanew-qty + watab-qty.

endif.

endloop.