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: 

summing the values

Former Member
0 Kudos

hi,

i have a function module with an internal tablewhich displays in this manner

(data type) char quan quan unit

1234blk 4 3 7

1280blk 4 3 7

1234blk 6 7 3

but i want my result to b displayed as follows.

(data type) char quan quan unit

1234blk 10 10 10

1280blk 4 3 7.

i cont use collect bcos data types are not of integer,

pls awaiting for ur respone.

6 REPLIES 6

Former Member
0 Kudos

Hi cyrilvictor,

1. No problem.

2. we can use Quantity field also in collect.

3. just copy paste in new program to get a taste of it.

4.

report abc.

*----


data : begin of itab occurs 0,

f(4) type c,

menge like ekpo-menge,

end of itab.

data : stab like table of itab with header line.

*----


itab-f = '1234'.

itab-menge = 25.

append itab.

itab-f = '1234'.

itab-menge = 50.

append itab.

*----


loop at itab.

move-corresponding itab to stab.

collect stab.

endloop.

*----


break-point.

regards,

amit m.

Former Member
0 Kudos

HI,

I THINK WE CAN USE COLLECT STMT AS IT IS FOR ABAP NUMERIC DATA TYPES.

hope this helps,

priya.

0 Kudos

sort itab by field1.

SELECT field1 field3 SUM( field2 ) FROM dbtab

INTO ITABK

WHERE cond

GROUP BY field1 field3 .

APPEND ITABK.

CLEAR:ITABK.

ENDSELECT.

Former Member
0 Kudos

Hi,

Please go through the folloewing logic,

sort the table by char

loop at internal table.

at end of char.

sum .

append wa_area to new_internaltable. " should be of same type.

endat.

MarkHelfull answers if the problem is solved

Regards

Former Member
0 Kudos

hi,

collect statement adds all the numeric fiels(irrespective of the data types) of whose alpha numeric fields are equal.

award pts. if it helps.

thanks,

keerthi.

0 Kudos

hi Charles,

use Collect Statement..

i.,e <b>COLLECT <wa> INTO <itab>.</b>

for further details check this link

http://help.sap.com/saphelp_erp2005/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm

Regards,

Santosh