An AMDP function implementation is an AMDP method for implementing an AMDP function as a
table 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 functions can be defined that can be accessed only in other AMDP methods and functions defined that implement
CDS table functions.
An AMDP function implementation whose AMDP function can 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 detected in the declaration part of the class and the same basically applies as to
AMDP procedure implementations with the following differences:
An 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.
Alongside the return value, an AMDP function implementation can have only elementary
input parameters and must not have any
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 an 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, any AMDP function implementations must be restricted to reads.
An AMDP function defined
using a AMDP function implementation like this can only be called in other AMDP methods and not in database procedures managed in AMDP or in database functions like database
table functions.
The same applies to an AMDP function implementation that implements a
CDS table function as to the function implementation above, with the following differences:
An AMDP function implementation for a CDS table function can only be declared in the
publicvisibility 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 an 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 CDSCDS 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 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, which the CDS table function represents with respect to ABAP. In the case of a client-specific CDS table function, the client column is also included.
The AMDP 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 Open SQL read statements in ABAP
Furthermore, the same uses as in the preceding function implementation are possible in other AMDP methods or other database procedures or database functions
Notes
The row type of the return value result of an AMDP function implementation
for a client-specific 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 associated 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 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 environment for the first time (for example, using Open SQL), the AMDP function implementation implements the empty AMDP function. Other frameworks that evaluate CDS entities using their
annotations, however,
can also cause the AMDP function to be implemented. It is possible to access the table function in a native way only after the implementation.