Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP: How to create parallel processing

Former Member
0 Kudos

Dear experts,

Requirement:

I have to select data of Sales Order (VBAP) with minical numbers of criteria - not filtered by date!!!!!. Hence it needs to select huge amount of records from the table. The key point is that to select data as fast as possible.

My Idea:

Per my investigation aroun the internet, I consider to use the concept of 'Parallel Processing'. I've tried doing like the following link: http://sapignite.com/learn-parallel-processing-in-abap/ . It doesn't work. I understand the concept of coding, but I don't get the concept of congiure at RZ12.

I'm an ABAPer. I've no idea on the BASIS side. Please advice me how to configure or communicate the BASIS team.

Thanks in advance.

Cheers,

Nattapong I.

1 ACCEPTED SOLUTION

manukapur
Active Participant
0 Kudos

Parallel Processing works in ABAP.

Please check the following posts

http://scn.sap.com/thread/1884700 and

http://scn.sap.com/thread/3271539.

If you have to select data from huge number of records, I suggest a few things for quick access.

1. create index on the table (but a lot of if's with it)

2. for Searching, obviously you would be already using a lot of key fields use still use binary search.

3. Use Open SQL. Its faster than Native SQL.

Regards,
Manu

13 REPLIES 13

manukapur
Active Participant
0 Kudos

Parallel Processing works in ABAP.

Please check the following posts

http://scn.sap.com/thread/1884700 and

http://scn.sap.com/thread/3271539.

If you have to select data from huge number of records, I suggest a few things for quick access.

1. create index on the table (but a lot of if's with it)

2. for Searching, obviously you would be already using a lot of key fields use still use binary search.

3. Use Open SQL. Its faster than Native SQL.

Regards,
Manu

hendrik_brandes
Contributor
0 Kudos

Hi,

first off all: Is your report already slow or are you in the designing process?

I would suggest, to use SQL-cursors because they provide a proper package mechanism. Try to minimize the data to transfer ( amount of rows and columns ), use joins and grouping funcatinality of the database.

The usage of parallel processing would be my last option, because you will have to separate the access and data transfer and merge them manual after all data has been read. It is possible, of course, but I think a good SQL and a fast ABAP can handle a lot of data in an acceptable time.

Kind regards,

Hendrik

tolga_polat
Active Participant
0 Kudos

Hi Nattapong,

For starting new task you dont need basis. in your example you can use DESTINATION IN GROUP DEFAULT if you want to write destination check CALL FUNCTION - STARTING NEW TASK help

here is the part from help :

Addition 1

... DESTINATION IN GROUP {group|DEFAULT}

Effect

If you specify IN GROUP as the destination, this supports parallel execution of multiple function modules on a predefined group of application servers of the current AS ABAP. This variant of aRFC is also known as parallel remote function call (pRFC).

For group, you must specify a data object of the type RZLLI_APCL from the ABAP Dictionary, one that is either initial, or one that includes the name of an RFC server group created in transaction RZ12. If DEFAULT is specified or if group is initial, all currently available application servers of the current AS ABAP are used as the group. Only one RFC server group may be used within a program. During the first asynchronous RFC using the addition IN GROUP, the specified RFC server group is initialized. 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.

If the function module cannot be executed on any of the application servers, because not enough resources are available at present, a predefined exception RESOURCE_FAILURE is raised, to which, in addition to the other RFC exceptions, a return code can be assigned. For this exception, the addition MESSAGE is not permitted.


check this link for code example : http://scn.sap.com/thread/3346895

Former Member
0 Kudos

Nattapong,

Parallel processing is mostly used when we have a lot of data to process and the current process is slow. One of the best examples is the program RBDAPP01 for parallel processing of Idocs.

Personally, I have not come across a scenario where we use parallel processing for data selection. To make this process faster, there are many suggestions provided above.

1. Consider creation of index. Run a trace and see what index is being used by SAP.

2. Use joins which are faster than multiple selects.

3. Use the packet size option on the select statement.

Thanks,

Vikram.M

Former Member
0 Kudos

Hi All,

Thanks everyone for your replies. Your comments are very helpful for me. By the way, as I communicate the functional person, he accept the concepr of creating idices and change a bit requirements which is now fine.

Cheers,

Nattapong I.

0 Kudos

Well done 😉 ! Its not worth to implement everything what is possible to gain the rest 10% performance...

former_member193464
Contributor
0 Kudos

Nattapong,

as i see your requirement(forgive if i am mistaken) you need to fetch huge amount of data from database... I think using cursors would be the best way to do it(using package size if its very huge)....
coming on to parallel programming the main part is, can you segregate your data extraction such that it can be appended to the main table in later stage.... if yes then Best would be to create a RFC F.M. and using STARTING NEW TASK and PERFORMING f_end ON END OF TASK. Inside this FM extract your data. and call this FM in loop so that many instances can be run but on different criterias (change the segregation criteria from the loop)

f_end you have to append all the data into your final table.
hope it make sense. thanks.

Former Member
0 Kudos

Hello,

in case of parallel processing you have to use JOB_OPEN and JOB_CLOSE fm.

loop at it into wa.  [ it holds huge of records..]

if counter = '100'.

g_c_counter = g_c_counter + 1.

perform parallel_processing.

else.

counter = counter + 1.

append wa to it_new.

endif.

endloop.

Form parallel_processing.

concatenate 'parallel'  g_c_counter into g_c_id separated by '_'.

EXPORT ITAB = it_new to shared buffer indx(ST) id g_c_id compression on.

jobname = g_c_id.

call function job_open.

after executing this fm you get jobcount (job number).

SUBMIT 'ZREP' with p_count = g_c_counter via <jobname> number <jobcount> and return.

call function job_close.

endform.

Report ZREP.

parameters: p_count type char5.

concatenate 'parallel' p_count into g_c_id separated by '_'.

IMPORT ITAB = it_new from shared buffer indx(ST) id g_c_id .

Delete from shared buffer indx(ST) id g_c_id.

if it_new is not initial.

select.......

endif.

Follow the above mentioned way......its a very good way to handle huge records and its performance is too good........it gives better performance...

Thanks

Sabyasachi

Former Member
0 Kudos

Hi,

If you want to use PARALLEL PROCESSING then you have to use the FM SPBT_INITIALIZE and then create a FM of your own and write the select query inside it and call it in a new task.

Regards,

Santanu.

arindam_m
Active Contributor
0 Kudos

Hi,

RZ12 setting are required to process in parallel as all programs are assigned process like Dialogue, Database and Background. A set number of such processes are possible for parallel execution in a sever. To keep things safe like A single program taking up all processes and Hardware resources and clog the server each program run by user is allocated a fixed amount such as say 1 Dialogue, 1 Background processing and 1 Dialogue and memory and Processing that's associated with it. That's

why programs also give dump at at times due to lack of available runtime memory its not that all runtime memory in server is used but its just that the amount allocated to a user is used up.

Coming back to the RZ12 setting. To do parallel processing your user profile will have to be configured to use more of these processes at one time which is usually not allowed as server administration best practises.

Cheers,

Arindam

Former Member
0 Kudos

LOOP AT t_likp INTO likp.

Read table t_lips into lips with key vbeln = likp-vbelnLOOP AT t_lips INTO lips FROM

w_index.

if sy-subrc EQ 0.

LOOP AT t_lips INTO lips FROM w_index.

-

do processing----

AT END OF <Key field> (here it is VBELN)

EXIT. " Exit of the inner loop pn t_likp or else it will go into infinite loops

ENDAT.

ENDLOOP.

ENDIF.

ENDLOOP.

may be help full answer...

reward me....

Venkat_Sesha
Employee
Employee
0 Kudos

Hi Nattapong

Use the Select statement with OPEN CURSOR and FETCH CURSOR Concept that will be usefull for your case. Search the F1 Help on these two Topic.

Parallel cursor is a process for processing the data. For Example.

You are looping Table A and inside you need to Fetch the data of Table B.

Generally most of the guys do Like this. Loop TABA and inside this Loop Loop TABB. This will eat up the memory and your program will take long time to execute and some times Memory or Time out Issues. So to Over come this. We Use Parallel Cursor logic.

Loop TABA.

Read the Index of the TABB with TABA Key.

Start Looping the TAB B with From Addition in the Loop Syntax.

Hope this helps...

Former Member
0 Kudos

REPORT  zparallel_cursor.

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.

Read table t_lips into lips with key vbeln = likp-vbelnLOOP AT t_lips INTO lips FROM

w_index.

if sy-subrc EQ 0.

LOOP AT t_lips INTO lips FROM w_index.

-

do processing----

AT END OF <Key field> (here it is VBELN)

EXIT. " Exit of the inner loop pn t_likp or else it will go into infinite loops

ENDAT.

ENDLOOP.

ENDIF.

ENDLOOP.