ABAP Managed Database Procedures

What is AMDP?

Allows developers to create and execute database procedures in an ABAP environment using ABAP method.

AMDP is the top-down approach of using HANA Database Procedures in ABAP.  Allow the execution of complex calculations inside the HANA database. AMDP only requires ABAP Application Server (AS) for developing, managing and calling database procedures.

---

What makes AMDP class and ABAP method different from normal class and method?

AMDP class

  • Can contain both regular methods and AMDP methods.
  • One or more AMDP methods can be present in AMDP class.
  • Can only be created using ADT.
  • class with AMDPs must implement interface IF_AMDP_MARKER_HDB
AMDP Methods
  • AMDP methods can be defined in the public, protected, or private visibility section of the class.
  • Although you can define AMDP methods as instance methods, they are always executed like static methods.
  • All AMDP method parameters have to be passed by value, and must be of either table or scalar types. Pass by reference is not permitted
  • Exporting, importing and changing parameters are allowed. Returning parameters are not allowed
  • AMDP Method is specified with addition BY DATABASE PROCEDURE in the method implementation part, followed by the database system (for example, HDB) and the implementation language (for example, SQLScript).
  • For parameters of table types, the line types have to consist of elementary components, because nested tables are not supported. ABAP Dictionary structure types are not allowed.
---

Comparision between ABAP CDS view and AMDP
 
ABAP CDS views AMDP
Work on all DBs supported by SAP Work only on SAP HANA DB
Use if or reusable queries Use if for complex queries which are not handled by ABAP CDS views
Only 1 result set can be returned Multiple result set can be returned
-
Use database specific programming language, such as SAP HANA SQL script
-
Features of native SQL functions can be leveraged

---

When to use ABAP SQL, CDS views, AMDP?

ABAP SQL, CDS views, and AMDP (ABAP Managed Database Procedures) are all options for accessing data in SAP systems. The choice of which to use depends on various factors such as performance, complexity, and data structure.

ABAP SQL should be used when simple data retrieval or manipulation is required, and the underlying database tables or views are well-structured. 

ABAP SQL can be used for basic SELECT, INSERT, UPDATE, and DELETE statements, and it is suitable for simple queries that do not require complex data processing.

CDS views should be used when a more complex view of data is required, and when the data needs to be accessed from multiple sources. CDS views can be used to define complex joins, unions, and aggregations, and they are optimized for performance. They are also suitable for creating reports and analytical applications.

AMDP should be used in situations where complex database processing is required, and performance is a concern. For example, if you need to perform complex calculations, aggregations, or join operations on large data sets, using AMDP may be a good option.  It allows database-specific functions to be accessed that do not exist in Open SQL.

AMDP allows developers to write database procedures in ABAP that can be executed on the database server, rather than in the application server, which can result in improved performance.   

In summary, ABAP SQL, CDS views, and AMDP all have their use cases, and the choice of which to use depends on the specific requirements of the task at hand.

ABAP Tips

 

See Also
Estimate Guidelines for ABAP programs

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP Basis, ABAP Programming and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.