The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Applies to:
SAP BI 7.0, SAP ABAP. For more information, visit the Business Intelligence homepage.
Summary
The objective of the article is to outline & explain the performance considerations while using ABAP and
parallel cursor technique in context to SAP BI. The document will also showcase the extent of performance
improvement that can be derived using the technique mentioned above.
Author Bio
Gundeep Singh is working as SAP BI Consultant in Accenture Services Private Ltd and
having extensive experience in implementation of BI/ABAP projects specializing in SCM
areas.
Deepak Somani is working as SAP BI Consultant in Accenture Services Private Ltd and
having extensive experience in implementation of BI/ABAP projects across various functional
areas.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Table of Contents
Pre-Requisites .................................................................................................................................................... 3
Database Access Using Select .......................................................................................................................... 3
Internal Table Operations ................................................................................................................................... 4
Parallel Cursor Technique: Overview ................................................................................................................. 5
Need of Nested loop ....................................................................................................................................... 5
Example/Illustration ......................................................................................................................................... 5
Example of a Nested Loop ........................................................................................................................................... 6
Parallel Cursor Approach: Demystified ............................................................................................................... 6
Sample Code & Demonstration ...................................................................................................................... 6
Nested Loop Using Parallel Cursor: ............................................................................................................................. 6
Performance Data Comparison .......................................................................................................................... 7
Related Content .................................................................................................................................................. 7
Disclaimer and Liability Notice ............................................................................................................................ 8
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Pre-Requisites
Basic understanding of SAP ABAP programming language
Basic understanding of dataflow in SAP BI 7.0.
Efficient Programming involves solving a problem / defining logic as fast as possible while using
system resources as sparingly as possibly. In context to SAP BI, when multimillion records form the
crux of the tool, the significance of efficient ABAP codes is very high. It is highly recommended to
write performance optimized & fine tuned codes for overall health of the system. As a part of this
write up we will look at some of the very basic and simple to use techniques that if followed and
adhered to can result in highly optimized BI systems.
Avoid Select *
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Making use of For All Entries as shown above ensures that we are
selecting only relevant records maintaining best performance
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Modifying a Record
To Copy data from one internal table into another ( where the two internal
tables are exactly the same ) , make use of the statement as shown above.
Example/Illustration
Say our inner internal table has 1000 records. The second loop i.e the inner loop will operate on the basis of
where condition as per the first loop. To suffice this where condition, the control will actually search the
internal table starting from the first record itself, moving till the last (1000th record). The time it takes for
finding the record will increase for the records that have matches at the end of the internal table. That means
the search will take more time to find the 1000th record than the time it takes to search for the 1st or 2nd
record. This as a result increases the loop & run time which further increases the data load time especially in
a real time scenario when the data count is huge and enormous.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Here when WA_EKKO-EBELN =123 the inner loop will execute 1000 times and statement inside the loop will
execute 3 times. This will result in higher data load runs and poor performance. We can optimize the above
using parallel cursor technique as elaborated below:
(b) Read the internal it_ekpo with key wa_ekko-ebeln and use binary search. It will give the starting
index of PO 123 in table it_ekpo.
(c) Loop on table it_ekpo from index got from step2 and also put an exit condition of inner loop.
Control will transfer to outer loop as exit condition passes.
CODE
DATA : it_ekko TYPE STANDARD TABLE OF ekko,
wa_ekko TYPE ekko,
it_ekpo TYPE STANDARD TABLE OF ekpo,
wa_ekpo TYPE ekpo.
DATA : lv_tabix TYPE sy-tabix.
SELECT * FROM ekko INTO TABLE it_ekko.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 6
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
Here when WA_EKKO-EBELN =123 the inner loop will execute 4 times and statement inside the loop will
execute 3 times. This will result in a major performance improvement over the nested loop code elaborated
earlier in the document.
As the tabular detail above demonstrates, using parallel cursor technique we can achieve high level of
performance optimization in SAP BI dataloading processes. The improvement in performance is far more
pronounced when the volume of the data is increased.
Related Content
ABAP Code for Parallel Cursor - Loop Processing
Parallel Cursor Technique
Book - > ABAP Development for SAP BW by Dirk Herzog
For more information, visit the Business Intelligence homepage.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 7
The Power of Performance Optimized ABAP and Parallel Cursor in SAP BI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 8