Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  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 →  ABAP SQL - Special Functions →  ABAP SQL - Date Functions and Time Functions 

sql_exp - Time Zone Functions

Other versions: 7.31 | 7.40 | 7.54

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-specific 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 before 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 or host expressions can be specified as actual parameters. Only enumeration 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.


Note

When used, these functions require the strict mode from 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 defines the way 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 enumeration 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)


Note

The system time zone returned is the client-specific content of column TZONESYS in 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 predefined type CHAR with length 12. The default value is the user name of the current 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 defines the way 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 enumeration 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)


Note

For the current client, the returned user time zone corresponds with 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 program 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 @DATA(result).

Example

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