SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL for Data Definitions → ABAP CDS - DEFINE VIEW → ABAP CDS - SELECT → ABAP CDS - SELECT, Operands and Expressions →ABAP CDS - session_variable
Syntax
... $session.vname ...
Effect
Specifies a session variable vname in an operand position in a SELECT statement of a CDS view. The variable is case-sensitive. $session.vname, $Session.Vname, and $SESSION.VNAME can all be used. No other spellings are allowed.
Session variables have a predefined name and are set to a predefined value when the CDS view is used in Open SQL. This also applies to CDS views that are used as data sources in other CDS views. The following session variables exist:
vname | Value in Open SQL Accesses |
user | Current user name, nominal value of the ABAP system field sy-uname |
client | Current client. The default value is the nominal value of the ABAP system field sy-mandt. In reads with an Open SQL statement (with the statement USING CLIENT) and in calls of an AMDP method from ABAP (in whose declaration the addition AMDP OPTIONS CDS SESSION CLIENT is specified), the value specified here. |
system_language | Text environment language of the current internal session, nominal value of the ABAP system field sy-langu |
system_date | Current system date of the AS ABAP, nominal value of the ABAP system field sy-datum |
Notes
Example
The following CDS view contains the possible session variables in the SELECT list. The program DEMO_CDS_SESSION_VARIABLES uses Open SQL to access the view and fills the session variables with the associated values. Here, it is possible to define whether USING CLIENT is used or not.
Example
The following CDS view DEMO_CDS_SELECT_T100 accesses a further CDS view DEMO_CDS_SELECT_T100_LANGU with a language input parameter to which the annotation environment.systemField with the value system_language is assigned. Unlike in Open SQL, there is no implicit pass of the actual parameter to the input parameter here and the corresponding session variable $session.system_language is passed instead. The program DEMO_CDS_T100 uses Open SQL to access both views and the result is identical. When DEMO_CDS_SELECT_T100_LANGU is accessed, the value of the system field sy-langu is passed implicitly to the input parameter. When DEMO_CDS_SELECT_T100 is accessed, the session variable $session.system_language is filled with this value.