AMDP Procedures
AMDP Procedures
Owner A Age
Tags
https://www.brandeis.de/en/blog/amdp-procedures
AMDP procedures
From the perspective of an ABAP developer, an AMDP procedure is an instance
method of an ABAP class implemented in the SQLScript programming language.
This trick solves several problems:
• The SQL procedure is called as a method call of an ABAP class. Thus, the
procedure call is perfectly integrated into ABAP.
• The database procedure is transported via the ABAP class. This means that
there are not several transport mechanisms involved that have to be kept
synchronized.
• It is not necessary for the developer to have direct access to the SAP HANA
database with the appropriate authorizations while devoloping. It is sufficient to
work with the ADTs with the usual ABAP developer authorizations.
In the following sections, the terms AMDP and AMDP procedure are used
interchangeably. If it is not explicitly mentioned, the information does not refer
to AMDP functions.
Creating AMDP procedures
IF_AMDP_MARKER_HDB
An AMDP method can only be created in a global class that implements the
marker interface. The interface itself has no methods, it is only
IF_AMDP_MARKER_HDB
AMDP procedures 1
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
TYPES gty_tt_countries TYPE TABLE OF t005t.
METHODS get_countries
IMPORTING
VALUE(iv_langu) TYPE langu
CHANGING
VALUE(ct_country) TYPE gty_tt_countries
VALUE(cv_subrc) TYPE sy-subrc.
ENDCLASS.
ct_country = select *
FROM t005t
WHERE spras = :iv_langu;
SELECT CASE
WHEN COUNT(*) > 0
THEN 0
ELSE 4
END AS subrc
INTO cv_subrc
FROM :ct_country;
ENDMETHOD.
ENDCLASS.
• Since SQLScript does not know any structures, only scalar data types and
table types may be used as parameters. The table types in turn may only use
scalar data types in their row structure.
• All parameters must be passed as value parameters (call by value); the use of
AMDP procedures 2
reference parameters (call by reference) is not possible. This is obvious
considering the fact that the application server runs on a different system than
the database. Accordingly, there is no common memory area referencing both
systems.
• Only
IMPORTING -, EXPORTING - and CHANGING -parameters are allowed in AMDP procedures.
exceptions. However, if they are not declared, these errors will result in a dump.
Implementation of an AMDP procedure
The language in which AMDP procedures are developed is SQLScript. This is
communicated to the system by the addition
BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT .
OPTIONS READ-ONLY
If an AMDP implementation accesses data in read-only mode, the addition
OPTIONS READ-ONLY can optionally be specified.
USING
The optional addition
USING can be used to tell an AMDP implementation to use the corresponding
...USING /BI0/PPLANT.
However, when you access this table using SQLScript code, you must use the
special notation because the slash is not allowed in the simple notation:
AMDP procedures 3
USING for AMDP objects
The use of AMDP procedures and functions is declared in the USING clause
using the name of the associated ABAP method with the notation
KLASSE=>METHODE . Listing 1.2 shows an example of the keywords in
the METHOD clause of the method implementation. Everything after the dot in line
5 up to the keyword ENDMETHOD is interpreted as SQLScript.
METHOD get_countries
BY DATABASE PROCEDURE FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING t005t.
<SQLScript-Code>
ENDMETHOD.
AMDP procedures 4
SAP documentation on AMDP
PreviousOnsite Konferenz
Weitere InfosBlogpost
SAP-Kräftemangel
Mit Recruiting kommen wir nicht mehr weiter. Die Alternative ist naheliegend...
Arbeiten wo andere Urlaub machen! Für einen Kunden durfte eine BW/4HANA
Delta Schulung im Seeressort Gröbern halten.
AMDP procedures 5
Hier gibts weitere Infos...Schulungstermin
Weitere InfosBlogpost
SAP-Kräftemangel
Mit Recruiting kommen wir nicht mehr weiter. Die Alternative ist naheliegend...
Arbeiten wo andere Urlaub machen! Für einen Kunden durfte eine BW/4HANA
Delta Schulung im Seeressort Gröbern halten.
AMDP procedures 6
•3
•4
AMDP procedures 7