If you’re already started developing ABAP on SAP HANA or if you’re planing on doing so, then you’ll soon ask yourself; “How do I consume my HANA artifacts in ABAP?”. Once you’ve figured that one out and you’ve been baptised in the fire of native SQL, you’ll probably ask yourself; “Isn’t there an easier way?”. Well, there is!
SAP has made SAP NetWeaver 7.4 and the ABAP Development Tools 2.7 generally available (GA) to its customers. As promised, SAP NetWeaver 7.4 has been optimized for SAP HANA. This includes new features to easily consume existing HANA artifacts in your ABAP code.
Let’s give you an idea of how it’s done!
Until now, the only way to consume existing HANA artifacts in your ABAP code was by using native SQL, e.g., by using ABAP Database Connectivity (ADBC). While native SQL is both powerful and flexible, it is also tedious and error-prone. The development cycle consists largely of string concatenations and runtime validations, which some ABAP developers affectionately refer to as “dump-driven development”.
Now, HANA views and SQLScript procedures which are stored in the HANA repository can be “imported” into the ABAP Dictionary. Proxy repository objects are created for the HANA artifacts in the ABAP Dictionary and the artifacts are optimally integrated into the ABAP development and runtime environments. This way you can take full advantage of the ABAP development tools (syntax check, static code checks, where-used, code-completion, etc.) when you write code which consumes your HANA artifacts.
The ABAP Development Tools 2.7 offer new tools to create proxy repository objects, i.e., External Views and Database Procedure Proxies for your HANA views and SQLScript procedures respectively.
You can import your HANA views into the ABAP Dictionary by creating an External View for your HANA view (New > Other ABAP Repository Object > Dictionary > Dictionary View).
When the External View is created, the HANA types are automatically mapped to ABAP types. Errors which occur during the import are displayed in the ABAP Log.
If the External View was successfully created, you can modify the DDIC types which were automatically mapped to the HANA types in the External View editor.
Once you have activated the External View, it can be used in OPEN SQL in the same way that you can use normal dictionary views!
SELECT
so_id
bupa_id
days_open
gross_amount
FROM zopen_invoice_vw INTO TABLE open_invoices.
HANA views with input parameters are not supported.
You can import your SQLScript procedures into the ABAP Dictionary by creating a Database Procedure Proxy for your SQLScript procedure (New > Other ABAP Repository Object > Dictionary > Database Procedure Proxy).
When a Database Procedure Proxy is created, the HANA types are automatically mapped to ABAP types and a read-only ABAP interface is created with ABAP type definitions for the parameters of the SQLScript procedure. The type definitions can be used to define the actual parameters for calling the SQLScript procedure via its proxy in ABAP.
If the import was successful, you can modify the ABAP names and the built-in ABAP types which were automatically mapped to the HANA types in the Database Procedure Proxy editor. You can also use an existing DDIC data element or structure as a parameter type.
The database procedure is called via its proxy using the new and convenient ABAP statement CALL DATABASE PROCEDURE. If you’ve ever called a SQLScript procedure using native SQL, then you will appreciate the ABAP code below!
DATA:
target_currency_code TYPE zif_zopen_inv_amount=>iv_target_currency_code,
figures TYPE STANDARD TABLE OF zif_zopen_inv_amount=>et_figures WITH EMPTY KEY.
CALL DATABASE PROCEDURE zopen_inv_amount
EXPORTING
iv_target_currency_code = target_currency_code
IMPORTING
et_figures = figures.
It is technically possible to create more than one External View or Database Procedure Proxy for your HANA artifact. This, however, is not recommended and you will get a warning when you import a HANA artifact into the ABAP Dictionary which has already been imported.
If you want to know which External Views or Database Procedure Proxies have already been created for your HANA artifact you can perform an ABAP Object Search for the artifact (Search > Search …). The search will return all the proxy repository objects in the ABAP Dictionary which exist for the artifact.
Currently not all HANA data types can be mapped to ABAP Dictionary types. HANA artifacts which use HANA types not listed in the table below cannot be imported into the ABAP Dictionary. You need to keep this in mind when you model your HANA artifacts in the HANA Studio if you want to use them in ABAP.
HANA Data Type | ABAP Dictionary Type |
---|---|
SMALLINT | INT2 |
INTEGER | INT4 |
DECIMAL | DEC |
SMALLDECIMAL | DEC |
FLOAT | FLTP |
NVARCHAR | CHAR |
VARBINARY | RAW |
BLOB | RAWSTRING |
NCLOB | STRING |
If the underlying HANA artifacts are modified, then the External Views and Database Procedure Proxies have to be manually synchronized with the HANA Repository. The External View and Database Procedure Proxy editors provide a “synchronize” function to retrieve the active version of the HANA artifact from the HANA repository. By default, the manual changes made to the External Views and Database Procedure Proxies (ABAP names, types, etc.) are preserved when they are synchronized.
So now that you've seen how easy it's become to consume HANA artifacts in ABAP, let's put it in a nutshell:
You will find more information about these and many others features in the official documentation integrated into the ABAP Development Tools (Help > Help Contents > SAP - ABAP for HANA Development User Guide) and the ABAP for SAP HANA Reference Scenario delivered with SAP NetWeaver 7.4.
If you're now asking youself how to get the HANA artifacts into your ABAP SAP system landscape and how to transport them together with your External Views and Database Procedure Proxies, then the answer is the HANA Transport Container.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
24 | |
21 | |
13 | |
11 | |
9 | |
9 | |
8 | |
8 | |
8 |