AMDP Part 2: Create Your First AMDP Method
Preview · a free account unlocks the full lesson
Create a working AMDP class and method in ADT, write SQLScript with input/output parameters, call it from ABAP, and understand when the database procedure is generated.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Creating your first AMDP method follows a clear flow: a class implementing if_amdp_marker_hdb, a method signature, the BY DATABASE PROCEDURE declaration, a USING clause, activation, and finally a call from ABAP. AMDP parameters must be passed BY VALUE, and EXPORTING tables are filled by assignment inside the SQLScript itself, where a parameter is read with a leading colon, as in :name. Whatever result comes back should always be validated against an equivalent ABAP SQL version run on the same input.
Part 1 explained when AMDP is actually justified; this part walks through building one. The example receives a company code and returns customer sales totals from an illustrative table. The real goal isn't clever SQLScript — it's understanding the full development flow: an ABAP class, the AMDP marker interface, the AMDP method signature, the SQLScript implementation, the USING dependency list, activation, the ABAP caller, and result validation.
Before starting, you need ADT in Eclipse, an ABAP system on SAP HANA with AMDP support, basic ABAP Objects knowledge, and a basic understanding of SQL — and AMDP should only be reached for once you have a genuine reason for database pushdown.
The first step is creating the ABAP class. A global class is created in ADT, with a public section that interfaces if_amdp_marker_hdb — this is the line that marks the class as an AMDP container for SAP HANA — type definitions for the result structure and table type, and a class method, get_sales_totals, importing a company code BY VALUE and exporting a result table BY VALUE.
The second step is implementing the method with SQLScript. The method is declared BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zsales_item, and its body assigns et_result from a SELECT that sums net_amount grouped by customer, filtered by :iv_company_code. The method still lives inside an ordinary ABAP class, but its body executes as SQLScript on HANA.
Each clause in that declaration has a specific meaning. BY DATABASE PROCEDURE means the method is implemented as a database procedure. FOR HDB means the implementation targets SAP HANA specifically. LANGUAGE SQLSCRIPT means the method body uses SQLScript rather than ABAP syntax. OPTIONS READ-ONLY marks this particular example as read-only — the option used should always match the actual design and requirement.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.