10-08-2008 7:01 AM
HI, gurus,
I have a problem with the 'select.. sum ..' clause.
the following is my code:
SELECT sgtxt sum( wrbtr ) FROM bsis
INTO CORRESPONDING FIELDS OF TABLE it_temp
WHERE bukrs = '1500'
AND budat >= '20040131'
AND budat <= q_date1
AND hkont = '0012420001'
AND sgtxt >= 'ORD 300000'
AND sgtxt <= 'ORD 399999'
group by sgtxt .
but I can't get the sum value of the field 'wrbtr' ,is the 'CURR' type field couldn't sum in this clause?
10-08-2008 7:36 AM
Hi Bill,
You have to modify your code as mentioned below.
SELECT sgtxt sum( wrbtr ) as wrbtr
FROM bsis
INTO CORRESPONDING FIELDS OF TABLE it_temp
WHERE bukrs = '1500'
AND budat >= '20040131'
AND budat <= q_date1
AND hkont = '0012420001'
AND sgtxt >= 'ORD 300000'
AND sgtxt <= 'ORD 399999'
group by sgtxt .
thanks & regards
Kishore M
10-08-2008 7:10 AM
Hi
The Clauses sum avg in select etc applies to all the records of the query result . it results in a single value.
so better use the below specified query
data : sum_wbetr type wbetr.
SELECT sum( wrbtr ) FROM bsis
INTO sum_wbetr
WHERE bukrs = '1500'
AND budat >= '20040131'
AND budat <= q_date1
AND hkont = '0012420001'
AND sgtxt >= 'ORD 300000'
AND sgtxt <= 'ORD 399999'
group by sgtxt .
u will probably not be using this value sum_wbetr multiple times , so no need to move it into every record of the table as u r doing.
SELECT sgtxt FROM bsis
INTO CORRESPONDING FIELDS OF TABLE it_temp
WHERE bukrs = '1500'
AND budat >= '20040131'
AND budat <= q_date1
AND hkont = '0012420001'
AND sgtxt >= 'ORD 300000'
AND sgtxt <= 'ORD 399999'
group by sgtxt .
Hope this clarifies ur query
10-08-2008 7:36 AM
Hi Bill,
You have to modify your code as mentioned below.
SELECT sgtxt sum( wrbtr ) as wrbtr
FROM bsis
INTO CORRESPONDING FIELDS OF TABLE it_temp
WHERE bukrs = '1500'
AND budat >= '20040131'
AND budat <= q_date1
AND hkont = '0012420001'
AND sgtxt >= 'ORD 300000'
AND sgtxt <= 'ORD 399999'
group by sgtxt .
thanks & regards
Kishore M
10-08-2008 9:00 AM
07-29-2010 8:42 AM
Hi Bill,
I want sum of DMBTR from BSIK n BSAS .
As kishore said now i m getting values in it_bsik-dmbtr, but i want to copy this value in var1 which is of type char.
can u plz help me , how to do this???
Thanks & Regards,
Manisha
Edited by: PATIL MANISHA on Jul 29, 2010 9:43 AM