The AMDP Framework

The AMDP Framework

The AMDP framework provides an easy way to use database procedures in SQLScript, in ABAP programs and in BW transformation routines. An excerpt from the 2nd edition of my book "SQLScript for SAP HANA", published by Rheinwerkverlag, SAP Press.


The term ABAP Managed Database Procedures (AMDP) refers to the framework recommended by SAP for the use of SQLScript code in ABAP programs. This is a concept for creating, managing and calling database-procedures and database-functions. The basic idea behind AMDP is that the source code of SAP HANA database objects is wrapped in the implementation of methods of an ABAP class. The corresponding SAP HANA database object is then generated from this as required.

There are three different objects that can be created with the AMDP framework.

  • AMDP procedures can be called like methods of an ABAP class. They are implemented in SQLScript. The user of the method does not know that it is actually a database procedure.
  • CDS table functions are AMDP functions that are encapsulated by a Core Data Services (CDS) object and can thus be called from ABAP or Open SQL like a normal database view with a SELECT query.
  • AMDP functions for AMDP methods cannot be called directly from ABAP or Open SQL. However, they can be used when implementing other AMDP objects in SQLScript source code.

In the following table you can find a comparison of the most important features of the three objects.

AMDP ProcedureCDS table functionAMDP function
Call from ABAPlike an ABAP methodin a SELECT statementNot possible
Implementationin a public instance methodin a public, static method of a static classin a static or an instance method
Two-track developmentRealizable via inheritancepossible by case distinctionnot relevant, because only callable from other AMDP methods
Type of data accessread and writeread onlyread only
Where are the parameters defined?in the definition of the methodin the definition of the CDS objectin the definition of the method
Type of parametersany IMPORTING , EXPORT and CHANGEany scalar IMPORTING parameter and exactly one table-like RETURNING parameterany scalar IMPORTING parameter and exactly one table-like RETURNING parameter

Comparison of the three AMDP objects

Hint: AMDP framework

The SAP NetWeaver 7.4 SPS05 release introduced ABAP Managed Database Procedures (AMDP) as a framework for managing and calling database procedures in the SAP HANA database.

With the SAP NetWeaver 7.5 release, this concept has been extended to include AMDP functions. From the technical perspective these are no procedures, but functions. Nevertheless the term AMDP is also used here.

AMDP classes are classes that implement the interface IF_AMDP_MARKER_HDB and also contain at least one AMDP method.

AMDP methods can be either AMDP procedures or AMDP functions. The AMDP functions either implement a CDS table function, or they are available internally to other AMDP methods.

Tools

With the means of the AMDP framework ABAP developers have extensive possibilities for the implementation according to the Code-To-Data paradigm. Direct access to the SAP HANA database is not absolutely necessary, as all development objects can be implemented in the Eclipse development environment via the ABAP Development Tools (ADT). It is also possible to use a debugger for the SQLScript code in the AMDP methods. This AMDP debugger is described in detail in section 11.2.3 of my book.

If SAP HANA data models such as Calculation Views are modeled or procedures and functions are developed outside the AMDP framework, direct database access with appropriate permissions is required. This then also requires the SAP HANA Studio Eclipse plug-ins to be installed.

Advantages of AMDP

When does it make sense to use SQLScript in ABAP programs? There is no generalized answer to this question. Basically, the use of the AMDP framework makes sense especially if it helps you to achieve significant performance improvements. This is especially the case in the following situations:

  • if it hleps to avoid the transport of large amounts of data between the database and the application server
  • if the SQLScript procedure is programmed declaratively and it can therefore be easily parallelized and optimized by the SAP HANA database
  • if in SAP BW the transformations are to be executed with routines directly on the SAP HANA database. This significantly speeds up data transfer processes (DTPs), regardless of whether the previous ABAP code used database accesses or not.

Disadvantages

However, by using AMDPs, you have to deal with a few disadvantages. You always have to evaluate well whether you want to accept these disadvantages and get the expected performance improvements in exchange. Some of the reasons against the use of AMDPs could be:

  • The application developer must be proficient in several programming languages. Sometimes a well implemented ABAP method is better than a poorly implemented AMDP.
  • The SAP GUI is not suitable for AMDP development.
  • The application logic is spread among database servers and application servers.
  • Not all cases result in a performance improvement.
  • The developments cannot be used on other database systems. You will learn about a suitable procedure for parallel development that still allows you to take advantage of SAP HANA with AMDPs in section 1.1.4 of my book.

Alternatives

Basically, you should check the alternatives before using the AMDP framework. This includes, for example, the CDS views and the extended Open SQL capabilities of the latest SAP NetWeaver releases. According to SAP documentation, AMDPs should only be used if database-specific functions such as the SQL function for currency conversion are to be used, which are not available in Open SQL. Another reason for using AMDPs is, if it helps to avoid the transport of larger data amounts between database server and application server.


Related links

Categories of this article