What does it do? In a CDS view entity, these functions perform conversions between date, time, and time stamp formats. The functions have positional parameters to which actual parameters need to be assigned when called. There are currently no optional parameters. Suitable fields of a data source, literals, parameters, path expressions, built-in functions, SQL-based scalar functions, expressions, or reuse expressions using $projection can all be specified as actual parameters. Only literals can be passed to the parameters on_error , on_initial, and on_null. If an actual parameter contains the null value, every function returns a null value. The conversions follow the ABAP-specific rules for time zones. The associated DDIC database tables must be filled correctly.
Latest notes:
These functions move the functions of the ABAP statements CONVERT TIME STAMP and CONVERT INTO TIME STAMP to the database.
Typed literals are available for date, time, and time stamp data types. With typed literals, all parameter positions can be filled with literals. NON_V5_HINTS
To carry out conversions that are not yet supported by built-in CDS conversion functions, an option is to use the respective HANA functions in AMDP or Native SQL. ABAP_HINT_END
What does it do? The function TSTMP_TO_DATS extracts the local date for the time zone specified in tzone from a time stamp in the argument 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. tzone expects an actual parameter of the type CHAR with length 6, either initial or containing a valid time zone. If an initial time zone is specified, no time shift is calculated. The actual parameter clnt must have the built-in dictionary type CLNT and must contain a valid client ID. This client ID is used in the evaluation of the system tables of the rules for time zones. The return value has the built-in data type DATS. 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 pattern is case-sensitive. Any incorrectly specified values raise an exception.
What does it do? The function TSTMP_TO_TIMS extracts the local time for the time zone specified in tzone from a time stamp in the argument tstmp. The same applies to the actual parameters tstmp, tzone, clnt, and on_error as to the function TSTMP_TO_DATS . The return value has the built-in data type TIMS.
What does it do? The function TSTMP_TO_DST extracts the daylight saving time marker for the time zone specified in tzone from a time stamp in the argument tstmp. This is X if the time stamp for the time zone is in the daylight saving time, otherwise it is initial. The same applies to the actual parameters tstmp, tzone, clnt, and on_error as to the function TSTMP_TO_DATS . The return value has the built-in data type CHAR with length 1.
What does it do? The function DATS_TIMS_TO_TSTMP constructs a time stamp from a local date specified in date and a local time specified in time in the time zone specified in tzone. The daylight saving time is respected implicitly. The actual parameter date must have the built-in data type DATS and should contain a valid date. The actual parameter time must have the built-in data type TIMS and should contain a valid time. The same applies to the actual parameters tzone, clnt , and on_error as to the function TSTMP_TO_DATS. The return value has the built-in data type DEC with length 15 and represents an ABAP-specific time stamp in a packed number.
What does it do? The function TSTMPL_TO_UTCL converts a time stamp tstmpl from the ABAP Dictionary type TIMESTAMPL to the built-in dictionary type UTCLONG. The actual parameter for the formal parameter tstmpl must have the built-in data type DEC with length 21 and 7 decimal places and contain a valid time stamp in the format YYYYMMDDHHMMSSMMMUUUN. The same applies to the actual parameter on_error as to the function TSTMP_TO_DATS. The actual parameter on_initial defines the way arguments with initial values are handled. It must have the built-in data type CHAR with the length 10 and must have one of the following values:
FAIL (an initial value raises an exception)
NULL (an initial value returns the null value)
INITIAL (an initial value returns the initial value) The pattern is case-sensitive. Any incorrectly specified values raise an exception.
Latest notes: The function TSTMPL_TO_UTCL is a purely technical type conversion and does not involve any time zone calculations. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_6 ... TSTMPL_FROM_UTCL(utcl,on_null)
What does it do? The function TSTMPL_FROM_UTCL converts a time stamp utcl from the built-in dictionary type UTCLONG to the ABAP Dictionary type TIMESTAMPL. It is the counterpart to variant 5. The actual parameter for the formal parameter utcl must have the built-in data type UTCLONG and it should contain a valid time stamp. The actual parameter on_null defines the way null values as arguments are handled. It must have the built-in data type CHAR with the length 10 and must have one of the following values:
FAIL (a null value raises an exception)
NULL (a null value returns the null value)
INITIAL (a null value returns the initial value) The pattern is case-sensitive. Any incorrectly specified values raise an exception. If the parameter utcl is initial, 0 is returned.
Latest notes: The function TSTMPL_FROM_UTCL is a purely technical type conversion and does not involve any time zone calculations. NON_V5_HINTS ABAP_HINT_END
What does it do? The function DATS_TO_DATN converts a date dats from the built-in ABAP Dictionary data type DATS to the built-in ABAP Dictionary type DATN. The actual parameter for the formal parameter dats must have the built-in data type DATS and should contain a valid date in the format YYYYMMDD. The same applies to the actual parameters on_error and on_initial as to the function TSTMPL_TO_UTCL (variant 5, see above).
Latest notes: DATN is a newer dictionary type which represents a real date type in a database. DATS, by contrast, is an older dictionary type. It is instantiated on a database as a character-like field. DATS and DATN are not interchangeable and a conversion is necessary to use certain functions. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_8 ... DATS_FROM_DATN(datn,on_null)
What does it do? The function DATS_FROM_DATN converts a date datn from the built-in ABAP Dictionary data type DATN to the built-in ABAP Dictionary type DATS. It is the counterpart to variant 7. The actual parameter for the formal parameter datn must have the built-in data type DATN and must contain a valid date in the format YYYYMMDD. The same applies to the actual parameter on_null as to the function TSTMPL_FROM_UTCL (variant 6, see above).
Latest notes: DATN is a newer dictionary type which represents a real date type in a database. DATS, by contrast, is an older dictionary type. It is instantiated on a database as a character-like field. DATS and DATN are not interchangeable and to use certain functions, a conversion is necessary. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_9 ... TIMS_TO_TIMN(tims,on_error)
What does it do? The function TIMS_TO_TIMN converts a time tims from the ABAP Dictionary type TIMS to the ABAP Dictionary type TIMN. The actual parameter for the formal parameter tims must have the built-in data type TIMS and contain a valid time in the format HHMMSS. The same applies to the actual parameter on_error as to the function TSTMP_TO_DATS (variant 1, see above).
Latest notes: TIMN is a newer dictionary type which represents a real date type in a database. TIMS, by contrast, is an older dictionary type. It is instantiated on a database as a character-like field. TIMS and TIMN are not interchangeable and to use certain functions, a conversion is necessary. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_10 ... TIMS_FROM_TIMN(timn,on_null)
What does it do? The function TIMS_FROM_TIMN converts a time timn from the ABAP Dictionary type TIMN to the ABAP Dictionary type TIMS. It is the counterpart to variant 9. The actual parameter for the formal parameter timn must have the built-in data type TIMN and contain a valid time in the format HHMMSS. The same applies to the actual parameter on_null as to the function TSTMPL_FROM_UTCL (variant 6, see above).
Latest notes: TIMN is a newer dictionary type which represents a real date type in a database. TIMS, by contrast, is an older dictionary type. It is instantiated on a database as a character-like field. TIMS and TIMN are not interchangeable and to use certain functions, a conversion is necessary. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 In the following CDS view entity, the date, the time, and the daylight saving time marker of the current UTC time stamp are extracted using the conversion functions TSTMP_TO_DATS, TSTMP_TO_TIMS, and TSTMP_TO_DST. The values of the columns DATS1 and TIMS1 of the DDIC database table DEMO_EXPRESSIONS are combined into a time stamp by the conversion function DATS_TIMS_TO_TSTMP. The conversion functions described in variants 5 to 10 convert time stamps, dates, and times between different types. The class CL_DEMO_CDS_DATE_TIME_VE accesses the view and displays the result. DDLS DEMO_CDS_DATE_TIME_VE ABAP_EXAMPLE_END