SAP HANA SESSION VARIABLES



Get Example source ABAP code based on a different SAP table
  


• CLIENT ABAP_HANA_SESSION_VAR
• CDS_CLIENT ABAP_HANA_SESSION_VAR
• APPLICATIONUSER ABAP_HANA_SESSION_VAR
• LOCALE_SAP ABAP_HANA_SESSION_VAR
• SAP_SYSTEM_DATE ABAP_HANA_SESSION_VAR

ABAP-Specific Session Variables in SAP HANA
Session variables are global variables in the SAP HANA database. They can be read there with the built-in function SESSION_CONTEXT and given a value using the statement SET 'VAR' = :value; (SAP HANA Platform SPS12 and higher). Session variables contain global information about the current context and are hence similar to ABAP system fields . In particular, their value should only be changed in exceptional application logic cases, for example, in SQLScript.
When a SAP HANA database is used as the standard AS ABAP database, the following session variables are filled with ABAP-specific values in ABAP reads:
CLIENT contains the current client in accordance with the nominal value of the ABAP system field sy-mandt.
CDS_CLIENT like CLIENT but with the following differences:
CDS_CLIENT is set to the specified value when the database is accessed with an AB-SQL statement with the addition USING CLIENT.
During an AMDP method call from ABAP, where the addition AMDP OPTIONS CDS SESSION CLIENT is specified in the declaration, CDS_CLIENT is set to the value specified there.
APPLICATIONUSER contains the current user name in accordance with the nominal value of the ABAP system field sy-uname.
LOCALE_SAP contains the text environment language of the current ABAP_ISESS in accordance with the nominal value of the ABAP system field sy-langu.
SAP_SYSTEM_DATE contains the current system date of the AS ABAP in accordance with the nominal value of ABAP system field sy-datum.



Latest notes:

The ABAP-specific session variables can be read, for example, in AMDP methods and make the corresponding input parameters superfluous. Such a method should only be called up from ABAP programs. Otherwise, it cannot be guaranteed that the variables will be provided with the correct values. However, writes to session variables with the SQLScript statement SET are not allowed in AMDP methods.
In the CDS DDL of the ABAP CDS, the syntax $session.vname can be used in the definition of a CDS view entity or a ABAP_CDS_V1_VIEW to access the ABAP-specific session variables. The name vname is then different from the name shown here. The CDS session variable client accesses CDS_CLIENT, not CLIENT. When a CDS view is accessed using AB_SQL , the session variables are available on all supported database platforms and not just on the SAP HANA database.
In ABAP reads, regardless of whether they are in AB-SQL , Native SQL, or AMDP, the session variable LOCALE_SAP contains the current value of the text environment language , which can be set by the statement SET LOCALE LANGUAGE .
ABAP_HINT_END



Example ABAP Coding

Reading of the session variable APPLICATIONUSER using ADBC.
ABEXA 01047
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example SAP HANA, ABAP-Specific Session Variables shows different ways of accessing the session variables specified here.
ABAP_EXAMPLE_END