What does it do? This statement calls a database procedure> written in SQLScript> ( SQLScript procedure>) on an SAP HANA database>.
If the addition CONNECTION> is not specified, the statement can only be executed in a system on the SAP HANA database.
If the addition CONNECTION> is specified, the statement can be executed in every system with a secondary connection> to an SAP HANA database. The SQLScript procedure is specified using a database procedure proxy> defined for it. The proxy can be specified as follows:
proxy> Specified directly and statically as proxy>.
(proxy_name)> Specified as the uppercase content of a parenthesized character-like data object proxy_name>. The following can be specified for proxy_name>:
Literal or constants
If the data object proxy_name> is specified as a character literal or as a constant, it can be evaluated statically, and the specified proxy is recognized as the used object.
Variable BEGIN_SECTION ID CALL-DATABASE-PROCEDURE-DYN
If the data object proxy_name> is specified as a variable, it is specified only dynamically and the content is not evaluated statically. END_SECTION ID CALL-DATABASE-PROCEDURE-DYN When the statement is executed, proxy_name> is not evaluated until runtime in both cases. The actual parameters for the input and output parameters of the procedure are either specified statically using parameter_list>> or dynamically using parameter_table>>.
Latest notes:
The names of the database procedure proxy and database procedure interface are freely definable. Usually, the database procedure interface has the name of the database procedure proxy with the prefix IF_>, and any additional namespace prefix>.
The constant CALL_DATABASE_PROCEDURE> of the class CL_ABAP_DBFEATURES>> can be used to query whether the current database supports database procedure proxies.
ABAP Managed Database Procedures> (AMDP) are a recommended alternative to the statement CALL DATABASE PROCEDURE> if the standard AS ABAP database> is an SAP HANA database. Any database procedures of the standard database can be called from AMDP, which makes the use of database procedure proxies superfluous as long as a secondary connection> is not used to access another SAP HANA database.
No database procedure proxies can be used for SQLScript procedures in SAP HANA XSA>. Alternative methods such as AMDP> or ADBC> must be used instead.
No database procedure proxies can be used on a SAP HANA Cloud database>. The method CL_SHDB_HC=>IS_HANA_CLOUD> can be used to check if the current database is a SAP HANA Cloud database. ABAP_HINT_END • CONNECTION CALL DATABASE PROCEDURE
ABAP Addition
What does it do? The SQLScript procedure is not executed on the standard connection> but on the specified secondary connection > instead. The database connection can be specified statically with con> or dynamically as the content of con_syntax>, where the field con_syntax> must be of the type c> or string >. The database connection must be specified with a name from the column CON_NAME> in the table DBCON>> or that begins with the prefix R/3*> and hence represents a service connection> to the standard database.
Latest notes:
The specified database procedure proxy for the database procedure of the secondary connection must exist in the current system.
Entries in the DDIC database table DBCON> can only be created and modified using the DBA Cockpit> tool.
The use of CALL DATABASE PROCEDURE> with the addition CONNECTION> is recommended in all scenarios in which existing database procedures are used in an SAP HANA database that is not the current standard AS ABAP database (side-by-side scenario). ABAP_HINT_END
Example ABAP Coding
SQLScript Procedure> Take the following SQLScript procedure: /********* Begin Procedure Script ************/ BEGIN out_items = select items.pos, items.first_name, items.last_name, items.posting_date as date, items.currency, items.amount from zngd_items as items inner join :in_sel as sel on ( items.first_name = sel.first_name and items.last_name = sel.last_name ) where posting_date = :in_date; END; /********* End Procedure Script ************/> The input parameters are: Parameter>Database Type> in_sel>Table data type> in_date>Scalar> The components of in_sel> are: Component>Database Type> FIRST_NAME>NVARCHAR, length 20> LAST_NAME>NVARCHAR, length 20> The output parameters are: Parameter>Database Type> out_items>Table data type> The components of out_items> are: Component>Database Type> POS>INTEGER> FIRST_NAME>NVARCHAR, length 20> LAST_NAME>NVARCHAR, length 20> DATE>INTEGER> CURRENCY>NVARCHAR, length 4> AMOUNT>DECIMALS, length 11, scale 2> Database Procedure Proxy> The following mapping is defined in the associated database procedure proxy ..._PROXY>: Procedure Parameter>ABAP Name>ABAP Data Type> IN_SEL>IN_SEL>Internal table IN_SEL>, FIRST_NAME>IN_SEL>, FIRST_NAME> c>, length 20 IN_SEL>, LAST_NAME>IN_SEL>, LAST_NAME> c >, length 20 IN_DATE>IN_DATE>d> OUT_ITEMS>, POS>OUT_ITEMS>, POS> i> OUT_ITEMS>, FIRST_NAME>OUT_ITEMS>, FIRST_NAME> c>, length 20 OUT_ITEMS>, LAST_NAME>OUT_ITEMS>, LAST_NAME> c>, length 20 OUT_ITEMS>, DATA>OUT_ITEMS>, POSTING_DATE> d> OUT_ITEMS>, CURRENCY>OUT_ITEMS>, CURRENCY> c>, length 4 OUT_ITEMS>, AMOUNT>OUT_ITEMS>, AMOUNT> p >, length 6, 2 decimal places The name and type changes in the date fields should be noted. Database Procedure Interface> The database procedure interface IF_..._PROXY> is generated with the following type declarations: INTERFACE if_..._proxy PUBLIC. TYPES: BEGIN OF in_sel, first_name TYPE c LENGTH 20, last_name TYPE c LENGTH 20, END OF in_sel. TYPES: in_date TYPE d. TYPES: BEGIN OF out_items, pos TYPE i, first_name TYPE c LENGTH 20, last_name TYPE c LENGTH 20, posting_date TYPE d, currency TYPE c LENGTH 4, amount TYPE p LENGTH 6 DECIMALS 2, END OF out_items. ENDINTERFACE.> Database Procedure Call> The following ABAP program section calls the SQLScript procedure using the name of the database procedure proxy, whereby actual parameters typed using the database procedure interface are used. DATA: in_date TYPE if_..._proxy=>in_date, in_sel TYPE STANDARD TABLE OF if_..._proxy=>in_sel WITH EMPTY KEY, out_items TYPE STANDARD TABLE OF if_..._proxy=>out_items WITH EMPTY KEY.
IF cl_abap_dbfeatures=>use_features( EXPORTING requested_features = VALUE #( ( cl_abap_dbfeatures=>call_database_procedure ) ) ) AND NOT cl_shdb_hc=>is_hana_cloud( ). CALL DATABASE PROCEDURE ..._proxy EXPORTING in_date = in_date in_sel = in_sel IMPORTING out_items = out_items. ENDIF.> ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA The example Database Procedure Call> uses a database procedure proxy created in the program to call a SQLScript procedure created using ADBC>. ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions Aside from CX_SY_DB_PROCEDURE_SQL_ERROR>, all the following exception classes are subclasses of the abstract superclass CX_SY_DB_PROCEDURE_CALL>>. CX_SY_DB_PROCEDURE_SQL_ERROR>>
Reason for error:
Error on the database when executing an SQLScript function.
Runtime error:
DBPROC_SQL_ERROR> CX_SY_DB_PROCEDURE_CONNECTION>>
Reason for error:
The specified secondary connection was not found in the DDIC database table DBCON>.
Runtime error:
DBPROC_CONNECTION> CX_SY_DB_PROCEDURE_NOT_FOUND>>
Reason for error:
The specified database procedure proxy does not exist.