ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Native SQL → AMDP - ABAP Managed Database Procedures → AMDP - Examples
AMDP, Implementation of a SQLScript Procedure
This example demonstrates how an SQLScript procedure is implemented using AMDP.
Other versions:
7.31 | 7.40 | 7.54
Source Code
DATA incprice TYPE sflight-price.
DATA price_before TYPE sflight-price.
DATA price_after TYPE sflight-price.
IF cl_db_sys=>is_in_memory_db = abap_false.
cl_demo_output=>display(
`Example can be executed on SAP HANA Database only` ).
LEAVE PROGRAM.
ENDIF.
cl_demo_input=>request( CHANGING field = incprice ).
IF incprice IS INITIAL.
RETURN.
ENDIF.
SELECT SINGLE price FROM sflight INTO price_before.
TRY.
NEW cl_demo_amdp( )->increase_price( clnt = sy-mandt
inc = incprice ).
CATCH cx_amdp_error INTO DATA(amdp_error).
cl_demo_output=>display( amdp_error->get_text( ) ).
RETURN.
ENDTRY.
SELECT SINGLE price FROM sflight INTO price_after.
IF price_after - price_before = incprice.
cl_demo_output=>display( `Price increased succesfully` ).
ENDIF.
Description
A simple SQLScript procedure is implemented in the AMDP method INCREASE_PRICE of the AMDP class CL_DEMO_AMDP:
LANGUAGE SQLSCRIPT
USING sflight.
update sflight set price = price + :inc
where mandt = :clnt;
ENDMETHOD.
The database table SPFLI defined in ABAP Dictionary must be specified after USING. On a SAP HANA database, this program works in the same way as the examples for
ADBC and for
CALL DATABASE PROCEDURE. AMDP replaces these technologies when calling database procedures for an SAP HANA database that is the central database of an AS ABAP.
Note
This is a syntax example. The same function can be provided with the same efficiency in Open SQL. AMDP is not needed in simple cases like this.