Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create CDS view with dynamic date in where clause using $session.system_date

0 Kudos

Good day,

I'm wondering how to select with date range? but my input should be Type:Int.

In my example below I have entered parameter type date and used it in the where condition

but I wanted to do something like this one but ended up with errors

calday between ( $session.system_date - $parameters.inputInt ) and $session.system_date

I wanted to avoid sy-datum - X, then passing the result as parameter

define view ZCDS_STAT_OLAP 
with parameters from_date : rsddstatday
as select from rsddstat_olap as olap
{
  key handletp,
  key steptp,
  key stepcnt,
  key uname,
  key calday,
  runtime,
  infoprov,
  objname   
} where runtime > 20
  and calday between $parameters.from_date and $session.system_date

Thank you for your help!

1 REPLY 1

AbhishekSharma
Active Contributor
0 Kudos

Hi mchua9

I faced somewhat similar issue while using system date in where clause...

I created normal view where I converted date field using below function:

tstmp_to_dats( CONFIRMED_AT, abap_system_timezone( $session.client,'NULL' ), $session.client, 'NULL' ) as ConfirmedDate,

this returns me date in format YYYY-MM-DD in result.

then I created one consumption view and called original view and then I was able to pass system date in were clause on CONFIRMED_AT field.

Hope this helps...

Thanks-

Abhishek