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: 

Issue in parallel processing in ABAP

Former Member
0 Kudos

Hello Gurus,

I am trying to do paralle processing in ABAP. I am having few issues. I am calling a custom function module in a loop where I pass the invocie number and I want back the amount calcualted (based on some custom logic) in custom function module.

After the parallel processing is finsihed, I want all the amounts for different invocies to be written on output screen. But the issue is, the screen-output does not show all amounts for all invocies passed. Sometimes it shows the amount for last invocie multiple times, sometimes not.

Please help.

LOOP AT GI_VBRK INTO wa_VBRK.
       index = sy-tabix.
       CONCATENATE 'Task' index into taskname. "Generate Unique Task Name
        CALL FUNCTION 'Z_CALCULATE_AMOUNT'
        STARTING NEW TASK taskname
        DESTINATION IN GROUP system
        performing set_function_done on end of task
        EXPORTING
          P_VBELN               = WA_VBRK-VBELN
        EXCEPTIONS
          system_failure        = 1  MESSAGE mess
          communication_failure = 2  MESSAGE mess
          resource_failure      = 3.
      ENDLOOP.
 
    LOOP AT GI_DATA INTO WA_DATA
        WRITE:/ 'AMOUNT'. WA_DATA-AMOUNT.
    ENDLOOP.
form set_function_done using taskname.
    receive results from function 'Z_CALCULATE_AMOUNT'
   importing
      AMOUNT    = v_AMOUNT.
   functioncall1 = done.
    WA_DATA-AMOUNT =  V_AMOUNT.
    APPEND WA_DATA TO GI_DATA.
  endform.              

Regards,

TG

1 ACCEPTED SOLUTION

former_member222709
Contributor
0 Kudos

Hi Tushar,

Just to add to Thomas, in the Function Call 'Z_CALCULATE_AMOUNT', verify the return codes, clear all the work areas before calculating, and add another field 'vbeln' with the amount field to ensure which value is getting repeated.

Ideally, clearing of work areas and addition of 'IF' conditions with return codes will solve your problem. Hope this helps.

Regards,

Pranav.

2 REPLIES 2

ThomasZloch
Active Contributor
0 Kudos

Two remarks at quick glance, you should check and react to return codes <> 0 from the aRFC call and repeat the call e.g. in case of a resource failure (could mean that no processes are available), and also you should maintain global counters for number of processes started and finished, and only start your final output once #finished = #started (remember that these are asynchronous calls). Use the WAIT UNTIL statement for this, see ABAP documentation and please search for available sample code.

Thomas

former_member222709
Contributor
0 Kudos

Hi Tushar,

Just to add to Thomas, in the Function Call 'Z_CALCULATE_AMOUNT', verify the return codes, clear all the work areas before calculating, and add another field 'vbeln' with the amount field to ensure which value is getting repeated.

Ideally, clearing of work areas and addition of 'IF' conditions with return codes will solve your problem. Hope this helps.

Regards,

Pranav.