cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS View with arithmetic CASE-Expression

0 Likes
13,002

Hey Experts,

i'm developing a CDS-View in ABAP for HANA and i need a CASE-Statement with an arithmetic expression in it.

Error on above image is unexpected word "(".

I have also tried a few other ways like casting or subtracting in a between clause but nothing works.

Looking forward to your answers.

Simon

Accepted Solutions (1)

Accepted Solutions (1)

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Simon,
please find the restrictions in CDS CASE expressions in ABAP Keyword Documentation.

So, I think you'll have to use a workaround like a view-on-view, wherein the underlying view calculates the field you'd like to use as right hand side (rhs) of the conditional expression.

Cheers,
  Jasmin

Former Member
0 Likes

case

when fkimg > 10

then 'dummy'

when netwr between 10 and 100

then 'dummy'

else

'fit'

end as invoiceuse ,


i have used this above code to build cds view it dnt throwed any error


and when you want to compare same field then try like,


case fkimg

when 0

then 'bad'

when 10

then 'good'

else

'better'

endcase as result.

0 Likes

Thanks Jasmin for your replay.

Using calculated fields in the same view again is also not possible?


bap.kwmeng - vbap.untto as calc,

case when bmeng >= calc and bmeng < vbap.kwmeng then 1

Thanks

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Simon,
nope, unfortunately not.
Cheers,
  Jasmin

0 Likes

Ok, thanks Jasmin, solved it as you mentioned.

View-on-View

Regards

Simon

Answers (1)

Answers (1)

thomasgauweiler
Employee
Employee
0 Likes

The calculated case ( CASE WHEN <boolean expression> ... ) is only available with SP8 or later.

See also http://help.sap.com/abapdocu_740/en/abennews-740_sp08-abap_cds.htm#!ABAP_MODIFICATION_5@5@

Regards, Thomas