Ansicht
Dokumentation

ABENCDS_FUNC_CLIENT_HANDLING - CDS FUNC CLIENT HANDLING

ABENCDS_FUNC_CLIENT_HANDLING - CDS FUNC CLIENT HANDLING

BAL_S_LOG - Application Log: Log header data   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

- Client Handling in CDS Table Functions

The CDS annotation @ClientHandling.type can be used to enable and disable client dependency for a CDS table function in ABAP CDS.

  • The value #CLIENT_DEPENDENT enables client dependency.
  • The value #CLIENT_INDEPENDENT disables client dependency.

Client dependency is enabled by default. The client dependency of a CDS table function has the following consequences for the CDS entity and the associated AMDP function implementation:

  • Client-Dependent CDS Table Function
  • The element list of a client-dependent CDS table function must have an explicit client field with the built-in dictionary type CLNT as its first element. The client field is a column of the tabular return value of the associated AMDP function implementation and is not a component of the structured data type represented by the CDS entity.

  • When a client-dependent CDS table function is accessed using SELECT without the obsolete addition CLIENT SPECIFIED, only those rows are selected implicitly from the result set of the function that contain the ID of the current client or the client specified in the addition USING CLIENT in the client field.

  • A CDS table function is always implemented in the associated AMDP method in platform-dependent SQL. The implementation must ensure that all required data is made available. Particularly in the ON conditions of joins, client columns must be used correctly.

  • For performance reasons, it is best to restrict the result set of the function to the required clients at the implementation stage. This usually involves passing the client ID in question to an input parameter of the function. Here, it is advisable to use an input parameter of the dictionary type CLNT, which needs to be annotated with the annotation @Environment.systemField and the predefined value #CLIENT. In this case, SELECT passes the correct client ID implicitly.

  • If the obsolete addition CLIENT SPECIFIED is specified, the column is added to the result set and is filled with the associated client ID for each row. Before this column can be used in the SELECT statement, a name must be assigned to it after the addition CLIENT SPECIFIED. If the name is not defined, no addressing is possible in a clause and no inline declarations can be made using @DATA$|@FINAL(...) after INTO. The defined name is also used in the case of INTO CORRESPONDING. If no name is defined, the client column is not transported.

  • Client-Independent CDS Table Function
  • The element list of a client-independent CDS table function does not need to have an explicit client field with the built-in dictionary type CLNT. If the first element has the type CLNT, it does not function as a client field. Instead, it is a column of the tabular return value of the associated AMDP function implementation and also a regular component of the structured data type represented by the CDS entity.

  • When a client-independent CDS table function is accessed using SELECT, an element of the type CLNT does not have a special meaning and is handled like any other element.

Notes

  • CDS table functions for application data should usually be client-dependent.
  • The annotation @ClientHandling.type with the values #CLIENT_DEPENDENT and #CLIENT_INDEPENDENT replaces the annotation @ClientDependent with the values true and false and should be used instead of this annotation.

Example

The following client-dependent CDS table function reads the ABAP-specific session variables CLIENT and CDS_CLIENT. The first element mandt of the element list is the client field. The other two elements return the read values. An input parameter clnt with the built-in dictionary type CLNT transfers the client ID and, as prescribed, is given the annotation @Environment.systemField:#CLIENT.

The AMDP function implementation is as follows:

The first line of a local table client_tab with the type of the tabular return value is supplied with the session variables. The client field is set to the value of the input parameter clnt and the table is returned. The program DEMO_AMDP_CLIENT_VARIABLES accesses the CDS table function using SELECT and the addition USING CLIENT, and attempts to use a client ID other than that of the current client in the table T000. The client ID specified with USING CLIENT is passed implicitly to the input parameter clnt and fills the client field of the return value with this ID, so that it is respected by implicit client handling. If a client ID other than that of the current client is used, the values of the session variables CLIENT and CDS_CLIENT are different.






rdisp/max_wprun_time - Maximum work process run time   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 9882 Date: 20240423 Time: 140205     sap01-206 ( 137 ms )