Get Example source ABAP code based on a different SAP table
ABAP_AMDP - 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. ITOC
AMDP Table Functions There are the following 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 AB_SQL
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. BEGIN_SECTION VERSION 5 OUT
The AMDP function implementation must be restricted to reads 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>>, END_SECTION VERSION 5 OUT
The AMDP function implementation cannot 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.
Latest notes:
Calls from ABAP programs are not possible since the result set cannot be restricted using a WHERE> condition. NON_V5_HINTS
Calls from non-AMDP-managed database procedures or database functions are possible - like for any database table function> - but not recommended>. ABAP_HINT_END
AMDP Table Functions for CDS Table Functions The same rules apply to an AMDP function implementation that implements an CDS table function> as to the AMDP table functions for AMDP methods (described 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 addition 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. 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 AB-SQL read statements in ABAP.