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: 

sum from cluster table

was_wasssu
Participant
0 Kudos

I want to make a SUM for a field from KONV table. Making the sum directly doesn't works because konv is a cluster table. What is the code for making the sum from this table?

Thank you.

2 REPLIES 2

Former Member
0 Kudos

Hi,

You can proceed with normal selection process ie : fetch the data into and internal table and then later

you can loop that particular internal table and collect it into another internal table to sum up the values.

for example :

select * from ( your required field which you want )

from konv

into table it_konv.

if it_konv[] is not initial.

loop at it_konv into wa_konv.

wa_konv to wa_collect.

collect wa_collect to it_collect.

endloop.

collect statement will full fill your requirment

Let me know if you need further information

Regards

Satish Boguda

Former Member
0 Kudos

can use this code also :

data : LV_EFFECTIVE TYPE KONV-KWERT .

SELECT KWERT FROM KONV INTO CORRESPONDING FIELDS OF TABLE IT_KONV WHERE KNUMV EQ WA_EKKO-KNUMV

AND KPOSN EQ WA_EKPO-EBELP

AND KSCHL NE 'NAVS'.

IF IT_KONV IS NOT INITIAL.

LOOP AT IT_KONV INTO WA_KONV.

LV_EFFECTIVE = LV_EFFECTIVE + WA_KONV-KWERT .

ENDLOOP .

ENDIF .