Search code examples
abapcds

(NOT) IN list of values filter in CDS definitions


I am curious to know if CDS views have any filter commands similar to SQL's in ('value1', 'value2'). It is not directly supported by CDS views, but it's supported by most versions of SQL (including Open SQL). I can always just check by writing out a long is or Field = 'value1' OR Field = 'value2', but if such syntax exists, I would prefer to use the shorter syntax.

Open SQL example of what I'm trying to achieve:

Select * 
  from customers 
  where customer_group in ( 'group1', 'group2' )
  into table @lt_table.

Solution

  • In ABAP CDS, probably not.

    Here are the possible operators from the ABAP 7.53 documentation:

    • =, <>, <, >, <=, >=
    • BETWEEN
    • LIKE
    • IS NULL
    • IS INITIAL

    (there is also the boolean operator NOT)

    As far as I can see, CDS Views in S/4HANA always use OR.