‎2007 Aug 09 2:42 PM
hallow
i wont to do select sum statment and i dont now how to do it right
i wont to sum field kwert to on field l_kwert how i do that.
i dont now the syntax
thankes
i try
select sum (kwert)
from konv
into l_kwert
where knumv = l_knumv
and kschl = 'ZMTG'.
‎2007 Aug 09 3:34 PM
Hi, use group by in your select or do a loop endloop with at end of key field sum!
Alex
‎2007 Aug 09 2:44 PM
Hi,
Here is the Example
SELECT SUM( cant )
FROM zcmtt_envase
INTO v_cant
WHERE docsap = p_tipo
AND ref = p_ti_zcmtt_envase-ref
AND matnr = ti_sumlips-matnr.Regards
Sudheer
‎2007 Aug 09 2:54 PM
hallow
itry like your sample but i have erorr
aggregate function and distinct are not supported in field lists for pooled and cluster table
what is wrong?
‎2007 Aug 09 2:54 PM
Hi,
I just see one problem with your syntax, the SPACES :
SELECT SUM( kwert ) FROM...
You don't have a space after SUM, but two around kwert.
Regards,
Mathieu
‎2007 Aug 09 2:57 PM
Hi,
As KONV is a cluster table you need to do like this way
select kwert from konv
into table i_kwert
where knumv = l_knumv
and kschl = 'ZMTG'.
loop at i_kwert.
v_kwert = v_kwert + i_kwert.
endloop.
aRs
‎2007 Aug 09 3:02 PM
‎2007 Aug 10 12:23 PM
Hi...
This is the code for u.
Data : i_kwert type Table of konv with header line.
data : v_kwert type konv-kwert.
select kwert from konv
into table i_kwert
where knumv = l_knumv
and kschl = 'ZMTG'.
loop at i_kwert.
v_kwert = v_kwert + i_kwert.
endloop.
<b>Reward if Helpful.</b>
‎2007 Aug 09 3:08 PM
Hi Shnya,
sum is an OPEN SQL aggregated function, you have to use the addition group by in youre select statment
select sum (kwert) from konv into l_kwert group by kwert
where knumv = l_knumv
and kschl = 'ZMTG'.
sometimes performances are not very good with aggregated functions,
another alternative, is to select all the master data you want, then summarize in a loop endloop with the sum statment.
loop.
at end of key fields
sum. append result to internal table
endloop.
hope it will helps,
thanks!
‎2007 Aug 09 3:34 PM
Hi, use group by in your select or do a loop endloop with at end of key field sum!
Alex
‎2007 Aug 10 11:53 AM
hi,
remove the blank space between sum (kwert).
other wise use internal table ..
in internal table use
loop at itab.
at end of kwert.
sum.
endloop.
Message was edited by:
alka sachin
‎2007 Aug 10 11:55 AM
hi,
remove the blank space between sum (kwert).
other wise use internal table ..
in internal table use
loop at itab.
at end of kwert.
sum.
endloop.
‎2007 Aug 10 12:03 PM
as KONV is a cluster table, see
aggregate function and distinct are not supported in field lists for pooled and cluster table
you must use:
select kwert from konv
into table i_kwert
where knumv = l_knumv
and kschl = 'ZMTG'.
loop at i_kwert.
v_kwert = v_kwert + i_kwert.
endloop.
You should also use such a coding, in the case of buffered tables!
If you do not know hwo to define internal tables, then I would highly
recommend you to call the online help on internal tables.
Siegfried