ABAP - Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - Views → 

ABAP CDS - Client Handling in CDS Views

For a CDS view in ABAP CDS, the CDS annotation @ClientHandling can be used to specify client handling.

Determining Client Dependency

The annotation @ClientHandling.type determines the client dependency of the view. The following values can be specified for the annotation:

#INHERITED

Default value. The client dependency of the view is determined by the data sources used.

#CLIENT_DEPENDENT

The view is client-specific. A prerequisite for this is that at least on of the data sources used in the view is client-specific. If not, a syntax error occurs.

#CLIENT_INDEPENDENT

The view is a cross-client view. A prerequisite for this is that none of the data sources used in the view is client-specific. If not, a syntax error occurs.

Notes

Determining Client Handling

The annotation @ClientHandling.algorithm determines how implicit client handling is performed. The following values can be specified for the annotation:

#AUTOMATED

Default value for the values #INHERITED and #CLIENT_DEPENDENT of the annotation @ClientHandling.type. Cannot be used together with its value #CLIENT_INDEPENDENT.

The value #AUTOMATED expands the joins of the CDS view implicitly as shown in the following table. In the case of outer joins, cross-client sides are made into client-specific sides artificially using cross joins, which avoids NULL values. This applies to joins specified directly using JOIN and to instances of joins created when using CDS path expressions.

Left Side Right Side INNER JOIN LEFT OUTER JOIN RIGHT OUTER JOIN CROSS JOIN
Client-specific Client-specific Compares the client columns in the ON condition Compares the client columns in the ON condition Compares the client columns in the ON condition Transforms the cross join to an inner join using an ON condition for the client column
Cross-client Client-specific - The left side is replaced by a cross join of the cross-client data source with the database table T000 and a comparison of the client columns in the ON condition. - -
Client-specific Cross-client - - The right side is replaced by a cross join of the cross-client data source with the database table T000 and the client columns are compared in the ON condition. -
Cross-client Cross-client - - - -

#SESSION_VARIABLE

Cannot be used together with the value #CLIENT_INDEPENDENT of the annotation @ClientHandling.type.

The value #SESSION_VARIABLE expands the joins of the CDS view implicitly as shown in the following table. This applies to joins specified explicitly using JOIN and to instances of joins created when using CDS path expressions.

Left Side Right Side INNER JOIN LEFT OUTER JOIN RIGHT OUTER JOIN CROSS JOIN
Client-specific Client-specific Compares the client columns in the ON condition Compares the client columns in the ON condition Compares the client columns in the ON condition Transforms the cross join to an inner join using an ON condition for the client column
Cross-client Client-specific - Compares the client column with the value of the session variable $session.client in the ON condition - -
Client-specific Cross-client - - Compares the client column with the value of the session variable $session.client in the ON condition -
Cross-client Cross-client - - - -

In addition, when client-specific data tables are accessed, WHERE clauses with comparisons of the client columns with the session variable $session.client are added to the view implicitly. If only client-specific CDS entities are accessed, however, no clauses are added.

If the session variable $session.client is evaluated in the view, it is not possible to access the data of different clients in a single read. This applies in the following cases:

The addition CLIENT SPECIFIED of the statement SELECT is not allowed in this case. The addition USING CLIENT, on the other hand, is allowed and the client specified here is used implicitly.

#NONE

Default value for the value #CLIENT_INDEPENDENT of the annotation @ClientHandling.type. Cannot be used together with its values INHERITED and #CLIENT_DEPENDENT. No implicit client handling takes place.

Notes

Properties of Client-Specific CDS Views

In Open SQL reads, the client dependency of a CDS view has the following consequences for the CDS entity and the associated CDS database view:

Notes

The last point is particularly important for client handling in general AMDP procedure implementations on the SAP HANA database, which are called like normal methods in ABAP. When a CDS database view is accessed using the addition AMDP OPTIONS CDS SESSION CLIENT, the value of the corresponding HANA session variable CDS_CLIENT must be set explicitly in the declaration of the AMDP method. If not, a syntax check warning and (in the call) an exception of the class CX_AMDP_CDS_CLIENT_MISMATCH is raised. However, in an AMDP function implementation that is used as a CDS table function in Open SQL, the HANA session variable CDS_CLIENT is filled with the content defined there.

Executable Example

CDS Views, Client Handling



Continue
ABAP CDS - Obsolete Client Handling in Views
Example CDS Views, Client Handling
Example CDS Views, Obsolete Client Handling