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: 

add amount fields of two same belnr entries

Former Member
0 Kudos

i am working on a zreport ,my problem is that in my itab if belnr is unique then it should print the amount value given against it ,but if it encounters two same belnr values then it should print the cumulative value of amount field.for e.g.

belnr amount

2500000018 205.

2500000020 800

2500000020 200

in case of belnr = 250000018 it should give 205,but in case of belnr = 2500000020 it should print 1000.

it is urgent please .points will be rewarded surely

sarabjit

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data:

itab1 like table of itab with header line.

sort ITAB by belnr.

loop at ITAB.

itab1 = itab.

collect itab1.

endon.

endloop.

Now ITAB1 will contain the required cumulative results.

If it doesn't work then in need to see how you declared ITAB.

Reward points if useful.Get back in case of query...

Cheers!!!

6 REPLIES 6

Former Member
0 Kudos

hi,

use collect statement in loop as

loop at itab.

..............

................

..............

collect itab.

endloop.

if there are same fields with numeric values then asingle record grouping of all numeric values will be done by collect statement.

if helpful reward some points.

with regards,

Suresh Babu.

Former Member
0 Kudos

first declare an internal table sumilar to ur interval table.

loop on itab1.

move-corresponding itab1 to itab2.

collect itab2.

endloop.

OR

sort itab.

at new belnr.

sum.

......

reward if helpful

0 Kudos

hi anju can u elaborate it plz

Former Member
0 Kudos

data:

itab1 like table of itab with header line.

sort ITAB by belnr.

loop at ITAB.

itab1 = itab.

collect itab1.

endon.

endloop.

Now ITAB1 will contain the required cumulative results.

If it doesn't work then in need to see how you declared ITAB.

Reward points if useful.Get back in case of query...

Cheers!!!

Former Member
0 Kudos

if u have the two fields in itab1.

data: begin of itab2 occurs 0,

belnr(10),

amount type p decimals 2.

end of itab2.

loop at itab1.

move itab1-belnr to itab2-belnr.

move itab1-amount to itab2-amount.

collect itab2.

endloop.

0 Kudos

thanks to all of you