Skip to Content

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

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!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jul 28, 2020 at 04:09 PM

    Hi Marverick Chua

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.