Former Member

# Itab total doubt

Hi,

I ve a internal table with following records,

Item no mat qty

1 abcd 2

1 abcd 7

2 efgh 6

How to make this to

1 abcd 9

2 defg 6

Thanks

10|10000 characters needed characters exceeded

### Related questions

• Former Member
Posted on Jan 22, 2008 at 07:51 AM

Hi Rahul,

Have a look at demo program DEMO_INT_TABLES_COLLECT

Hope this helps.

Thanks

Lakshman

10|10000 characters needed characters exceeded
• Former Member
Posted on Jan 22, 2008 at 07:58 AM

Hi,

Sort itab by itemno mat.

Loop at itab.

AT End of qty.

SUM.

itab1-itemno = itab-itemno.

itab1-mat = itab-mat.

itab1-qty = itab-qty. (qty will be automatically get summed)

Append itab1.

Endat.

Endloop.

Display itab1 , u will get the required result.

10|10000 characters needed characters exceeded
• Former Member
Posted on Jan 22, 2008 at 08:03 AM

Hi

use COLLECT u r problem get solves..

loop at itab into wa.

collect wa to itab_new.

endloop.

loop at itab_new to wa.

write: /

endloop.

plzz reward if iti si useful...

10|10000 characters needed characters exceeded
• Former Member
Posted on Jan 22, 2008 at 08:06 AM

REPORT ZTEST1231.

data : begin of itab occurs 0 ,

item_no(3) type i ,

material(20) type c,

Quantity(3) type i,

end of itab .

itab-item_no = '1'.

itab-material = 'abcd'.

itab-quantity ='2'.

Append itab.

itab-item_no = '1'.

itab-material = 'abcd'.

itab-quantity = '7'.

Append itab.

itab-item_no ='2'.

itab-material = 'efgh'.

itab-quantity = '6'.

Append itab.

clear itab .

sort itab by item_no material .

collect itab .

loop at itab.

write : itab-item_no , itab-material, itab-quantity .

endloop.

10|10000 characters needed characters exceeded
• Former Member
Posted on Jan 22, 2008 at 08:08 AM

Hi,

just u use collect statement for 2nd field then the respected values will be added when it 2nd fields having same name.

f1 f2 f3

1 abcd 2

1 abcd 7

2 efgh 6

collect itab.

then u will get following output

1 abcd 9

2 defg 6

if it is use full answer reward me a points