2007 Aug 17 1:12 PM
Dear Sir(s),
I want to sum kbetr (no. of packing) for same knumv(invoice no.) in table konv.
e.g.
invoice no. no. of packing
(knumv) (kbetr)
001 2
001 3
002 4
002 5
result should be -
invoice no no. of packing
001 5
002 9
code-
select knumv kschl sum(distinct kbetr)
from konv
into table it_konv
for all entries in it_vbrk
where kschl = 'ZFQT'
and knumv = it_vbrk-knumv
group by knumv kbetr.
error showing - unkown col. sum(distinct field list.
Please help me immediately.
thanks,
R.Kapoor
2007 Aug 17 1:16 PM
u can use at end of statement inside loop statement
loop at it.
write:/ it-field1,it-field2,
at end of kumnv
sum.
endat.
endloop.
reward points if this is useful
2007 Aug 17 1:16 PM
select knumv sum( kbetr )
into table it_konv
from ...
group by knumv.
2007 Aug 17 1:16 PM
u can use at end of statement inside loop statement
loop at it.
write:/ it-field1,it-field2,
at end of kumnv
sum.
endat.
endloop.
reward points if this is useful
2007 Aug 17 1:16 PM
Hi..
Change ur Select statement as below .
<b>select knumv sum(kbetr)</b>
from konv
into table it_konv
for all entries in it_vbrk
where kschl = 'ZFQT'
and knumv = it_vbrk-knumv
<b>group by knumv .</b>
Here you need not to Retrieve the Field KSCHL since it is anyway given in the WHERE clause.
Let me know incase of any other issue.
<b>Reward if Helpful.</b>
2007 Aug 18 10:47 AM
Dear Sir,
I am still facing problem in using sum agregate in select statement.
it showing error again, kindly check at your end and send by mail.
thanks & regards,
Rakesh Kapoor
2007 Aug 17 1:18 PM
Hi,
try this
<b>select knumv kschl
from konv</b>
into table it_konv
for all entries in it_vbrk
where kschl = 'ZFQT'
and knumv = it_vbrk-knumv
group by knumv kbetr.
sort it_know by knumv.
loop at it_knov.
at end of knumv.
sum.
write:/ it_knov-knumv, it_knov-kbetr.
endat.
endloop.
thanks & regards,
Venkatesh
2007 Aug 18 10:41 AM
Dear Sir,
Your solution is very helpful and now i overcome from the problem. hope in future also you will help me in solving problems.
thanks & regards,
Rakesh Kapoor
2007 Aug 17 1:18 PM
u loop the internal table and then use
ON CHANGE OF in loop and do SUM.
2007 Aug 17 1:22 PM
data:
it_konv2 like table of it_konv with header line.
select knumv kschl kbetr
from konv
into table it_konv
for all entries in it_vbrk
where kschl = 'ZFQT'
and knumv = it_vbrk-knumv.
loop at it_konv.
it_konv2 = it_konv.
collect it_konv2.
endloop.
**So it_konv2 will have your desired data.
Reward points if useful.Get back in case of query...
Cheers!!!
2007 Aug 17 1:26 PM