ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → ABAP and SAP HANA → Database Procedure Proxies for SQLScript Procedures → CALL DATABASE PROCEDURE
SAP HANA, Database Procedure Proxy
This example demonstrates how a database procedure created in the program is called.
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.
create_db_procedure( ).
DATA(params) =
VALUE if_dbproc_proxy_basic_types=>ty_param_override_t(
( db_name = 'INC'
abap_name = 'INCREASE'
descr = cl_abap_typedescr=>describe_by_name(
'SFLIGHT-PRICE' ) ) ).
TRY.
DATA(api) = cl_dbproc_proxy_factory=>get_proxy_public_api(
if_proxy_name = prox_name ).
api->delete( ).
api->create_proxy( EXPORTING
if_proc_schema = '_SYS_BIC'
it_param_override = params
if_proc_name = proc_name ).
CALL DATABASE PROCEDURE (prox_name)
EXPORTING increase = incprice.
api->delete( ).
CATCH cx_dbproc_proxy INTO DATA(api_exc).
cl_demo_output=>display( api_exc->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
ADBC is used in the method create_db_procedure
to create the same database procedure as in the example
ADBC, Stored Procedure. Here, however, the procedure
is called using the statement CALL DATABASE PROCEDURE
and not using ADBC.
The database procedure proxy need to do this is created temporarily in the program itself using the associated API.
- The API is created using the factory method GET_PROXY_PUBLIC_API from the factory class CL_DBPROC_PROXY_FACTORY.
- The proxy is created using the method CREATE_PROXY of the interface IF_DBPROC_PROXY_PUBLIC_API.
- Here, the internal table
params
filled previously is used to define the mapping between the parameter interface and ABAP data types. The parameter names are also modified.
The example AMDP, simple procedure call shows how the procedure can be managed and called as an ABAP Managed Database Procedure.