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: 

Sum

Former Member
0 Kudos

I have an itab containing netwr, kwmeng and olfmng values. I am displaying this itab on the output in simple list. What should I do to get sum of these values for each fields at the end of the list?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi nuren,

sort itab.

loop at itab.

at last.

sum.

endat.

endloop.

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

loop at itab.

at last.

collect itab.

endat.

endloop.

Then display your itab.

Regards,

ravi

Former Member
0 Kudos

hi nuren,

sort itab.

loop at itab.

at last.

sum.

endat.

endloop.

0 Kudos

You can have a structure which has those fields.

* Create a structure with the same field names that 
* you want to sum.
data: begin of xsum,
      netpr type netpr,
      menge type menge,
      end of xsum.


loop at itab.

add-corresponding itab to xsum.

endloop.


write:/ xsum-netpr, xsum-menge.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Nuren,

In order to find the sum of the table contents.

Loop at i_tab.

<b>at last.

sum.

endat.</b>

endloop.

Now you will have the sum of the values of netwr, kwmeng and olfmng in the header of the internal table.

ws_total = i_tab-netwr.

ws_tot = i_tab-kwmeng.

ws_totl = i_tab-olfmng.

write: / ws_total, ws_tot, ws_totl.

Reward if useful.

Regards,

Tushar

Message was edited by: Tushar Marshall Dass

Former Member
0 Kudos

Hi Nuren,

loop at it_tab.

at last.

sum.

endat.

Regards,

Laxmi.

Former Member
0 Kudos

Hi nuren,

end-of-selection.

loop at itab.

at last.

sum.

endat.

reawrd if helpful.

regards,

keerthi.