As an ABAP Developer one of the most important thing for me while I am writing codes , is the performance. As you know the performance of your codes not only depends on big-O notation but also the SQL queries that you are doing in your program. Trying to get data from Database is always effecting the performance of the programme.
What will we do then? Because it is nearly impossible to write code without using DB queries.
This is the goal of this article to introduce you, if you have not introduced yet, with AMDP (ABAP Managed Database Procedures).
The SAP HANA database came to our lives with variety of programming options for application logic at the DB level. So AMDP is HANA specific feature and came with HANA.
So while we are using OpenSQL in our CDS views or simple queries in our codes , we will use Native SQL in AMDP.
What is NativeSQL then? I asked to AI this question and he/she told me that;
Native SQL in SAP allows developers to write database-specific SQL statements directly within ABAP programs, bypassing the limitations of Open SQL, which is SAP's database-independent SQL abstraction layer'. As you can understand from this simple explanation we are talking about elimination of one layer and execution of SQL statements directly on the database, leveraging database-specific optimizations.
Let me give an example to understand the logic better ; Think about GEKAP (Recovery Contribution Fee) in Turkey, but firstly let me explain what GEKAP is: GEKAP is a process that promote the recycling of materials such as plastic, glass, metal, and paper and reduce environmental impact. To make this happen Goverment orderes that companies are required to pay a contribution fee based on specific rates determined for various product types. As an ABAP Developer I worked in this kind of project. From coding perspective I will try to explain inportance of performance and AMDP.
In GEKAP project we must have took the packaging process details from several different tables and to control process we should have made several queries. As you can imagine it really effects the performance of the programme. Because there was a layer between the codes and Database. But think that you are writing your codes and managing the object in Application server but execution or implementation will be done in Database.
Now I want to give some information about the limitation and history of AMDP.
No Support for Return Values:
At its introduction in ABAP 7.4 SP05, AMDP methods did not support return values.
Unlike traditional ABAP methods, the RETURNING keyword could not be used.
Use of Output Parameters:
To pass data back to the calling ABAP program, developers were required to use EXPORTING parameters.
This approach added extra steps for handling output.
Restricted Functionality:
Methods in AMDP were limited to using output parameters only, which constrained flexibility and alignment with object-oriented ABAP standards.
Enhancements in Later Versions:
With updates in ABAP 7.5, the limitation was addressed.
Developers could now use tabular return values, enabling methods to return tables directly via the RETURNING keyword.
To make you understand simply the logic of syntax I will share a simple code block which I wrote;
As you can see in the schema , simply we create a class and then we will send a structure using AMDP syntax to HANA Database and make it fill the table there.
And here is the usage of this code in ABAP report;
As you can see we use our class, and send table structure to Native SQL and after Database procedure our empty structure filled with values.
After make necessary researchments you can create more complicated examples or let me say, you can control more complex process which necessiates lots of Database queries, by AMDP...
Comments