Ansicht
Dokumentation

ABENCDS_TIMESTAMP_FUNCTIONS_V2 - CDS TIMESTAMP FUNCTIONS V2

ABENCDS_TIMESTAMP_FUNCTIONS_V2 - CDS TIMESTAMP FUNCTIONS V2

PERFORM Short Reference   Vendor Master (General Section)  
This documentation is copyright by SAP AG.
SAP E-Book

- CDS View Entity, Time Stamp Functions

... UTCL_CURRENT()
  $| UTCL_ADD_SECONDS(utcl,seconds)
  $| UTCL_SECONDS_BETWEEN(utcl1,utcl2)
  $| TSTMP_IS_VALID(tstmp)
  $| TSTMP_CURRENT_UTCTIMESTAMP()
  $| TSTMP_SECONDS_BETWEEN(tstmp1,tstmp2,on_error)
  $| TSTMP_ADD_SECONDS(tstmp,seconds,on_error) ...


Variants:

1. ... UTCL_CURRENT()

2. ... UTCL_ADD_SECONDS(utcl,seconds)

3. ... UTCL_SECONDS_BETWEEN(utcl1,utcl2)

4. ... TSTMP_IS_VALID(tstmp)

5. ... TSTMP_CURRENT_UTCTIMESTAMP()

6. ... TSTMP_SECONDS_BETWEEN(tstmp1,tstmp2,on_error)

7. ... TSTMP_ADD_SECONDS(tstmp,seconds,on_error)

Effect

In a CDS view entity, these functions perform operations on time stamps.

With the exception of UTCL_CURRENT and TSTMP_CURRENT_UTCTIMESTAMP, these functions have positional parameters to which actual parameters must be assigned when called. There are currently no optional parameters. Suitable fields of a data source, literals, parameters, path expressions, built-in functions, expressions, or reuse expressions using $projection can all be specified as actual parameters. Only literals can be passed to the parameter on_error. If an actual parameter contains the null value, every function except TSTMP_IS_VALID returns a null value.

Notes

  • While the time stamp functions starting with UTCL process data that is stored as real time stamp on the database, the functions starting with TSTMP process time stamps on the database that are stored as a packed number in the ABAP-specific format in DDIC database tables. These TSTMP time stamps are interpreted as regular numeric values in ABAP and in other types of access.
  • Conversion functions make it possible to transform a time stamp to date fields and time fields and to transform date fields and time fields to a time stamp.

Variant 1

... UTCL_CURRENT()


Effect

This function generates a UTC time stamp from the system time and the system date of AS ABAP in accordance with POSIX. The return value has the built-in dictionary type UTCLONG.

Variant 2

... UTCL_ADD_SECONDS(utcl,seconds)


Effect

The function UTCL_ADD_SECONDS adds seconds seconds to a time stamp utclong. It has two positional parameters. The actual parameter for the formal parameter utclong must have the built-in dictionary type UTCLONG and contain a valid UTC time stamp. An invalid time stamp produces an error. The actual parameter for the formal parameter seconds must have either the built-in data type INT4 or the data type DEC with length 21 and 7 decimal places. Any negative values are subtracted. If the result is invalid, an error occurs.

The result is of type UTCLONG.

Notes

  • If the positional parameter utclong is empty, it is set to its initial value.
  • The days missing from the Gregorian calendar (from 5.10.1582 to 15.10.1582) are handled as usually in ABAP.

Variant 3

... UTCL_SECONDS_BETWEEN(utcl1,utcl2)


Effect

The function UTCL_SECONDS_BETWEEN calculates the difference between two specified time stamps, utcl1 and utcl2, in seconds. It has two positional parameters. The actual parameters for the formal parameters utcl1 and utcl2 must have the built-in dictionary type UTCLONG and contain a valid UTC time stamp. Any invalid time stamps produce an error. If utcl2 is greater than utcl1, the result is positive. If the values are identical, the result is 0. In all other cases, the result is negative.

The result is of type DEC with length 21 and 7 decimal places.

Notes

  • If an actual parameter is empty, then this parameter is set to its initial value.
  • The days missing from the Gregorian calendar (from 5.10.1582 to 15.10.1582) are handled as usual in ABAP.

Variant 4

... TSTMP_IS_VALID(tstmp)


Effect

The function TSTMP_IS_VALID determines whether an argument tstmp contains a valid time stamp in the format YYYYMMDDHHMMSS. The actual parameter must have the built-in data type DEC with length 15 and no decimal places. The result has the data type INT4. A valid time stamp produces the value 1 and all other input values (including the null value) produce the value 0.

Variant 5

... TSTMP_CURRENT_UTCTIMESTAMP()


Effect

The function TSTMP_CURRENT_UTCTIMESTAMP returns a UTC time stamp in accordance with the POSIX standard. The result has the data type DEC with length 15 and no decimal places.

Notes

  • If the function TSTMP_CURRENT_UTCTIMESTAMP is used more than once within a view, it cannot be guaranteed that the every call within a database access produces the same result. Later calls can produce later time stamps.

Variant 6

... TSTMP_SECONDS_BETWEEN(tstmp1,tstmp2,on_error)


Effect

The function TSTMP_SECONDS_BETWEEN calculates the difference between two specified time stamps, tstmp1 and tstmp2, in seconds. The actual parameter must have the built-in data type DEC with length 15 and no decimal places and contain valid time stamps in the format YYYYMMDDHHMMSS. Any invalid time stamps produce an error. If tstmp2 is greater than tstmp1, the result is positive. In the reverse case, it is negative.

The actual parameter on_error controls error handling. It must have the built-in data type CHAR with the length 10 and must have one of the following values:

  • "FAIL" (an error raises an exception)
  • "NULL" (an error returns the null value)
  • "INITIAL" (an error returns the initial value)

The values are case-sensitive. Any incorrectly specified values raise an exception.

Variant 7

... TSTMP_ADD_SECONDS(tstmp,seconds,on_error)


Effect

The function TSTMP_ADD_SECONDS adds seconds seconds to a time stamp tstmp. The actual parameter tstmp must have the built-in data type DEC with length 15 and no decimal places and contain a valid time stamp in the format YYYYMMDDHHMMSS. An invalid time stamp produces an error. The actual parameter seconds must also have the built-in data type DEC with length 15 and no decimal places. Any negative values are subtracted. If the result is invalid, an error occurs.

The actual parameter on_error controls error handling. The same applies as to the function TSTMP_SECONDS_BETWEEN. The additional value "UNCHANGED" can be used to specify that an error caused the unchanged value of tstmp to be returned.

Example

The following CDS view entity applies time stamp functions in the SELECT list to columns of the DDIC database table DEMO_EXPRESSIONS. The program DEMO_CDS_TIMESTAMP_FUNC_VE uses SELECT to access the view. The column NUM1 of the DDIC database table is given a value that is added to a time stamp in the column TIMESTAMP1 as seconds. The difference is found between this sum and a time stamp retrieved on the database by the function TSTMP_CURRENT_UTCTIMESTAMP. A delay, wait, can be integrated between the time stamp in the ABAP program and the time stamp created on the database.






RFUMSV00 - Advance Return for Tax on Sales/Purchases   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 16684 Date: 20240329 Time: 064113     sap01-206 ( 202 ms )