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: 

how to sum the values based on the for all entries

Former Member
0 Kudos
317

for example :

select aufnr vornr sum (ISM02) sum ( ISM04) Sum (ism05) from afru into table I_afru for all entries of I_caufv where aufnr = i_caufv-aufnr group by aufnr.

can any one help based on this query

without forall entries it is working based for all entries only i want the solution Help me please.

Regards

Augustine

2 REPLIES 2

Former Member
0 Kudos
98

Another solution is to use the below logic.

1. Get min and max aufnr from i_caufv.

2. Build a range for aufnr.

3. Select aufnr vornr sum(ism02)....from afru into i_afru

where aufnr in range_aufnr group by aufnr vornr.

4. Loop at i_caufv.

read table i_afru with aufnr = i_caufv-aufnr.

endloop.

Regards

Anurag

Former Member
0 Kudos
98

Simple,

select aufnr vornr ISM02 ISM04 ism05 from afru into table

I_afru for all entries of I_caufv

where aufnr = i_caufv-aufnr .

<b>if sy-subrc eq 0.

sort I_afru by aufnr.

loop at l_afru.

at end of aufnr.

SUM.

l_afru_temp = l_afru.

append l_afru_temp.

endat.

endloop.

endif.</b>