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

regarding SUM

Former Member
0 Likes
762

Hi,

i have an internal table with field plant and quantity.

i want total of quantity according to same plant.

eg.

plant quantity

p1 100

p1 200

total 300

p2 100

total 100

p3 200

p3 200

total 400

plz. help me.

7 REPLIES 7
Read only

Former Member
0 Likes
741

Hi vishal,

You can use Collect statement in your case.


Loop at <internal table>
   Collect <internal table>.
Endloop.

Then watchout for the contents of the internal table.

Reward points if this helps,

Kiran

Read only

Sm1tje
Active Contributor
0 Likes
741

use LOOP and COLLECT.

Read only

Former Member
0 Likes
741

Hi,

U can use control Break statements like AT END OF <field>. ENDAT. In this u can use SUM keyword.

or u can use COLLECT statememt.

Best regards,

raam

Read only

Former Member
0 Likes
741

hi,

loop at itab.

at new plant.

***you can sum or collect your records in another table.

endat.

endloop.

hope this will help u out.

Read only

Former Member
0 Likes
741

Hi

You can do the following way.

data: beign of itab occurs 0,

plant type char4,

qty type i,

end of itab.

  • Assume data is available at this internal table.

data: it_out like itab occurs 0.

loop at itab.

collect itab into it_out.

endloop.

You can get the sum based on yr plant.

Reward points if it is helpful.

Regards

Raja

Read only

Former Member
0 Likes
741

Hi,

You can use at end and collect statement.


"Using collect.

loop at itab into wa.
collect wa into itab2.
endloop.

OR

"Using at end.

loop at itab.
at end of plant.
sum.
write : itab-pant, itab-quantity.
endat.
endloop.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
741

Hi,

There are two ways.

1. You can use COLLECT key word.

LOOP AT ITAB.

COLLECT ITAB.

ENDLOOP.

2. You can use SUM keyword.

LOOP AT ITAB.

AT END OF COMPANY.

SUM.

ENDAT.

ENDLOOP.