Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Current date in ABAP CDS views


I am trying to get current system date into a variable (in the form of parameter) as shown below :

What I need is  : If the end date is less than today's date, it's fine(continue with the end date)  else replace it with today's date (that's get it from the system's date) . But I am getting error such that it is not supported.

Can anyone suggest a workaround solution at the earliest ?

Thanks & Kind Regards,


Former Member

Hi Anita,

Unfortunately, result1, result2, ... of a CASE expression cannot be parameters (up to now).

But, hey, they can be CAST expressions. Therefore, a cheap trick that gives no error in 7.50:

@AbapCatalog.sqlViewName: 'KELLERH_V_TEST'

define view kellerh_cds_test

  with parameters

    @Environment.systemField: #SYSTEM_DATE

    p_start_date : abap.dats

  as select from demo_expressions




  case when dats2 < $parameters.p_start_date

    then dats2

    else cast( $parameters.p_start_date as abap.dats )

  end as res




1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question