Application Development and Automation 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: 
Read only

CDS - Date calculation

Former Member
0 Likes
3,131

Hi,

I'm trying to do som calculation with date type fields.

@AbapCatalog.sqlViewName: 'ZDEMOSDN'

@EndUserText.label: 'test'

define view ZDEMOSDN as select from aufk as a inner join afko as b

    on a.aufnr = b.aufnr

{

    key a.aufnr,

    a.erdat - a.idat2 as date2   

}

I'm getting the error messages:

Data type DATS is currently not supported in an arithmetic expression

Will this be supported in near future? Is there kind of workaround .

Regards,

Bart



4 REPLIES 4
Read only

christian_seitel
Product and Topic Expert
Product and Topic Expert
0 Likes
1,769

There are functions like

dats_is_valid

dats_days_between

dats_add_days

dats_add_months

If they are not available yet in your current SP-release then there is no workaround as date-time calculations are very complex (just think of leap years or things like that)

Read only

0 Likes
1,769

Thanks Christian. Unfortunately
not available, because of SP-release.

Regards,

Bart

Read only

0 Likes
1,769

Read only

0 Likes
1,769

Usage of a parameter could serve as workaround:

define view ...

  with parameters

    sydat : abap.dats @<Environment.systemField: #SYSTEM_DATE

  as select from svers

{

  dats_days_between( $parameters.sydat, $parameters.sydat ) as delta

}

or a join with another view (wrapping $session.system_date as column)

define view ...

  as select from svers

{

  $session.system_date as system_date

}