ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → 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.
IF NOT cl_abap_dbfeatures=>use_features(
EXPORTING
requested_features =
VALUE #( ( cl_abap_dbfeatures=>call_amdp_method ) ) ).
cl_demo_output=>display(
`Current database system does not support AMDP procedures` ).
RETURN.
ENDIF.
cl_demo_input=>request( CHANGING field = incprice ).
IF incprice IS INITIAL.
RETURN.
ENDIF.
SELECT price
FROM sflight
ORDER BY carrid, connid, fldate
INTO @DATA(price_before)
UP TO 1 ROWS.
ENDSELECT.
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 price
FROM sflight
ORDER BY carrid, connid, fldate
INTO @DATA(price_after)
UP TO 1 ROWS.
ENDSELECT.
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 executable example when calling a further AMDP procedure.