ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP and SAP HANA → Access to Objects in SAP HANA XS → Access to SAP HANA XSC Objects → Database Procedure Proxies for SQLScript Procedures in the SAP HANA Repository → 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.
IF NOT cl_abap_dbfeatures=>use_features(
EXPORTING
requested_features =
VALUE #( (
cl_abap_dbfeatures=>call_database_procedure ) ) ).
cl_demo_output=>display(
`Current database does not support CALL DATABASE PROCEDURE` ).
LEAVE PROGRAM.
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.
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 ).
COMMIT CONNECTION default.
TRY.
CALL DATABASE PROCEDURE (prox_name)
EXPORTING increase = incprice.
CATCH cx_sy_db_procedure_sql_error INTO DATA(db_exc).
cl_demo_output=>display( db_exc->get_text( ) ).
RETURN.
ENDTRY.
api->delete( ).
CATCH cx_dbproc_proxy INTO DATA(api_exc).
cl_demo_output=>display( api_exc->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
ADBC is used in the method create_db_procedure
to create the same database procedure as in the executable 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 executable example AMDP, simple procedure call shows how the procedure can be managed and called as an ABAP Managed Database Procedure.