May 30, 2014

ABAP on HANA - enhance performance through code push down


With SAP Netweaver AS ABAP 7.4, I thought of a simple ABAP program to compare the performance between ABAP program consisting of classic SQL(multiple joins & currency conversion)  against the ABAP program calling HANA calculation view directly (classic SQL with joins & currency conversion logic converted into HANA calculation view).

  • ABAP with SQL embedded  – SQL query with multiple joins & currency conversion in ABAP program. vs
  • ABAP program calling HANA calculation view directly  a.k.a code push down to HANA DB.

You can manage ABAP program, modeling & ABAP profiling all in one place with SAP HANA studio. You need to install additional ABAP development plugins for eclipse and I used SAP HANA Studio version:  1.0.58.




Below is the screen I captured while profiling ABAP program from HANA studio. ABAP program uses classic SQL to fetch data from BKPF, BSEG (multiple joins) and perform currency conversion using standard function module. Actual database time that it took to execute ~ 24 seconds.

From the image below

Screen 1:
SQL statement navigated from hit list (Screen 3) shows more time consumed at DB during execution. SQL query from screen 1 is later converted into calculation view in HANA DB to improve the performance drastically.

Screen 2:
Snapshot from ABAP profilin g analysis done in HANA studio with database time: ~ 24seconds

Screen 3:
Complete Hit list of ABAP program showing BKPF SQL fetch and currency conversion (Perform CONV_CC) which consumed most of the time. Both the SQL statement and currency conversion is pushed down to calculation view for performance boost.

Screen 4:
Currency conversion code inside - Perform CONV_CC.



ABAP code optimization using HANA 24 seconds to 2 seconds:

SQL query & currency conversion is converted into HANA calculation view and called from SQL query as shown below: ZBC_BSEG_DOC is the dictionary view created from HANA calculation view.




Dictionary view: ZBC_BSEG_DOC

dic_view.jpg

HANA Calculation view:




HANA views can be accessed by standard SQL With ABAP 7.40 they are natively supported in ABAP
  • Mapping to DDIC types possible

ABAP profiling & performance after code push down to HANA

Screen 5: ABAP code optimized for HANA. All SQL joins & currency conversi on pushed down to HANA DB as calculation view CA_BSEG_DOC.

Screen 6:
Proxy ABAP dictionary view generated from HANA calculation view so it can be used in ABAP SQL.

Screen 7:
ABAP profiling snapshot showing approx. 2 seconds spent in database during execution compared to 24 seconds with classic SQL.

Screen 8:
HANA calculation view inside HANA DB.

Screen 9:
Hit list fr om ABAP profiling.

hana_optimized.jpg

No comments: