SAP CDS TIMEZONE FUNCTIONS V2



Get Example source ABAP code based on a different SAP table
  


• ABAP_SYSTEM_TIMEZONE ABAP_CDS_FUNCTION
• ABAP_USER_TIMEZONE ABAP_CDS_FUNCTION

ABAP_CDS_DDL - CDS View Entity, Time Zone Functions

ABAP_SYNTAX
... ABAP_SYSTEM_TIMEZONE(clnt,on_error)
$| ABAP_USER_TIMEZONE(user,clnt,on_error) ...

ABAP_VARIANTS:
1 ... ABAP_SYSTEM_TIMEZONE(clnt,on_error)
2 ... ABAP_USER_TIMEZONE(user,clnt,on_error)

What does it do?
In a CDS view entity, these functions return the client-dependent system time zone and the user-dependent user time zone of the current AS ABAP. The functions have positional parameters to which actual parameters must 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 parameter on_error. If an actual parameter contains the null value, every function returns a null value.



Latest notes:

For user time zone, there is also the session variable user_timezone available. It returns the same result as the built-in function ABAP_USER_TIMEZONE.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_1 ... ABAP_SYSTEM_TIMEZONE(clnt,on_error)

What does it do?
The function ABAP_SYSTEM_TIMEZONE returns the system time zone of the AS ABAP for the client specified with clnt. The actual parameter clnt must have the built-in dictionary type CLNT and must contain a valid client ID. The result has the CHAR type with a length of 6. If the system time zone cannot be determined, an error is raised.
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 values are case-sensitive. Any incorrectly specified values raise an exception.



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(user,clnt,on_error)

What does it do?
The function ABAP_USER_TIMEZONE returns the user time zone of the AS ABAP for the ABAP user specified with user and the client specified with clnt. The actual parameter user must have the built-in type CHAR. The same applies to the actual parameter clnt as to function ABAP_SYSTEM_TIMEZONE. The result has the CHAR type with a length of 6. If the user time zone cannot be determined, an error is raised.
The actual parameter on_error controls error handling and the same applies as in function ABAP_SYSTEM_TIMEZONE.



Latest notes:

For the current client, the returned user time zone corresponds with 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 actual parameters of the functions are supplied with suitable session variables. The class CL_DEMO_CDS_TIMEZONE_FUNC_VE accesses the view, compares the CDS values with the corresponding ABAP values, and returns the result.
DDLS DEMO_CDS_TIMEZONE_FUNC_VE
ABAP_EXAMPLE_END