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

summing

Former Member
0 Likes
846

how to add different amounts for a same account id ?

ex: accid- 1000 amt - 100

accid- 1000 amt - 1000

accid- 1000 amt - 200

accid- 1000 amt - 10000

accid- 1000 amt - 300

6 REPLIES 6
Read only

former_member182354
Contributor
0 Likes
825

Hi,

Use collect statement.

Collect itab.

Regards,

Raghav

Read only

dhruv_shah3
Active Contributor
0 Likes
825

Hi,

Use the Collect Statement inside the Loop..Endloop.

you have to use this collect statement on work area of the internal table.

HTH.

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
825

Use loop for the account id table

Loop at accidtable.

amount = amount + accountid-amount.

Endloop.

Thanks,

Sunil

Read only

Former Member
0 Likes
825

Hi,

let us assume accid and amt fields are in an internal table say itab

now

loop at itab.
at end of accid.
sum.
write : / itab-accid,itab-amt.
endat.
endloop.

Cheers,

jose.

Read only

Former Member
0 Likes
825

hi ,

Use following code,

sort itab by accid.

Loop at itab,

itab1-amount = itab1-amount + itab-amount.

at end of accid.

itab1-accid = itab-acccid.

append itab1.

clear itab1.

endat.

endat.

endloop.

Regards,

Talwinder

Read only

Former Member
0 Likes
825

Hi,

You can use collect statement.


"Declare a work area and another internal table same as internal table.

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

Thanks,

Sriram Ponna.