Ansicht
Dokumentation

ABENCDS_SESSION_VAR_APPLICATION_V2 - CDS SESSION VAR APPLICATION V2

ABENCDS_SESSION_VAR_APPLICATION_V2 - CDS SESSION VAR APPLICATION V2

RFUMSV00 - Advance Return for Tax on Sales/Purchases   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

- CDS View Entity, Application Session Variables

... $session.vname ...

Effect

Specifies an application session variable vname in an operand position in a SELECT statement of a CDS view entity. The variable must be prefixed by $session..

Application session variables are required for specific applications and they can be set by dedicated system programs using a special system class. The following application session variables exist:

vname Value when accessed
bs_instance_id Instance ID of the current business service instance. The returned value has the data type SSTRING.
bs_zone_id Zone ID of the current business service instance. The returned value has the data type SSTRING.

A CDS view entity that accesses an application session variable must be usable as replacement object. That implies that the respective CDS view entity must not have any input parameters.

Notes

  • From a technical perspective, session variables indicate global variables of the current database. Application session variables are set to their value by dedicated system programs using a special system class. Like ABAP system fields, they are changeable from an ABAP program. However, they should not be changed in application programs. They should only be used for reads. Otherwise, important information for further program execution may be lost.
  • The annotation environment.systemField is relevant for built-in session variables, but not for application session variables.
  • In existing CDS view entities without corresponding input parameters, session variables can be passed to the input parameters of CDS view entities or CDS table functions used there.
  • Application session variables are supported only in CDS view entities. However, it is possible to build a CDS DDIC-based view on top of a CDS view entity with application session variables. The information is passed on to the CDS DDIC-based view in this case.

  • CDS view entities with application session variables cannot be used in AMDP, since AMDP does not support application session variables.
  • The ADT function Data Preview does not work for CDS view entities with application session variables.

Example

The following CDS view entity contains the application session variable bs_instance_id in its SELECT list. The following program sets a value for this session variable, using the ABAP class CL_OSQL_EXTERNAL_CONTEXT The class must be used within a procedure, otherwise an exception occurs.

This program demonstrates the setting of application session variables for system internal purposes. You should not set or overwrite application session variables as shown in the example in application programs, since important information for further program execution may be lost.






BAL_S_LOG - Application Log: Log header data   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 4944 Date: 20240512 Time: 110441     sap01-206 ( 60 ms )