Application Development and Automation 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: 
Read only

Parallel processing using starting at new task

0 Likes
7,165

Hi All,

i have used the below code for parallel processing.

CALL FUNCTION 'ZCCR_TABLE_DATA' STARTING NEW TASK  taskname

       PERFORMING f_return_data ON END OF TASK

       EXPORTING

         i_input = _it_count-count

     TABLES

         it_table1 = t_table1[]

    

*&---------------------------------------------------------------------*

*&      Form  return_zrfc

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->TASKNAME   text

*----------------------------------------------------------------------*

FORM  f_return_data USING taskname.

   RECEIVE RESULTS FROM FUNCTION 'ZCCR_TABLE_DATA' 

    IMPORTING

    e_output       = it_result[]  

SO i have debugged the code and found that the data is being calculated in FM, but the  perform f_return_data is not being called. I put an infinite loop in side this perform and try to check in SM50. but in any case it is not called.

Can anyone help me to get a solution on it ??

1 ACCEPTED SOLUTION
Read only

Katan
Active Participant
0 Likes
2,282

HI Andy,

I wrote the following demo program and sample FM code which works for me.  Not sure if you have your wait statement working correctly or if you have used the wrong import param name as I can't see your FM code.

Cheers,

Katan

*&---------------------------------------------------------------------*

*& Report  ZKP_ASYNC_FUNC_TEST

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  zkp_async_func_test.

*----------------------------------------------------------------------*

*       CLASS cl_async_func_controller DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS cl_async_func_controller DEFINITION.

   PUBLIC SECTION.

     CLASS-METHODS: execute_program,

                    response IMPORTING p_task TYPE clike.

     CLASS-DATA: g_result TYPE char10.

ENDCLASS.                    "cl_async_func_controller DEFINITION

*----------------------------------------------------------------------*

*       CLASS cl_async_func_controller IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS cl_async_func_controller IMPLEMENTATION.

   METHOD execute_program.

     break bcuser.

* Can use this to kick off a load of selects in parallel that are not dependent

* and then wait on the results

     CALL FUNCTION 'ZFUNC_ASYNC1'

       STARTING NEW TASK 'TASK1'

       CALLING response ON END OF TASK.

* Without this wait statement the program just completes

* need to set an appropriate time out.  Not too short and not too long

     WAIT UNTIL g_result IS NOT INITIAL UP TO 20 SECONDS.

   ENDMETHOD.                    "execute_program

   METHOD response.

     DATA: l_result TYPE char10.

     break bcuser.

     RECEIVE RESULTS FROM FUNCTION 'ZFUNC_ASYNC1'

       IMPORTING ex_result = l_result.

     g_result = l_result.

     WRITE: l_result.

   ENDMETHOD.                    "response

ENDCLASS.                    "cl_async_func_controller IMPLEMENTATION

START-OF-SELECTION.

   cl_async_func_controller=>execute_program( ).




*********************************************

This is the code for the FM


FUNCTION zfunc_async1.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  EXPORTING

*"     VALUE(EX_RESULT) TYPE  CHAR10

*"----------------------------------------------------------------------

   WAIT UP TO 5 SECONDS.

   ex_result = 'Async 1'.

ENDFUNCTION.


6 REPLIES 6
Read only

Former Member
0 Likes
2,282

Hi,

In which server are you executing the RFC  the name of the group server and destination keyword missing . Also, have a look at the prerequisites.

CALL FUNCTION 'RFC_SYSTEM_INFO'    "Function module to perform

                                     "in parallel 

       STARTING NEW TASK TASKNAME    "Name for identifying this

                                     "RFC call

       DESTINATION IN GROUP group    "Name of group of servers to

                                     "use for parallel processing.

                                     "Enter group name exactly

                                     "as it appears in transaction

                                     "RZ12 (all caps).  You may

                                     "use only one group name in a

                                     "particular ABAP program.

       PERFORMING RETURN_INFO ON END OF TASK

Kindly go through the following link, for better understanding the parallel processing

Implementing Parallel Processing (SAP Library - Background Processing)

Regards,

DPM

Read only

Katan
Active Participant
0 Likes
2,283

HI Andy,

I wrote the following demo program and sample FM code which works for me.  Not sure if you have your wait statement working correctly or if you have used the wrong import param name as I can't see your FM code.

Cheers,

Katan

*&---------------------------------------------------------------------*

*& Report  ZKP_ASYNC_FUNC_TEST

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  zkp_async_func_test.

*----------------------------------------------------------------------*

*       CLASS cl_async_func_controller DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS cl_async_func_controller DEFINITION.

   PUBLIC SECTION.

     CLASS-METHODS: execute_program,

                    response IMPORTING p_task TYPE clike.

     CLASS-DATA: g_result TYPE char10.

ENDCLASS.                    "cl_async_func_controller DEFINITION

*----------------------------------------------------------------------*

*       CLASS cl_async_func_controller IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS cl_async_func_controller IMPLEMENTATION.

   METHOD execute_program.

     break bcuser.

* Can use this to kick off a load of selects in parallel that are not dependent

* and then wait on the results

     CALL FUNCTION 'ZFUNC_ASYNC1'

       STARTING NEW TASK 'TASK1'

       CALLING response ON END OF TASK.

* Without this wait statement the program just completes

* need to set an appropriate time out.  Not too short and not too long

     WAIT UNTIL g_result IS NOT INITIAL UP TO 20 SECONDS.

   ENDMETHOD.                    "execute_program

   METHOD response.

     DATA: l_result TYPE char10.

     break bcuser.

     RECEIVE RESULTS FROM FUNCTION 'ZFUNC_ASYNC1'

       IMPORTING ex_result = l_result.

     g_result = l_result.

     WRITE: l_result.

   ENDMETHOD.                    "response

ENDCLASS.                    "cl_async_func_controller IMPLEMENTATION

START-OF-SELECTION.

   cl_async_func_controller=>execute_program( ).




*********************************************

This is the code for the FM


FUNCTION zfunc_async1.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  EXPORTING

*"     VALUE(EX_RESULT) TYPE  CHAR10

*"----------------------------------------------------------------------

   WAIT UP TO 5 SECONDS.

   ex_result = 'Async 1'.

ENDFUNCTION.


Read only

0 Likes
2,282

The example can work, but usually I use those tools to execute multiple calls, and I increment a counter of requested executions at call statement. In receive methods/forms I decrement the counter. then only wait til counter back to initial value and a fixed duration in cas of aborted tasks.

Regards,

Raymond

Read only

Katan
Active Participant
0 Likes
2,282

Ditto that.  That was just a demo program and you need to make sure that you don't lock out all the system processes (you may upset some of the basis guys), so make sure you factor that in to your design. 

Was in a rush so did not get a chance to make sure you apply all the due diligence checks...

Read only

0 Likes
2,282

No problem, but I would suggest usage of FM like SPBT_INITIALIZE and SPBT_GET_CURR_RESOURCE_INFO of group SPBT to prevent performance problems to arise for other users.

Regards,

Raymond

Read only

0 Likes
2,282

Hi Katan,

i think i missed the Wait until statement. Thanks