ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Native SQL → AMDP - ABAP Managed Database Procedures → AMDP - Examples
AMDP, Calling an SQLScript Procedure from AMDP
This example demonstrates how a database procedure is called from an AMDP procedure.
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.
cl_demo_amdp_call=>increase_price( 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
The SQLScript procedure of the AMDP method INCREASE_PRICE in the AMDP class CL_DEMO_AMDP_CALL calls a database procedure (not managed by AMDP) of the current database schema in the namespace /1BCAMDP/:
METHOD increase_price BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT.
call "/1BCAMDP/ABAP_DOCU_DEMO_INCPRICE"( INC => :INCPRICE );
ENDMETHOD.
The called database procedure is created dynamically in the static constructor of the AMDP class CL_DEMO_AMDP_CALL using
ADBC. It is in the same database schema, but due to the namespace
/1BCAMDP/ it cannot and must not be used after the addition
USING
of the METHOD
statement. Compare this example when calling a further AMDP procedure.