Ansicht
Dokumentation
ABENAMDP_FUNCTION_METHODS - AMDP FUNCTION METHODS
BAL Application Log Documentation CPI1466 during BackupThis documentation is copyright by SAP AG.
- Function Implementations
An AMDP function implementation is an AMDP method for implementing an AMDP function as a database function. An AMDP function implementation is indicated as an AMDP method in the implementation part of the class using the addition BY DATABASE FUNCTION of the statement METHOD. AMDP table functions and AMDP scalar functions can be implemented.
AMDP Table Functions
There are two types of AMDP table functions:
- Functions that can only be accessed in other AMDP methods
- Functions that implement CDS table functions that can be accessed in
AMDP Table Functions for AMDP Methods
An AMDP function implementation for an AMDP table function that can only be accessed in AMDP methods is declared in an AMDP class like a regular static method or instance method in any visibility section. An AMDP function implementation like this cannot be identified in the declaration part of the class and the same basically applies as to AMDP procedure implementations with the following differences:
- The AMDP function implementation must have a return value defined using RETURNING. The data type of the return value must be tabular with a structured row type whose components are elementary. Any table category and table key can be specified for return value.
- In addition to the return value, the AMDP function implementation can have elementary and tabular input parameters, but no input/output parameters or output parameters. The special input parameter connection is not allowed.
- No class-based exceptions can be declared using RAISING in the interface of the AMDP function implementation.
- In declarations of the AMDP method using the addition AMDP OPTIONS READ-ONLY or in implementations of the AMDP method using the addition OPTIONS READ-ONLY, the AMDP function implementation must be restricted to reads.
- The AMDP function implementation can be called in ABAP like a regular method and cannot be used as a functional method in a functional method call.
The AMDP table function of a AMDP table function can be called from other AMDP methods. It cannot be called in ABAP programs like a regular functional method.
Notes
- Calls from ABAP programs are not implemented since the result set cannot be restricted directly here by a WHERE condition.
- Calls from non-AMDP-managed database procedures or database functions are, like any database table function, possible but not recommended.
AMDP Table Functions for CDS Table Functions
The same applies to an AMDP function implementation that implements an CDS table function as to the AMDP table functions for AMDP methods above, with the following differences:
- An AMDP function implementation for a CDS table function can only be declared in the public visibility section of a static AMDP class. It is not possible in interfaces.
- A special form of the statement CLASS-METHODS with the addition FOR TABLE FUNCTION must be used for the declaration. This form flags the AMDP function implementation as an implementation of a CDS table function.
- The parameter interface of the AMDP function implementation is not declared using the statement CLASS-METHODS. Instead it is generated in accordance with the associated CDS table function using the statement DEFINE TABLE FUNCTION in the ABAP CDS CDS DDL:
- The input parameters in the AMDP function implementation are determined by the input parameters of the CDS table function. Their names are used, and the ABAP types are derived from their Dictionary types. The input parameters are always elementary and not optional.
- A return value with the type of a standard table is created with an empty table key named result with a structured row type. The components of the row type are determined by the elements of the CDS table function. Their names are used, and the ABAP types are derived from their dictionary types. The row type corresponds to the structured data type represented by the CDS table function with respect to ABAP. In the case of a client-dependent CDS table function, the client column is also included.
The AMDP table function defined by an AMDP function implementation like this can be used as follows using the CDS entity represented by the CDS table function:
- as a data source of read statements in ABAP
- as a data source of CDS view entities in the CDS DDL of ABAP CDS.
- as a data source of in the CDS DDL of ABAP CDS.
In addition, calls from other AMDP methods are possible. Calls as regular functional methods are not possible in an ABAP program.
Notes
- The row type of the return value result of an AMDP function implementation for a client-dependent CDS table function does not contain a client field, even though this field must be declared in the element list.
- An AMDP function implementation can only be linked with a single CDS table function.
- When an AMDP function implementation is created for a CDS table function, it must already exist as an active function. When a new CDS table function is activated, an empty AMDP table function is created in the database. This function raises an exception if a non-AMDP access is performed. When the CDS table function is accessed by the ABAP runtime framework for the first time (for example, using ), the AMDP function implementation implements the empty AMDP table function. Other frameworks that evaluate CDS entities using their annotations, however, can also cause the AMDP table function to be implemented. It is possible to access the table function in a native way only after the implementation.
- Calls from non-AMDP-managed database procedures or database functions are, like any database table function, possible but not recommended.
AMDP Scalar Functions
An AMDP is declared in an AMDP class like a regular static method or instance method in any visibility section. An AMDP function implementation like this cannot be identified as such in the declaration part of the class and the same basically applies as to AMDP table functions for AMDP methods with the following differences:
- The data type of the return value is elementary.
- The data types of input parameters must also be elementary.
- No class-based exceptions can be declared using RAISING in the interface of the AMDP function implementation for AMDP scalar functions.
- An AMDP scalar function can be called in ABAP like a regular method and can be used as a functional method in a functional method call.
The AMDP scalar function defined using an AMDP function implementation like this can be used in other AMDP methods in accordance with the rules for scalar functions.
Notes
- These functions can be used in non-AMDP-managed database procedures or database functions, like any database scalar function, but this is not recommended.
- It is possible for an AMD scalar function to specify the database-specific option DETERMINISTIC after OPTIONS. This buffers the result of the function for the duration of a query.
Vendor Master (General Section) PERFORM Short Reference
This documentation is copyright by SAP AG.
Length: 14311 Date: 20240425 Time: 114640 sap01-206 ( 182 ms )