We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
[CLASS-]METHODS meth ... AMDP OPTIONS $[READ-ONLY$]
$[CDS SESSION CLIENT clnt$|CURRENT$] ...
1. ... READ-ONLY
2. ... CDS SESSION CLIENT clnt$|CURRENT
The addition AMDP OPTIONS for METHODS and CLASS-METHODS statements can be used to declare properties of AMDP methods of global classes or interfaces. After AMDP OPTIONS, at least one property must be specified.
If the addition AMDP OPTIONS is used in the declaration of a method, but the method is implemented as a regular ABAP method without the addition BY DATABASE PROCEDURE|FUNCTION, the properties specified by AMDP OPTIONS are ignored. However, the following restrictions for AMDP methods apply to the method declaration:
A prerequisite for using this addition is that the global class or the interface must contain a
tag interface
IF_AMDP_MARKER_... for
AMDP classes. AMDP OPTIONS cannot be used in local classes, for the
constructors
constructor or class_constructor, for
event handlers declared with FOR EVENT, for
redefinitions declared with REDEFINITION, or for
AMDP function implementations for
CDS table
functions declared with FOR TABLE FUNCTION.
... READ-ONLY
If the option READ-ONLY is specified, only reads of database tables are allowed in the implementation of the database procedure or database function. Only database procedures or database functions of other AMDP methods that are also marked as READ-ONLY can be called. This is checked during the syntax check or at runtime.
This property can also be specified using the addition OPTIONS in the implementation of an AMDP method with METHOD meth BY DATABASE PROCEDURE|FUNCTION. It applies when specified either in the declaration or in the implementation of the method, or in both places.
The option READ-ONLY must be specified at least once in the implementation of an
AMDP function or an
L procedure. If the addition AMDP
OPTIONS is used in the declaration of a method with a RETURNING parameter, the option READ-ONLY must already be specified in the declaration.
... CDS SESSION CLIENT clnt$|CURRENT
If the option CDS SESSION CLIENT is used, the session variable of the database that can be addressed in the CDS DDL of the ABAP CDS under the name $session.client (CDS view entity, ) is supplied with a value when the AMDP method is called from ABAP. On the SAP HANA database this is the ABAP-specific session variable CDS_CLIENT. The value is determined as follows:
The session variable is only set when the AMDP method is called from ABAP. If the associated database procedure or function is called from another AMDP method or from a database procedure or function that is not managed by AMDP, the session variable is not affected.
If the database procedure or function of an AMDP method that is declared with the option CDS SESSION CLIENT is called from an AMDP procedure or function implementation or during a SELECT statement, the following rules apply:
A call can occur during a SELECT statement if it directly or indirectly accesses a CDS table function, because this is implemented as an AMDP table function.
If an AMDP method accesses the CDS-managed DDIC view of a , whose client handling is defined by the annotation @ClientHandling.algorithm: #SESSION_VARIABLE, it must be declared with the option CDS SESSION CLIENT. If not, a syntax error occurs.
The following implementation of an AMDP method accesses the CDS-managed DDIC view DEMO_CDS_PRJCT0A of a client-dependent :
The DDL source code used to define the actual CDS entity DEMO_CDS_SPFLI_CLIENT_0A is as follows:
Client handling is defined using the annotation @ClientHandling.algorithm: #SESSION_VARIABLE. For this reason, the version of the view in the database contains the following WHERE condition (in this case for the SAP HANA database):
WHERE ( "SPFLI"."MANDT" = SESSION_CONTEXT( 'CDS_CLIENT') )
This WHERE condition applies each time the view is accessed. If the SELECT statement in the above AMDP method had its own WHERE condition for the client column MANDT and this would select a client other than the session variable CDS_CLIENT, the result set would be empty. For this reason, accessing such a CDS-managed DDIC view in an AMDP method causes a syntax check warning by default. This warning can be bypassed using the addition AMDP OPTIONS CDS SESSION CLIENT when declaring the method in the class CL_DEMO_AMDP_SESSION_CLIENT:
CLASS cl_demo_amdp_session_client DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
TYPES t_connections TYPE STANDARD TABLE OF demo_cds_prjct0a
WITH EMPTY KEY.
METHODS get_spfli_view
AMDP OPTIONS READ-ONLY
CDS SESSION CLIENT clnt
IMPORTING VALUE(clnt) TYPE sy-mandt
EXPORTING VALUE(connections) TYPE t_connections
RAISING cx_amdp_error.
When the method is called from ABAP, the session variable CDS_CLIENT is set to the value passed to the input parameter clnt. The program DEMO_AMDP_SESSION_CLIENT calls the AMDP method and it is possible to enter different values for the client ID. The data of the relevant client is selected.
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki