07-26-2019 8:29 PM
Hi Gurus,
I have a requirement wherein I need to get aggregate of local currency for particular GL based on Division.
Consider the below query-
select BSEG~BUKRS ,
BSEG~GJAHR ,
BKPF~MONAT,
BSEG~HKONT ,
case substring( setleaf~SETNAME , 1 , 3 )
when 'MBG' then 'MBG'
when 'ETB' THEN 'ETB'
when 'EMP' THEN 'EMP'
ELSE setleaf~SETNAME
END AS Division_type,
BKPF~WAERS,
SUM( BSEG~DMBTR ) AS TOTO_LOCAL
from ( BSEG AS BSEG
inner join BKPF AS BKPF
on BKPF~BELNR = BSEG~BELNR
and BKPF~BUKRS = BSEG~BUKRS
and BKPF~GJAHR = BSEG~GJAHR
inner join setleaf as setleaf
on setleaf~VALFROM = bseg~prctr
)
group by bseg~bukrs,
bseg~gjahr,
bkpf~monat,
BSEG~HKONT ,
( case substring( setleaf~SETNAME , 1 , 3 )
when 'MBG' then 'MBG'
when 'ETB' THEN 'ETB'
when 'EMP' THEN 'EMP'
ELSE setleaf~SETNAME
END ) ,
BKPF~WAERS
ORDER BY bseg~bukrs,
bseg~gjahr,
bkpf~monat,
BSEG~HKONT,
Division_type,
BKPF~WAERS
On executing syntax check I am getting the below error-
Only elementary arithmetic types can be used in arithmetic expressions. The type of 'MBG' is invalid.
Can someone suggest on resolving this error.
07-26-2019 9:17 PM
The error is probably in the CASE of the GROUP BY clause. Could you try removing the parentheses around CASE? Not sure if CASE is fully supported in GROUP BY, could you try removing the whole CASE from both SELECT and GROUP BY? What ABAP version do you use?
07-28-2019 4:15 PM
Do your query "without" the "group by" works?
BTW: What version of ABAP are you using?
07-29-2019 1:46 AM
I think you can directly group by setleaf~setname instead, result should be the same.