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

Former Member
0 Likes
854

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
Read only

Former Member
0 Likes
823

hi nuren,

sort itab.

loop at itab.

at last.

sum.

endat.

endloop.

6 REPLIES 6
Read only

Former Member
0 Likes
823

loop at itab.

at last.

collect itab.

endat.

endloop.

Then display your itab.

Regards,

ravi

Read only

Former Member
0 Likes
824

hi nuren,

sort itab.

loop at itab.

at last.

sum.

endat.

endloop.

Read only

0 Likes
823

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

Read only

Former Member
0 Likes
823

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

Read only

Former Member
0 Likes
823

Hi Nuren,

loop at it_tab.

at last.

sum.

endat.

Regards,

Laxmi.

Read only

Former Member
0 Likes
823

Hi nuren,

end-of-selection.

loop at itab.

at last.

sum.

endat.

reawrd if helpful.

regards,

keerthi.