2015 Jul 16 11:50 AM
Hi,
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,
Anita
2016 Aug 12 7:03 AM
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
{
dats1,
dats2,
case when dats2 < $parameters.p_start_date
then dats2
else cast( $parameters.p_start_date as abap.dats )
end as res
}
Cheers
Horst
2016 Aug 11 3:36 PM
Hi Anita,
I think one (dirty) workaround in your scenario could be to define a second CDS view with identical interface as wrapper and use the parameter as colum output. Maybe you can try something like this (untested):
1. Adjust your CDS view by adding a column with system date, e.g.:
define view ZEMP_YEARS_1
with parameters
@Environment.systemField: #SYSTEM_DATE
@EndUserText.label: 'Test'
p_start_date : abap.dats
as select from ZAD_EMPSTAFFING{
-- your column fields...
$parameters.p_start_date as sydatum
}
2. Create new CDS view, e.g.:
define view ZEMP_YEARS_1_WRAP
with parameters
@Environment.systemField: #SYSTEM_DATE
@EndUserText.label: 'Test'
p_start_date : abap.dats
as select from ZEMP_YEARS_1( p_start_date: $parameters.p_start_date ){
-- your column fields...
case
when ZEMP_YEARS_1.EndDate < ZEMP_YEARS_1.sydatum then ZEMP_YEARS_1.EndDate
else ZEMP_YEARS_1.sydatum end as EndDateU
}
I hope this helps and all the best,
Michael
2016 Aug 12 7:25 AM
2016 Aug 12 7:03 AM
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
{
dats1,
dats2,
case when dats2 < $parameters.p_start_date
then dats2
else cast( $parameters.p_start_date as abap.dats )
end as res
}
Cheers
Horst
2016 Aug 12 7:26 AM
2016 Aug 26 9:06 AM
Hello,
Is there any way to do arithmatic on date and time fields?
would you pls let me know syntax.
normal CDS view or Query type CDS view (@Analytics.query: true)
2016 Aug 26 9:17 AM
2016 Sep 01 7:23 AM
2021 Sep 18 6:51 AM
Hi Experts,
Without using Parameters , do we get the system field in Plain CDS View.
Thanks
Sumanth
2021 Sep 24 1:15 AM
Hi Sumanth,
Maybe, it can help.
"tstmp_to_tims(TSTMP_CURRENT_UTCTIMESTAMP(), abap_system_timezone( $session.client,'NULL' ), $session.client, 'NULL') as SYSTIME ,"
Kind Regards,
Carlos
2023 Mar 01 3:47 PM
I know this question is old, but I just had the same "challenge".
It depends on the release you are working on.
Release 7.51 and higher provides a session-variable that gives us directly the current date.
$session.system_date
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abencds_f1_session_variable.htm