ABAP - Keyword Documentation →  ABAP - Programming Language →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Expressions sql_exp →  sql_exp - sql_func →  ABAP SQL - Built-In Functions sql_func →  sql_func - Special Functions →  sql_func - Date Functions and Time Functions → 
Mail Feedback

sql_func - Time Zone Functions

Syntax

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


Variants:

1. ... ABAP_SYSTEM_TIMEZONE( ... )

2. ... ABAP_USER_TIMEZONE( ... )

Effect

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.

Hint

The use of these functions enforces the strict mode from ABAP release 7.53.

Variant 1  

... ABAP_SYSTEM_TIMEZONE( ... )


Effect

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:

Hint

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

Variant 2  

... ABAP_USER_TIMEZONE( ... )


Effect

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:

Hint

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

Example

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.

SELECT SINGLE
       FROM demo_expressions
       FIELDS
         abap_system_timezone(
           client   = @sy-mandt,
           on_error = @sql_abap_system_timezone=>set_to_null )
             AS system_tz,
         abap_user_timezone(
           user     = @sy-uname,
           client   = @sy-mandt,
           on_error = @sql_abap_user_timezone=>set_to_null )
             AS user_tz
       INTO @FINAL(result).

Example

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