SAP SQL TIMEZONE FUNC



Get Example source ABAP code based on a different SAP table
  


• ABAP_SYSTEM_TIMEZONE ABAP_OSQL_FUNC
• ABAP_USER_TIMEZONE ABAP_OSQL_FUNC

ABAP_SQLFUNC - Time Zone Functions

ABAP_SYNTAX
... ABAP_SYSTEM_TIMEZONE( $[client = client$]$[,
on_error = on_error$] )
$| ABAP_USER_TIMEZONE( $[user = user $]$[,
client = client$]$[,
on_error = on_error$] ) ...

ABAP_VARIANTS:
1 ... ABAP_SYSTEM_TIMEZONE( ... )
2 ... ABAP_USER_TIMEZONE( ... )

What does it do?
These SQL functions return the client-dependent system time zone and the user-dependent user time zone of the current AS ABAP.
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 optional keyword parameters to which actual parameters can be assigned when called.
SQL expressions, in particular individual columns, literals, SQL functions, host variables or host expressions can be specified as actual parameters. Only enumerated constants of specific classes can be passed to the parameter on_error. If an actual parameter contains the null value, every function returns a null value.



Latest notes:

NON_V5_HINTS
The use of these functions enforces the ABAP_STRICT_772 strict mode from ABAP_RELEASE ABAP_772 / .
ABAP_HINT_END

ABAP_VARIANT_1 ... ABAP_SYSTEM_TIMEZONE( ... )

What does it do?
The function ABAP_SYSTEM_TIMEZONE returns the system time zone of the AS ABAP for the client passed to client. 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.
The result has the type CHAR with the length 6. If the system time zone cannot be detected, an error occurs.
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_ABAP_SYSTEM_TIMEZONE and the following enumerated constants can be passed:
SQL_ABAP_SYSTEM_TIMEZONE=>FAIL, an error raises an exception (default)
SQL_ABAP_SYSTEM_TIMEZONE=>SET_TO_NULL, an error returns the null value



Latest notes:

The system time zone returned is the client-dependent content of column TZONESYS in DDIC database table TTZCU.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_2 ... ABAP_USER_TIMEZONE( ... )

What does it do?
The function ABAP_USER_TIMEZONE returns the user time zone of AS ABAP for the user name passed to user and the client passed to client.
The actual parameter for the optional formal parameter user must have the built-in type CHAR with length 12. The default value is the user name of the current ABAP user. The same applies to the parameter client as to the function ABAP_SYSTEM_TIMEZONE.
The result has the type CHAR with the length 6. If the user time zone cannot be detected, an error occurs.
The optional parameter on_error affects how errors are handled. The actual parameter for on_error must be an enumerated object with the enumerated type ON_ERROR from the class SQL_ABAP_USER_TIMEZONE and the following enumerated constants can be passed:
SQL_ABAP_USER_TIMEZONE=>FAIL, an error raises an exception (default)
SQL_ABAP_USER_TIMEZONE=>SET_TO_NULL, an error returns the null value



Latest notes:

For the current client, the returned user time zone corresponds to the content of system field sy-zonlo in ABAP.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following SELECT statement returns the values for system time zone and user time zone that were read with the ABAP_SYSTEM_TIMEZONE and ABAP_USER_TIMEZONE functions for the current client and current user. The optional parameters client and user are filled explicitly with host variables. The system fields contain the default values and could be omitted if required. The class CL_DEMO_SQL_TIMEZONE_FUNCTIONS executes the statement and displays the result.
ABEXA 01287
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The example for date/time conversions uses the function ABAP_SYSTEM_TIMEZONE without parameters being specified explicitly.
ABAP_EXAMPLE_END