Sei sulla pagina 1di 7

11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

Home
ABAP
Welcome
Register

Faça seu pedido Faça seu pedido Faça seu

Articles
Certifications
Downloads
Featured Article
What People Have To Say About Us!!
Forum

Search
search site Go

Subscribe to our mailing list

email address

Learn Parallel Processing in ABAP – Speed up ADVERTISE HERE

Performance
webmaster@sapignite.com
Jul 8th, in SAP ABAP, by Ajay

Have you ever thought of achieving parallel processing using ABAP. Check out how you can do this so as Chat with SAP Ignite
Offline
to best utilize your current infrastructure for better performance.

Categories
ABAP Debugger
ABAP Interview Guide
Articles
Author : Ajay Certifications
Code Inspector
Author's Website | Articles from Ajay Coding Challenge
Data Dictionary
Ajay is a Functional Consultant in Supply Chain Management. He is a SAP Certified SCM APO Downloads
consultant and ABAP Developer. He is also involved in SAP implementations, Migration and Support Enhancement & User Exit
activities as a Consultant. Follow me on Facebook Featured Article
Free Access to SAP IDES system
Parallel Processing in ABAP GUI
Home
Every ABAPer would have definitely encountered issues regarding performance tuning. Usually we use SAP ABAP
trivial methods of optimizing the performance. SAP HANA
Unicode
In this article we would be covering topic for parallel processing in ABAP with respect to asynchronous Webdynpro For ABAP
RFC Function Modules. Slight different perspective for performance tuning. What people have to say about us!!

The idea behind this would be Asynchronous call of a remote-capable function module using the RFC
interface.

To understand the concept we would take a simple example where we would use
‘BAPI_MATERIAL_GET_DETAIL’ to fetch the Material Description from the Material Number and then
we will try to optimize the performance using parallel processing.

So the Program WITHOUT any parallel processing would look like.

sapignite.com/learn-parallel-processing-in-abap/ 1/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

_____________________________________________________________________

REPORT ZMATERIAL_WITHOUT_PARALLEL.
TABLES : MARA.
DATA : BAPIMATDOA TYPE BAPIMATDOA,
BAPIRETURN TYPE BAPIRETURN.
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.

LOOP AT S_MATNR.
CALL FUNCTION ‘BAPI_MATERIAL_GET_DETAIL’
EXPORTING
MATERIAL = S_MATNR-LOW
IMPORTING
MATERIAL_GENERAL_DATA = BAPIMATDOA. Find us on Facebook

write : BAPIMATDOA-MATL_DESC.
SAP Ignite
ENDLOOP.
Like 985
_____________________________________________________________________
985 people like SAP Ignite.
Here every time the during loop execution the control would wait for the Function Module to return its
value only then the loop will continue with the next record.
H ardik Ramesh Ram Kumar S omesh Koundiny
Leandro
a
In this case only One Work Process is busy executing your program it does not consider other work
processes even if they are sitting idle.

Let us have a look on the program first and then we will try to understand in detail.
S itharam S habbir N av y asri M ano Rajathi

_____________________________________________________________________ F acebook social plugin

REPORT ZMATERIAL_DISPLAY_PARALLEL.
TABLES : MARA.
DATA : BAPIMATDOA TYPE BAPIMATDOA,
BAPIRETURN TYPE BAPIRETURN.
My journey to ABAP Certification 307
DATA : SYSTEM TYPE RZLLI_APCL, comment(s)
taskname(8) type c, How to prepare for ABAP Certification 251
comment(s)
index(3) type c,
snd_jobs TYPE i,
Get Free Access to SAP IDES system 188
rcv_jobs TYPE i, comment(s)
exc_flag TYPE i, SAP ABAP interview questions and answers
mess TYPE c LENGTH 80. 64 comment(s)
TYPES : BEGIN OF type_material,
Tutorial for interactive forms by Adobe using
desc TYPE maktx, Webdynpro for ABAP 42 comment(s)
END OF type_material. Most frequently asked Differences in ABAP
interview 39 comment(s)
DATA : Material type table of type_material with header line. How to Implement a BADI in SAP ABAP
with Tutorial 39 comment(s)
data: functioncall1(1) type c. Consuming a Web Service in ABAP 38
constants: done(1) type c value ‘X’. comment(s)
What is SAP HANA ? 36 comment(s)
SELECT-OPTIONS S_MATNR FOR MARA-MATNR. My journey to PI 7.1 Certification
(C_TBIT44_71) 30 comment(s)
system = ‘parallel_generators’. ” RFC Server Group

LOOP AT S_MATNR.
index = sy-tabix.
CONCATENATE ‘Task’ index into taskname. ” Generate Unique Task Name
CALL FUNCTION ‘BAPI_MATERIAL_GET_DETAIL’ STARTING NEW TASK taskname
DESTINATION IN GROUP system
performing set_function1_done on end of task
EXPORTING
MATERIAL = S_MATNR-LOW
EXCEPTIONS
system_failure = 1 MESSAGE mess
communication_failure = 2 MESSAGE mess
resource_failure = 3.
CASE sy-subrc.
WHEN 0.
snd_jobs = snd_jobs + 1.

WHEN 1 OR 2.
MESSAGE mess TYPE ‘I’.
WHEN 3.
IF snd_jobs >= 1 AND
exc_flag = 0.
exc_flag = 1.

WAIT UNTIL rcv_jobs >= snd_jobs

sapignite.com/learn-parallel-processing-in-abap/ 2/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

UP TO 5 SECONDS.

ENDIF.

IF sy-subrc = 0.
exc_flag = 0.

ELSE.

MESSAGE ‘Resource failure’ TYPE ‘I’.

ENDIF.

WHEN OTHERS.

MESSAGE ‘Other error’ TYPE ‘I’.

ENDCASE.
ENDLOOP.

WAIT UNTIL rcv_jobs >= snd_jobs.

loop at material.
write : material-desc.
endloop.

form set_function1_done using taskname.

rcv_jobs = rcv_jobs + 1.

receive results from function ‘BAPI_MATERIAL_GET_DETAIL’


IMPORTING
MATERIAL_GENERAL_DATA = BAPIMATDOA.
BAPIRETURN = BAPIRETURN.
functioncall1 = done.

APPEND bapimatdoa-matl_desc TO material.


ENDFORM.

_____________________________________________________________________

Things to keep in mind, before we start coding.

RFC server group

For group, you must specify a data object of the type RZLLI_APCLfrom the ABAP Dictionary. This
is usually one of the RFC server group created in transaction RZ12. In our case it is “parallel_generators”.

For each asynchronous RFC where the group is specified, the most suitable application server is
determined automatically, and the called function module is executed on this.

Below is the values configured for the Server Group which we are using.

SYNTAX :

CALL FUNCTION func STARTING NEW TASK task

DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]


Parameter list
[{PERFORMING subr}|{CALLING meth} ON END OF TASK].

sapignite.com/learn-parallel-processing-in-abap/ 3/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

With this statement, you are instructing the SAP system to process function module calls in parallel.
Typically, you’ll place this keyword in a loop in which will divide up the data that is to be processed into
work packets.

Calling program is continued using the statement CALL FUNCTION, as soon as the remotely
called function has been started in the target system, without having to wait for its processing to be
finished.

———————————-

CALL FUNCTION ‘BAPI_MATERIAL_GET_DETAIL’ STARTING NEW TASK skname

———————————–

———————————-

——————————————- .

It creates Different task name TASK in a separate work process. Each such task executes “form
set_function1_done” in a separate work process.

We have defined a subroutine set_function1_done as the callback routine, which is executed


after terminating the asynchronously called function module. For subroutine, you must directly specify a
subroutine of the same program. For method, you can enter the same specifications as for the general
method call.

The statement WAIT UNTIL rcv_jobs >= snd_jobs makes sure that all the call to the asynchronous
RFC call has been completed after which we are ready to write the remaining logic for the program.

Result : The run time analysis of both the program are given as below.

Both the Program was executed for 200 material numbers as input.

With parallel Processing

Without Parallel Processing

Clearly the program with parallel processing is around 50% more effective than the normal program
considering 200 materials as input.

sapignite.com/learn-parallel-processing-in-abap/ 4/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

Next time when you face any similar scenario , don’t feel helpless come back read and surprise your
functional tracker with the enhanced performance.

Like this post? Share it!

Faça seu pedido

Faça seu pedido

Faça seu pedido

ADVERTISE HERE
Faça seu pedido

User Comments

It is rally a good article… Keep it up..

Ramesh
July 18, 2011

REPLY

Thank’s For Your Help !!!

SGSONG
February 15, 2012

REPLY

Good documentation Vijay.. Thanks for sharing

Saravanan
March 13, 2012

sapignite.com/learn-parallel-processing-in-abap/ 5/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

REPLY

Good blog; however, you’re not mentioning the processor load of the
actual RFC’s when you do your measurement. True, the main program
trond
April 25, 2012
takes shorter time, but the total load on the application server is higher.
Might be worth considering!

REPLY

Very usefull post. Thanks for sharing and keep posting.

Eryanta
May 2, 2012

REPLY

Very useful in understanding the parallel processing concept. Thnx.

Ebrahim
May 30, 2012

REPLY

Hi,

vivek I am not using the RFC, when i am using the normal function module can i
August 27, 2012
use the above technique…

REPLY

Hi Vivek,
You can use for all the FMs for which the processing type of the FM if
it is remotely enabled.

Cheer
Ajay Ajay
August 27, 2012

REPLY

Thanks Ajay …

vivek
August 27, 2012
REPLY

Leave a Reply

Name

E-mail

URL (optional)

sapignite.com/learn-parallel-processing-in-abap/ 6/7
11/6/12 Learn Parallel Processing in ABAP – Speed up Performance « SAP Ignite

Submit

Copyright Terms Recent Comments


SAP IGNITE @ 2012 All product names on this Hi Raj, The installation shown above is for
web site are trademarks of the companies that own MiniSAP which is used to explore new
them. Sapignite.com is not affiliated with SAP AG ABAP Features. Youby admin
in any way. SAP AG is the registered trademark
holder of SAP, SAP R/3, mySAP, ABAP, xApps, Hi Syed, The issue would be resolved soon
NetWeaver, and other proprietary terms. The once the system is refreshed. Cheers Team
technical information on this site is verified to the SAP Igniteby admin
greatest extent possible, however, any information
Hi Nasir, You have the following clients
found on this site is used at the site visitor's own
which can be used for customization. Client
risk. Sapignite.com reserves the right to correct any
errors or omissions in any portion of this site at any 400: Customizinby admin
time without obligation.

sapignite.com/learn-parallel-processing-in-abap/ 7/7

Potrebbero piacerti anche