SAP AMDP FUNCTIONS ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_AMDP - AMDP Functions
This example demonstrates AMDP functions and how they are used.

ABAP_SOURCE_CODE
DEMO CL_DEMO_AMDP_FUNCTIONS_DEMO

ABAP_DESCRIPTION
This example accesses AMDP functions that are declared and implemented in the AMDP class CL_DEMO_AMDP_FUNCTIONS_INPCL.
The method GET_SCARR_SPFLI is an AMDP function implementation for an AMDP table function that can only be called in other AMDP methods. It has an explicitly declared interface.
METH CL_DEMO_AMDP_FUNCTIONS_INPCL=>GET_SCARR_SPFLI This method cannot be called in ABAP.
The method SELECT_GET_SCARR_SPFLI is an AMDP procedure implementation that uses SELECT to access the AMDP table function implemented in the method GET_SCARR_SPFLI.
METH CL_DEMO_AMDP_FUNCTIONS_INPCL=>SELECT_GET_SCARR_SPFLI This method is called in the example class.
The method GET_SCARR_SPFLI_FOR_CDS is an AMDP function implementation for the CDS table function DEMO_CDS_GET_SCARR_SPFLI_INPCL, which is also shown as an example of the DDL statement DEFINE TABLE FUNCTION :
DDLS DEMO_CDS_GET_SCARR_SPFLI_INPCL This method is declared using the addition FOR TABLE FUNCTION and its interface is determined using the CDS table function.
METH CL_DEMO_AMDP_FUNCTIONS_INPCL=>GET_SCARR_SPFLI_FOR_CDS The example class uses SELECT to access the CDS table function. The input parameter is filled here. Access to both AMDP table functions produces the same result, which is ensured by the ASSERT statement.
The method GET_MAX_FLTIME_SPFLI is an AMDP function implementation for an AMDP scalar function. It has an explicitly declared interface and can be called in ABAP.
METH CL_DEMO_AMDP_FUNCTIONS_INPCL=>GET_MAX_FLTIME_SPFLI In the example class, a WHERE condition of a SELECT statement contains a host expression with a functional method call of this ADMP function implementation.
The method SELECT_SPFLI_BY_MAX_FLTIME is an AMDP procedure implementation where the AMDP scalar function that is implemented in the method GET_MAX_FLTIME_SPFLI is called in its SELECT statement in the WHERE condition.
METH CL_DEMO_AMDP_FUNCTIONS_INPCL=>SELECT_SPFLI_BY_MAX_FLTIME This method is called in the example class. The preceding AB-SQL statement and the method call have the same result, which is ensured by the ASSERT statement.



Latest notes:

The CDS table function DEMO_CDS_GET_SCARR_SPFLI_INPCL used here has an input parameter for the client, annotated using the annotation @Environment.systemField and the predefined value #CLIENT. This input parameter is filled explicitly with the ID of the current client by the AB-SQL statement SELECT and used in the implementation of the associated AMDP method for selecting the data. The nearly identical class CL_DEMO_AMDP_FNCTNS uses the following CDS table function DEMO_CDS_GET_SCARR_SPFLI in which the current client is selected from the result set of the table function.
DDLS DEMO_CDS_GET_SCARR_SPFLI
NON_V5_HINTS
ABAP_HINT_END