Former Member

### add amount fields of two same belnr entries

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

10|10000 characters needed characters exceeded

Former Member
Aug 17, 2007 at 05:55 AM

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!!!

10|10000 characters needed characters exceeded
• Former Member
Aug 17, 2007 at 05:20 AM

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.

with regards,

Suresh Babu.

10|10000 characters needed characters exceeded
• Former Member
Aug 17, 2007 at 05:27 AM

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.

......

10|10000 characters needed characters exceeded
• Former Member

hi anju can u elaborate it plz

• Former Member
Aug 17, 2007 at 05:57 AM

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.