Skip to Content
1
Former Member
Dec 15, 2016 at 02:01 PM

ABAP CDS View Cast in Case Expression

20667 Views Last edit Dec 16, 2016 at 08:25 AM 3 rev

Hello,

I want to make a new field in my CDS-View, with a CASE-condition, like that:

case 
        when usage_6m  = 0 then '1'
        when usage_6m < '10' or usage_6m > '0' then '2'
        when usage_6m < '250' or usage_6m > '10' then '3'
        else '0'
        end as usage_icon

The problem is that the type of the field "usage_6m" NUMC10 is, so eclipse throws an error : "data type conflict". So then I wanted to cast the field to abap.int4, but that does not work eighter, because the CAST--expression is not supported in this position like this:

case 
        when cast( usage_6m  as abap.int4 )  = 0 then '1'

...

Do any of you have an idea how I cand solve this, or why I can't cast a field inside of a CASE-expression.

Thank you!

Cristina