cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

AMDP Class - Database Procedure

0 Likes
598

AMDP Class

 An AMDP (ABAP Managed Database Procedure) class is used to write complex logic directly in the SAP HANA database using SQL Script, instead of writing everything in ABAP.

This helps to:

  • Improve performance by processing data inside the database.
  • Reduce load on the application layer.
  • Speed up reports and data-heavy programs.

 Open Eclipse.

Step 1: Create a package. 

Krishnaveni_Palanisamy_0-1746168963252.png

 

Give basic properties.

Krishnaveni_Palanisamy_1-1746168963255.png

Select Transpost request.

Krishnaveni_Palanisamy_2-1746168963265.png

 

STEP2 : Create AMDP class

Krishnaveni_Palanisamy_3-1746168963272.png

 

The class will be like below.

Krishnaveni_Palanisamy_4-1746168963275.png

To convert the normal class into the AMDP class, use the interface IF_AMDP_MARKER_HDB

Krishnaveni_Palanisamy_5-1746168963284.png

 

Create class attributes, and to implement the method, click on CTRL+1.

Krishnaveni_Palanisamy_6-1746168963293.png

The AMDP procedure will run on HANA DB. The memory location is not available at the database level. It is only available at the application level, so we have to pass the parameter with a pass-by value.

Krishnaveni_Palanisamy_7-1746168963297.png

Two Types of AMDP Methods :

In AMDP, we can write two types of methods:

  1. Database Procedure
  • This is a normal AMDP method written in SQL Script.
  • It can be used to read or modify data.
  • Called directly from ABAP like a regular method
  1. Database Function (Table Function)
  • This is used with CDS Views to return a result set like a virtual table.
  • Implemented using an AMDP method, but used as a function in CDS.
  • Always read-only.

Here we will see Database Procedure.

To convert the method to the AMDP method.

  • To convert the normal method to the AMDP method write some code to the implementation part of methods.

Specify the target database in which you want to create the database procedure, along with the database language to be used. Additionally, list all the objects (such as tables, views, procedures, etc.) that need to be accessed within the specified schema.

  • 2.AMDP procedure is not implicit in client handling. So, we need one more parameter to pass the client.

 

Krishnaveni_Palanisamy_8-1746168963304.png

An error will occur when using the Database table in the AMDP method.

Krishnaveni_Palanisamy_9-1746168963309.png

Step 3:

Create a program to consume the AMDP class.

Krishnaveni_Palanisamy_10-1746168963322.png

Search PROGRAM à select ABAP program.

Krishnaveni_Palanisamy_11-1746168963328.png

Write the below code.

Krishnaveni_Palanisamy_12-1746168963330.png

Output :

Krishnaveni_Palanisamy_13-1746168963331.png

 

 

Conclusion:

AMDP procedures are a powerful way to push complex logic to the SAP HANA database, allowing you to handle large volumes of data more efficiently.

Use AMDP procedures when:

  • You want to improve performance with code pushdown.
  • You need to process data-heavy logic directly in HANA.
  • You want to keep your ABAP code clean and efficient.

Accepted Solutions (0)

Answers (0)