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: 

Parallel processing u0096 starting new task

Former Member
0 Kudos

Hello,

I am trying to understand how to process mass data in parallel. I was successfully able to call a function module in a new task (actually in my case I have 4 tasks). The program runs and executes entirely, but I can’t get any results.

In the call back form I have inserted a RECEIVE RESULTS statement, but maybe I don’t have the syntax correct, I just can’t get the results. Maybe in the RECEIVE RESULTS statement I’m not putting the task name... Your help would be great.

Here is my code:


DESCRIBE TABLE izusername LINES recordcount.
time = sy-uzeit.
batchsize = recordcount / cpus. "CPUS = # of WPs

LOOP AT izusername.
  MOVE-CORRESPONDING izusername TO izusername1.
  APPEND izusername1.
  IF sy-tabix = batchsize.
    task_count = task_count + 1.
    CONCATENATE time task_count INTO task_name.
    CALL FUNCTION 'Z_GET_USER_NAME'
      STARTING NEW TASK task_name DESTINATION IN GROUP DEFAULT
      PERFORMING return_info ON END OF TASK
      TABLES
        izusername       = izusername1.
    REFRESH izusername1.
    CLEAR izusername1.
  ENDIF.

ENDLOOP.

LOOP AT izusername3.
  WRITE:/ izusername3.
ENDLOOP.

FORM return_info USING task_name.
  receive results from function 'Z_GET_USER_NAME'
    tables
        izusername       = izusername2.
  APPEND LINES OF izusername2 TO izusername3.
  refresh izusername2.
ENDFORM.

Thank you.

ss

1 ACCEPTED SOLUTION

christian_wohlfahrt
Active Contributor
0 Kudos

Hello SS!

You're missing a wait statement. The receiver-routine can only be triggered, if execution of your calling program is in a wait status - otherwise it would corrupt the sequentiell program execution to much.

Have a look at FM WBB_CHANGE_ARTICLE_FIND, e.g. routine bdcp2_analysis to see a working parall execution.

        
do.
"table filling
      curr_proc_nr = send - receive.
"max process handling
WAIT UNTIL receive >= send.
        curr_proc_nr = send - receive.

CALL

if sy-subrc = 0.
send = send + 1.
endif.

exit when all packs are sent.

enddo.
    WAIT UNTIL receive >= send .

...
form receiver.
receive = receive + 1.
endform.

Regards,

Christian

6 REPLIES 6

christian_wohlfahrt
Active Contributor
0 Kudos

Hello SS!

You're missing a wait statement. The receiver-routine can only be triggered, if execution of your calling program is in a wait status - otherwise it would corrupt the sequentiell program execution to much.

Have a look at FM WBB_CHANGE_ARTICLE_FIND, e.g. routine bdcp2_analysis to see a working parall execution.

        
do.
"table filling
      curr_proc_nr = send - receive.
"max process handling
WAIT UNTIL receive >= send.
        curr_proc_nr = send - receive.

CALL

if sy-subrc = 0.
send = send + 1.
endif.

exit when all packs are sent.

enddo.
    WAIT UNTIL receive >= send .

...
form receiver.
receive = receive + 1.
endform.

Regards,

Christian

0 Kudos

Thanks Christian! That did the trick.

0 Kudos

Another question I wanted to ask, can I submit the FM in parallel and perform wait at 2 (or more) different times in the same program? What I mean is, there are two parts of the program that take the longest time. I want to process both parts in parallel processing, separately.

I want to:

1) Create separate FMs of those two parts and submit the first part in parallel processing.

2) Receive all information from 1st part, do some processing and/or data manipulation on it.

3) Then submit the 2nd part in parallel processing also. This would be dependent on data received from 1st part.

Can that be done? I'm assuming as long as the task names are different, this should be possible. The only concern that I have is, that I don't want the 2nd part to be processed before I get the results from the 1st part.

Thanks.

ss

0 Kudos

Hi SS,

There's a weblog that I have written on Parallel Processing sometime back. You might want to take a look at that as well. Here's the link - /people/sap.user72/blog/2005/04/22/parallel-processing--an-introduction

Regards,

Anand Mandalika.

0 Kudos

Hello SS,

when you use 'WAIT UNTIL receive >= send.' in step 2), you will receive all FMs of first processing. Be sure, your wait is placed <i>after</i> loop for sending your FMs in step 1).

Then no general problem should occur, this scenario is a quite common one.

Regards,

Christian

0 Kudos

Thanks, Anand. That was a informative intorduction.

It (actually Hint #3) talks about executing in background. Is that possible in 4.7 (6.20) or even 4.6 (4.6D)? I'm trying to figure out if there is a way to use the background work processes instead of dialog work process.

Thanks,

ss