ABAP Managed Database Procedures
AMDP[ABAP Managed Database Procedure]– is a framework for managing and calling stored/database procedure and database function in AS ABAP. The AMDP manages AMDP procedures and functions.
AMDP CLASS– An AMDP class is a global class that contains special tag interface that starts with – IF_AMDP_MARKER_* .
For HANA Database- the interface – IF_AMDP_MARKER_HDB – the suffix HDB indicates the database system for which the ABAP managed database procedure can be implemented in the AMDP method of AMDP class. AMDP class can contain both normal regular methods as well as AMDP methods. It can contain one or more AMDP methods for each database system specified by the special tag interface.
AMDP METHOD– Constructors can’t implemented as AMDP method. There are two types of AMDP methods: 1-AMDP Procedure Implementation and 2-AMDP Function Implementation.
The AMDP method for AMDP procedure implementation must be flagged with addition- BY DATABASE PROCEDURE & AMDP method for AMDP Function Implementation must be flagged with addition- BY DATABASE FUNCTION.
AMDP PROCEDURE IMPLEMENTATION– is an AMDP method for implementing database procedure. It can be a static or instance method and can be declared in any section. The parameter interface must follow the below mentioned rules:
-> Parameters must be declared using pass by value ( pass by reference not allowed).
-> Return values can not be declared using RETURNING.
-> RAISING can only be used to specify the exception classes which are AMDP specific- CX_AMDP_* ( subclass of CX_DYNAMIC_CHECK).
The method implementation- must not be empty, no DDL statements like creating/change or deleting database objects, no execution of transactional statements like COMMIT WORK/ROLLBACK WORK, method don’t have any implicit enhancement option, write can not be performed on DB tables with buffering switched on ( SQL script access are ignored by buffer synchronization). Dynamic programming should not be used[ write can be made dynamically on a buffered table leading to inconsistencies in buffer synchronization].
AMDP FUNCTION IMPLEMENTATION- is an AMDP method for implementing database function. An AMDP Function implementation is marked in the method implementation with addition- BY DATABASE FUNCTION.
AMDP Functions are:
1-AMDP Table Function
1.1- AMDP Table Functions for AMDP Methods :- Function that can be accessed on other AMDP methods.
1.2- AMDP Table Functions for CDS Table Functions:- Function that implements CDS table function that can be accessed in ABAP SQL.
2-AMDP Scalar Function
AMDP Table Functions for AMDP Methods: An AMDP function implementation for an AMDP table function can be declared as static or instance method in any visibility section of an AMDP class and can be called in ABAP like regular method. The method interface must follow the below rules:
-> Must have a return parameter with pass by value defined using RETURNING and the data type of the return value must be tabular with a structure row type with elementary components.
-> Can have elementary or tabular input parameters but can’t have output parameters.
-> Class based exceptions can not be declared using RAISING in the method interface.
AMDP Table Functions for CDS Table Functions: this can only be declared in the public section of a static AMDP class and addition- FOR TABLE FUNCTION must be used in the declaration. The parameter interface is generated as per the associated CDS table function. The return value “RESULT” with type of standard table with empty key is created where the components of the row type are determined by the elements of the CDS table function.