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

help in Sum

Former Member
0 Likes
1,075

Hi,

i Have in program internal table with fields like below

and i wont to sum the sick days and put it in the last Colman

what is the Best way to do that?

Regards

i have this table without Colman sum (empty) .

pernr      orgeh       sick_days        sum

123        5555            3                   7
123        5555            4                   7
456        6666            7                  16
456        6666            1                  16
456        6666            8                  16
789        5656            3                  6
789        5656            3                  6

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
959

with the command COLLECT, check syntax in sap help

5 REPLIES 5
Read only

Former Member
0 Likes
960

with the command COLLECT, check syntax in sap help

Read only

Former Member
0 Likes
959

make pernr and orgeh the keys in a second table, loop at the first table and use collect to the second table and you shouldn't need a new colum

Read only

Former Member
0 Likes
959

Hi,

I guess this might help.

i_itab-sum = 0;

Loop at i_itab.

i_itab-sum = i_itab-sum + i_itab-sickdays.

endloop.

Read only

manuel_bassani
Contributor
0 Likes
959

Hi ricardo,

try the following:

DATA: sum_sick_days TYPE i.

LOOP AT tab INTO wa.
  AT NEW orgeh.
    SUM.
    sum_sick_days = wa-sick_days.
  ENDAT.

  wa-sum = sum_sick_days.
  MODIFY tab FROM wa.
ENDLOOP.

AT NEW ORGEH will sum the sick_days at every changes of PERNR or ORGEH.

So, for the same PERNR/ORGEH, you will have the correct sum.

Regards,

Manuel

PS: Please rewards points for useful answers.

Read only

Former Member
0 Likes
959

Hi,

You can use like...

SORT ITAB BY PERNR.

LOOP AT ITAB.

AT NEW PERNR.

SUM.

WRITE: /..............

ENDAT.

ENDLOOP.

The SICK field must be integer...so it can be added and others r of char(key).

reward if helpful.

thanks.