ABAP Development for SAP HANA
Hello, habrasociety!
In this article, I would like to highlight new approaches to development on ABAP, as applied to SAP HANA. We’ll look at the new elements of the ABAP language that will allow you to more effectively use the opportunities provided by SAP HANA.
Suppose we have a report written in the ABAP language, whose working time does not suit us. We want to optimize the performance of this report. The main idea of changing the report logic is that part of the report logic, which intensively uses data from the DBMS (in our case, it is SAP HANA), will be delegated to the DBMS level.

Fig. 1. Code to Data pushdown.
To implement this approach, the following designs can be used:
Starting with Application Server ABAP 7.4 SP5, the capabilities of the built-in database language in ABAP - Open SQL have been significantly expanded.

Fig. 2. Advanced Open SQL
New features of Open SQL:
You can find more information on advanced Open SQL in a course from Open SAP called “ABAP Development for SAP HANA” ( link ).
As a rule, new features relate to operating with tables at the DBMS level. But there are often situations when you need to “manipulate” both internal tables and database tables together. For these purposes, you can use the SELECT ... FOR ALL ENTRIES (FAE) construct.
SELECT result FROM table FOR ALL ENTRIES IN itab WHERE ... col op itab_comp ...
This expression construct does not conform to the SQL standard, so the interpreter converts to a semantically equivalent SELECT expression that can be executed by the database.
You can control the conversion process using ProfileParameters (set in the transaction RZ11):
For example, the construct:
ABAP
SELECT col1, col2, ..., colM from TAB
FOR ALL ENTRIES IN itab
WHERE col1 op1 itab-a1
op col2 op2 itab-a2
...
op colM opM itab-aM
, depending on the settings, can be converted in the following ways :
UNION
SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 i11 op col2 op2 i12 op ... op colM opM i1N
UNION ALL SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 i21 op col2 op2 i22 op ... op colM opM i2N
...
UNION ALL SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 iM1 op col2 op2 iM2 op ... op colM opM iMN
OR
SELECT col1 ,, col2, ..., colM FROM TAB WHERE col1 op1 i11 op col2 op2 i12 op ... op colM opM i1N
OR col1 op1 i21 op col2 op2 i22 op ... op colM opM i2N
...
OR col1 op1 iM1 op col2 op2 iM2 op ... op colM opM iMN
IN
SELECT col1, col2, ..., colM FROM TAB WHERE (col1, ..., colM) IN ((i11, ..., i1N),
(i21, ..., i2N),
...
(iM1, ..., iMN))
JOIN
SELECT col1, col2, ..., colM FROM TAB, ABAP_ITAB AS T1 (C_1 datatype, C_2 datatype, ..., C_M datatype)
WHERE TAB.col1 op1 T1.C_1 op
op TAB.col2 op2 T1.C_2
...
op TAB.colM opM T1.C_M
Profile parameters can be overloaded using hints :
SELECT * FROM [..] FOR ALL ENTRIES IN [..] WHERE [..]
% _HINTS HDB '& prefer_join 1'.
For more information on FOR ALL ENTRIES, see SAP notes 48230, 129385, 1622681.
Open SQL functionality is not always enough. For example, an Open SQL expression can receive an input and return only one internal table. To implement a more complex logic for querying the DBMS, everything in the same AS ABAP 7.4 SP5 version has the ability to create SAP HANA stored procedures directly in ABAP. It looks as if the stored procedure "wraps" in a class method. To create and edit AMDP, you will need ABAP Development Tools in Eclipse version 2.19 or higher. You can view AMDP code in the SAP GUI (for example, through transactions SE24, SE80).

Fig. 3. ABAP Managed Database Procedures
AMDP Features:
You can find more information on AMDP in the same course from “ABAP Development for SAP HANA” ( link ) or in SCN ( link ).
Summary
In this article, we wanted to show that ABAP has developed tools that allow you to effectively use the capabilities of SAP HANA.
useful links
In this article, I would like to highlight new approaches to development on ABAP, as applied to SAP HANA. We’ll look at the new elements of the ABAP language that will allow you to more effectively use the opportunities provided by SAP HANA.
Suppose we have a report written in the ABAP language, whose working time does not suit us. We want to optimize the performance of this report. The main idea of changing the report logic is that part of the report logic, which intensively uses data from the DBMS (in our case, it is SAP HANA), will be delegated to the DBMS level.

Fig. 1. Code to Data pushdown.
To implement this approach, the following designs can be used:
- Advanced Open SQL
- FOR ALL ENTRIES
- ABAP Managed Database Procedures
Advanced Open SQL
Starting with Application Server ABAP 7.4 SP5, the capabilities of the built-in database language in ABAP - Open SQL have been significantly expanded.

Fig. 2. Advanced Open SQL
New features of Open SQL:
- Advanced JOIN DATABASE TABLES
- Arithmetic expressions
- String expressions
- CASE, COALESCE expressions
You can find more information on advanced Open SQL in a course from Open SAP called “ABAP Development for SAP HANA” ( link ).
FOR ALL ENTRIES
As a rule, new features relate to operating with tables at the DBMS level. But there are often situations when you need to “manipulate” both internal tables and database tables together. For these purposes, you can use the SELECT ... FOR ALL ENTRIES (FAE) construct.
SELECT result FROM table FOR ALL ENTRIES IN itab WHERE ... col op itab_comp ...
This expression construct does not conform to the SQL standard, so the interpreter converts to a semantically equivalent SELECT expression that can be executed by the database.
You can control the conversion process using ProfileParameters (set in the transaction RZ11):
- rsdb / prefer_in_itab_opt (convert to IN)
- rsdb / prefer_join (convert to JOIN)
- rsdb / prefer_union_all (convert to UNION ALL)
- rsdb / max_blocking_factor (maximum number of lines passed from itab)
- rsdb / max_in_blocking_factor (the maximum number of lines passed from itab in the case of IN)
For example, the construct:
ABAP
SELECT col1, col2, ..., colM from TAB
FOR ALL ENTRIES IN itab
WHERE col1 op1 itab-a1
op col2 op2 itab-a2
...
op colM opM itab-aM
, depending on the settings, can be converted in the following ways :
UNION
SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 i11 op col2 op2 i12 op ... op colM opM i1N
UNION ALL SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 i21 op col2 op2 i22 op ... op colM opM i2N
...
UNION ALL SELECT col1, col2, ..., colM FROM TAB WHERE col1 op1 iM1 op col2 op2 iM2 op ... op colM opM iMN
OR
SELECT col1 ,, col2, ..., colM FROM TAB WHERE col1 op1 i11 op col2 op2 i12 op ... op colM opM i1N
OR col1 op1 i21 op col2 op2 i22 op ... op colM opM i2N
...
OR col1 op1 iM1 op col2 op2 iM2 op ... op colM opM iMN
IN
SELECT col1, col2, ..., colM FROM TAB WHERE (col1, ..., colM) IN ((i11, ..., i1N),
(i21, ..., i2N),
...
(iM1, ..., iMN))
JOIN
SELECT col1, col2, ..., colM FROM TAB, ABAP_ITAB AS T1 (C_1 datatype, C_2 datatype, ..., C_M datatype)
WHERE TAB.col1 op1 T1.C_1 op
op TAB.col2 op2 T1.C_2
...
op TAB.colM opM T1.C_M
Profile parameters can be overloaded using hints :
SELECT * FROM [..] FOR ALL ENTRIES IN [..] WHERE [..]
% _HINTS HDB '& prefer_join 1'.
For more information on FOR ALL ENTRIES, see SAP notes 48230, 129385, 1622681.
ABAP Managed Database Procedures (AMDP)
Open SQL functionality is not always enough. For example, an Open SQL expression can receive an input and return only one internal table. To implement a more complex logic for querying the DBMS, everything in the same AS ABAP 7.4 SP5 version has the ability to create SAP HANA stored procedures directly in ABAP. It looks as if the stored procedure "wraps" in a class method. To create and edit AMDP, you will need ABAP Development Tools in Eclipse version 2.19 or higher. You can view AMDP code in the SAP GUI (for example, through transactions SE24, SE80).

Fig. 3. ABAP Managed Database Procedures
AMDP Features:
- Lifecycle-Management Support
- Using ABAP Dictionary Objects
- Call other AMDP
- Writing Language - SQL Script
- Called as a regular ABAP method
You can find more information on AMDP in the same course from “ABAP Development for SAP HANA” ( link ) or in SCN ( link ).
Summary
In this article, we wanted to show that ABAP has developed tools that allow you to effectively use the capabilities of SAP HANA.
useful links