Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
harishbokkasam1
Product and Topic Expert
Product and Topic Expert
462

What is AMDP?

  • ABAP Managed Database Procedures (AMDP) are the preferred way for developing SAP HANA DB procedures on the ABAP platform.
  • AMDPs allow you as an ABAP developer to write database procedures directly in ABAP. Special ABAP classes (so-called AMDP classes) can contain embedded code (SQLScript) that is used to generate DB procedures in the SAP HANA DB layer.
  •  AMDP is written in a database-specific language, such as Native SQL or SQLScript, and is implemented within an AMDP method body of an AMDP class.

AMDP Documentation

How can you integrate AMDP into ABAP CDS?

  • ABAP CDS provides a framework for defining and consuming semantic data models on the central database of the application server AS ABAP. 
  • Complex calculations can be pushed down to HANA through code pushdown and data can be retrieved into CDS through AMDPs. 
  • ABAP CDS acts as a container to retrieve data from database through AMDPs.
  • A CDS view has a field that cannot be calculated with ABAP SQL; then AMDP can be used to implement the calculation logic via Native SQL and code pushdown.

What features in ABAP CDS support AMDPs?

  • Table functions
  • Scalar functions

Table functions

  • ABAP CDS table functions are implemented natively on the database and can be called in CDS.
  • Table functions accept multiple input parameters and return multiple values as a tabular data set.

harishbokkasam1_0-1721981343572.pngharishbokkasam1_1-1721981343575.png                    Implementation class                                             Implementation logic 

CDS Table functions documentation  

Scalar functions

  • An SQL-based scalar function (implemented with SQLScript) is a user-defined function that accepts multiple input parameters and returns exactly one scalar value.
  • A scalar function allows developers to encapsulate complex algorithms into manageable, reusable code that can then be used in all operand positions of CDS view entities that expect scalar values.
  • AMDP based scalar functions are visible and accessible in ABAP CDS views.
  • harishbokkasam1_2-1721981343577.png

How is client handling handled in AMDP?

AMDP in general does not support implicit client handling. When accessing client-dependent database tables or views in an AMDP method, the required client ID must be selected explicitly. 

CDS Scalar functions documentation 

Client handling in CDS Table functions

Client handling in CDS table functions is controlled via annotations.

The CDS annotation @ClientDependent can be used to switch client dependency on and off for a CDS table function in ABAP CDS (the default setting is on).

  • The value #CLIENT_DEPENDENT enables client dependency.
  • The value #CLIENT_INDEPENDENT disables client dependency.

CDS table functions can be either client-dependent or -independent. More details on client dependency and its consequences for the CDS entitites and AMDP implementations can be found here.

Client handling in scalar functions

  • 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.

What is a client-safe repository object?

A client-safe object can access data of a single client only.

  • If an AMDP method is implemented in cloud-compliant ABAP, then it is implicitly client-safe.
  • A repository object that accesses only client-independent SQL data sources is implicitly client-safe and must access only client-safe objects.

AMDP does not support implicit client handling. Therefore, client safety must be delegated to the objects accessed in an AMDP method and declared in its USING list. 

More details on the requirements for defining client-safe AMDP methods. 

client Safety in AMDP 

Client safety in CDS view entities