Вы находитесь на странице: 1из 8

Topic 8: Consumption of Stored Procedure in

ABAP

1 Module Name: 1. HANA Overview 2013 IBM Corporation


Consumption of HANA Stored Procedure in ABAP

There are two methods of using HANA Stored Procedure in our ABAP
programming:

Calling SAP HANA Stored Procedure through Native SQL

Using Database Procedure Proxy to expose HANA Procedure

Both the process has its pros and cons, but it is better to use Database proxy over
the native SQL.

Diagram Source: SAP

2 Module Name: 1. HANA Overview 2013 IBM Corporation


Native SQL process vs Database Proxy

Advantage of Native SQL process over Database Proxy

Faster development, lesser effort Once you have the stored procedure created in the
HANA DB, you can write native SQL to access that directly.

No extra ABAP artifact, less maintenance As no other ABAP artifact to be created (like
DB Proxy) maintenance cost will be lesser in this case

Native SQL Development can be done in SAP GUI as well as ADT, whereas for DB
proxy it required to be done in ADT only

3 Module Name: 1. HANA Overview 2013 IBM Corporation


Native SQL process vs Database Proxy

Advantage of Database Proxy over Native SQL process

Native SQL Process is tedious and error prone

Full advantage of ABAP development environment available

Procedure proxy call is similar like Function Module, which is quite familiar for ABAP
developer and are easy to use

In case of change in DB Procedure the code changing process is totally manual, but for
proxy it is semi-manual and proxy can be synchronized while editing the same as
shown below:

4 Module Name: 1. HANA Overview 2013 IBM Corporation


Calling SAP HANA Stored Procedure through Native SQL

In your ABAP report define a type having two member (one for parameter another for value) of
type string and declare an internal table of that type.
Pass the Call statement in a string.
lv_sql = CALL <FULL NAME OF PROCEDURE> (PARAM1 , PARAM2, ,PARAMn) WITH
OVERVIEW
Execute the above SQL query by using the method EXECUTE_QUERY of class
CL_SQL_STATEMENT and get that result in an object of type CL_SQL_RESULT_SET.
Get the queried data in the table defined in step 1.
Read the table above with <PARAMETER_NAME> = <VALUE of the Parameter>. This will
return a temporary table name in Value field where the actual result of the query corresponding
to the parameter value saved.
Execute another SQL query following step 2 and 3 and the result will be available in your
internal table.

5 Module Name: 1. HANA Overview 2013 IBM Corporation


Using HANA Stored Procedure with Database Procedure Proxy

Switch to the ABAP perspective in ADT


Select the Package and right-click on it and select New -> Other ABAP Repository Object
from the context menu. Filter for Database Procedure Proxy", select it and press on Next
Provide the Name of the Proxy and its description in the dialog box.
Also provide the name of existing HANA procedure and the name of the interface to be
created.
Adjust type to be used in interface (refer to the table below)
HANA Data Type ABAP Dictionary Type
SMALLINT INT2
INTEGER INT4
DECIMAL DEC
SMALLDECIMAL DEC
FLOAT FLTP
NVARCHAR CHAR
VARBINARY RAW
BLOB RAWSTRING
NCLOB STRING

6 Module Name: 1. HANA Overview 2013 IBM Corporation


Using HANA Stored Procedure with Database Procedure Proxy

In the ABAP program declare the related parameters for Proxy similar to type in generated
interface.
Call the Proxy in your ABAP program as below:
CALL DATABASE PROCEDURE <PROXY_NAME>
EXPORTING
E_PAR1 = V_PARAM1
E_PAR2 = V_PARAM2
IMPORTING
I_PAR1 = LT_DATA1
I_PAR2 = LT_DATA2.

7 Module Name: 1. HANA Overview 2013 IBM Corporation


Using HANA Stored Procedure with Database Procedure Proxy

Below picture will explain the high level architecture of using Database Procedure in
ABAP.

8 Module Name: 1. HANA Overview 2013 IBM Corporation

Оценить