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,
Horst Keller replied
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:
define view kellerh_cds_test
p_start_date : abap.dats
as select from demo_expressions
case when dats2 < $parameters.p_start_date
else cast( $parameters.p_start_date as abap.dats )
end as res