Get Example source ABAP code based on a different SAP table
• FOR SCALAR FUNCTION CLASS-METHODS ID METHODS-FOR-SCALAR-FUNCTION
CLASS-METHODS>, FOR SCALAR FUNCTION> Short Reference >
ABAP_SYNTAX CLASS-METHODS meth FOR SCALAR FUNCTION cds_scalar_func.>
What does it do? This statement declares the static method > meth> as an AMDP function implementation> that implements a CDS scalar function cds_scalar_func> as an AMDP scalar function>. This statement can only be specified in the public> visibility section> of an AMDP class> and not in an interface. The method must be implemented using the addition BY DATABASE FUNCTION>> of the statement METHOD>. cds_scalar_func> expects a CDS scalar function> defined using the statement DEFINE SCALAR FUNCTION >> in the ABAP CDS> CDS DDL >. This function must have a CDS scalar function implementation reference> of type SQL> and the current class as well as the method meth> must be specified in the field AMDP Reference> of the CDS scalar function implementation reference>. No other additions are possible. The interface parameters of the AMDP function implementation are derived from the CDS scalar function definition> as follows:
The input parameters of the CDS scalar function are generated as mandatory input parameters of the AMDP function implementation. The names are copied, and the ABAP types are derived from the specified types.
The return value of the CDS scalar function is generated as return value. It has the data type specified in the CDS scalar function definition. The name of this return variable is result >. This name is not part of the method signature. Client-handling has not yet been implemented for CDS scalar functions and therefore, only client-independent objects can be accessed in the AMDP method that implements the scalar function.