What does it do? The SQL functions described in variants 1 to 4 convert time stamps into dates or times, and vice versa. The SQL functions described in variants 5 to 10 convert time stamps, dates, and times between different types. The arguments of the functions are specified as a comma-separated list in parentheses. A blank must be placed after the opening parenthesis and in front of the closing parenthesis. The functions have keyword parameters>. Optional parameters can be assigned actual parameters when called. Non-optional parameters must be assigned actual parameters. SQL expressions>, in particular individual columns, type-compliant literals, SQL functions, host variables or host expressions can be specified as actual parameters. The conversions follow the ABAP-specific rules for time zones>. The associated DDIC database tables must be filled correctly.
Latest notes:
The functions described in Variants 5 to 10 have keyword parameters> and all of them have exactly one required parameter. When calling only the required parameter, then it can be handled like a positional parameter>, that means it can be called without the formal parameter name.
These functions move the functions of the ABAP statements CONVERT TIME STAMP>> and CONVERT INTO TIME STAMP>> to the database. NON_V5_HINTS
Use of the functions described in Variants 1 to 4 enforces the ABAP_STRICT_771 strict mode from ABAP_RELEASE ABAP_771 / .
Use of the functions described in Variants 5 to 10 enforces the ABAP_STRICT_778 strict mode from ABAP_RELEASE ABAP_778 / . ABAP_HINT_END
ABAP_VARIANT_1 ... TSTMP_TO_DATS( ... )>
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 for the formal 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 for the optional formal parameter client> must have the built-in dictionary type CLNT>> and contain a valid client ID>. The default value is the current 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 optional parameter on_error> affects how errors are handled. The parameter for on_error> must be an enumerated object> with the enumerated type> ON_ERROR> from the class SQL_TSTMP_TO_DATS>> and the following enumerated constants> can be passed:
SQL_TSTMP_TO_DATS=>FAIL>, an error raises an exception (default)
SQL_TSTMP_TO_DATS=>SET_TO_NULL>, an error returns the null value
ABAP_VARIANT_2 ... TSTMP_TO_TIMS( ... )>
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 parameters tstmp>, tzone>, client>, and on_error> as to the function TSTMP_TO_DATS >. Here, the class of the enumerated type of on_error> is SQL_TSTMP_TO_TIMS> >. The return value has the built-in data type TIMS>>.
ABAP_VARIANT_3 ... TSTMP_TO_DST( ... )>
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 parameters tstmp>, tzone>, client>, and on_error> as to the function TSTMP_TO_DATS >. Here, the class of the enumerated type of on_error> is SQL_TSTMP_TO_DST> >. The return value has the built-in data type CHAR>> with length 1.
ABAP_VARIANT_4 ... DATS_TIMS_TO_TSTMP( ... )>
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 for the formal parameter date> must have the built-in data type DATS>> and should contain a valid date. The actual parameter for the formal parameter time> must have the built-in data type TIMS>> and should contain a valid time. The same applies to the parameters tzone>, client>, and on_error> as to the function TSTMP_TO_DATS>. Here, the class of the enumerated type of on_error> is SQL_DATS_TIMS_TO_TSTMP>>. The return value has the built-in data type DEC>> with length 15 and represents an ABAP-specific time stamp in a packed number>.
ABAP_VARIANT_5 ... TSTMPL_TO_UTCL( ... )>
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 optional parameter on_error> affects how errors are handled: The parameter for on_error> must be an enumerated object> with the enumerated type> ON_ERROR> from the class SQL_TSTMPL_TO_UTCL>> and the following enumerated constants > can be passed:
SQL_TSTMPL_TO_UTCL=>C_ON_ERROR-FAIL>, an error raises an exception (default)
SQL_TSTMPL_TO_UTCL=>C_ON_ERROR-SET_TO_NULL>, an error returns the null value)
SQL_TSTMPL_TO_UTCL=>C_ON_ERROR-SET_TO_INITIAL>, an error returns the initial value The optional parameter on_initial> affects how arguments with initial values are handled: The parameter for on_initial> must be an enumerated object> with the enumerated type> ON_INITIAL> from the class SQL_TSTMPL_FROM_UTCL> > and the following enumerated constants> can be passed:
SQL_TSTMPL_FROM_UTCL=>C_ON_INITIAL-FAIL>, an initial value raises an exception
SQL_TSTMPL_FROM_UTCL=>C_ON_INITIAL-SET_TO_NULL>, an initial value returns the null value
SQL_TSTMPL_FROM_UTCL=>C_ON_INITIAL-SET_TO_INITIAL>, an initial value returns the initial value (default)
ABAP_VARIANT_6 ... TSTMPL_FROM_UTCL( ... )>
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 should contain a valid time stamp. The optional parameter on_null> affects how null values as arguments are handled. The parameter for on_null> must be an enumerated object> with the enumerated type> ON_NULL> from the class SQL_TSTMPL_FROM_UTCL>> and the following enumerated constants > can be passed:
SQL_TSTMPL_FROM_UTCL=>C_ON_NULL-FAIL>, a null value raises an exception
SQL_TSTMPL_FROM_UTCL=>C_ON_NULL-SET_TO_NULL>, a null value returns the null value
SQL_TSTMPL_FROM_UTCL=>C_ON_NULL-SET_TO_INITIAL>, a null value returns the initial value (default)
ABAP_VARIANT_7 ... DATS_TO_DATN( ... )>
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). Here, the class of the enumerated type of on_error> and on_initial > is SQL_DATS_TO_DATN>>.
Latest notes: The same effect of the function DATS_TO_DATN> can be achieved by casting>. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_8 ... DATS_FROM_DATN( ... )>
What does it do? The function DATS_FROM_DATN> converts a date date> 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 date> 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). Here, the class of the enumerated type of on_null> is SQL_DATS_FROM_DATN>>.
Latest notes: The same effect of the function DATS_FROM_DATN> can be achieved by casting>. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_9 ... TIMS_TO_TIMN( ... )>
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). Here, the class of the enumerated type of on_error> is SQL_TIMS_TO_TIMN>>.
Latest notes: The same effect of the function TIMS_TO_TIMN> can be achieved by casting>. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_10 ... TIMS_FROM_TIMN( ... )>
What does it do? The function TIMS_FROM_TIMN> converts a time time> 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 time> 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). Here, the class of the enumerated type of on_null> is SQL_TIMS_FROM_TIMN>>.
Latest notes: The same effect of the function TIMS_FROM_TIMN> can be achieved by casting>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Extracts date, time, and daylight saving time flag of the current UTC time stamp 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 TSTMPL_TO_UTCL > and TSTMPL_FROM_UTCL > convert time stamps between TIMESTAMPL>> and utclong>> format. The conversion functions DATS_TO_DATN> and DATS_FROM_DATN > convert dates between DATS>> and DATN>>. The conversion functions