What is CrazyEngico.com (CE)?

CrazyEngico (CE) is a one-stop solution for interview questions and answers, domain knowledge, e-learning, tutorials, articles and many more learning material.
e-learning - Intelligent e-learning tutorials and articles
Domain Knowledge Learn about various business domains/verticals such as Banking, Financial, Insurance, Healthcare and many more...
Interview Questions and Answers - Post your questions and answers. 1000+ database of ready questions and answers available to prepare for an interview.
Tutorials - 300+ video tutorials from beginner to expert level.
Articles - 300+ technical articles to understand concepts.
Forum - A technical forum to post your queries/responses.

Ads
Sap - Performance Tuning Using Parallel Cursor
Views: 1973 | Votes: 0        0

Sap - Performance Tuning Using Parallel Cursor

Author: Suresh Kumar Parvathaneni

Nested Loops – This is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.

Program using Normal Nested Loop:

REPORT ZNORMAL_NESTEDLOOP.

TABLES:
likp,
lips.

Data:
t_likp type table of likp,
t_lips type TABLE OF lips.

data:
W_RUNTIME1 TYPE I,
W_RUNTIME2 TYPE I.

START-OF-SELECTION.
select *
from likp
into table t_likp.

select *
from lips
into table t_lips.

get RUN TIME FIELD w_runtime1.

loop at t_likp into likp.
loop at t_lips into lips where vbeln eq likp-vbeln.
endloop.
endloop.

get RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.

write w_runtime2.

Nested Loop using Parallel Cursor:

REPORT zparallel_cursor2.

TABLES:
likp,
lips.

DATA:
t_likp TYPE TABLE OF likp,
t_lips TYPE TABLE OF lips.

DATA:
w_runtime1 TYPE i,
w_runtime2 TYPE i,
w_index LIKE sy-index.

START-OF-SELECTION.
SELECT *
FROM likp
INTO TABLE t_likp.

SELECT *
FROM lips
INTO TABLE t_lips.

GET RUN TIME FIELD w_runtime1.
SORT t_likp BY vbeln.
SORT t_lips BY vbeln.

LOOP AT t_likp INTO likp.

LOOP AT t_lips INTO lips FROM w_index.
IF likp-vbeln NE lips-vbeln.
w_index = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.

GET RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.

WRITE w_runtime2.

Analysis report: Runtime in microseconds:
Iteration 1:
Normal Nested Loop: 34,796,147
Using Parallel Cursor: 63,829

Iteration 2:
Normal Nested Loop: 38,534,583
Using Parallel Cursor: 56,894

Iteration 3:
Normal Nested Loop: 34,103,426
Using Parallel Cursor: 50,510

Article Source: http://www.articlesbase.com/programming-articles/sap-performance-tuning-using-parallel-cursor-324225.html

About the Author

Suresh P is an SAP Consultant and has authored several tips and tutorials on various SAP Technical topics. Some of his articles are available at http://www.SAPTechnical.com and SAP SDN.


Copyright © 2017 CrazyEngico.com. All rights reserved.
CrazyEngico.com is not responsible for the content and CrazyEngico.com does not evaluate or guarantee the accuracy of any CrazyEngico.com content.
Please read our terms of service agreement before using this site.

feedback