|
Blogs
I will step through each area of the code describing what I'm doing. The situation: We have an internal table LT_DATA that is used to loop and build up BDC related data. At the end of VBELN we have all the data in our BDC table to be called. We need the program to wait and display the result of the called BDC. STEP 1: The LC_PER constant stores the percentage value of unused work processes to make available to our report. data: lv_free_threads TYPE i, STEP 2: Get the number of free work processes IF sy-subrc <> 0. STEP 3: Calculate how many sessions we'd like to run in parallel lv_thread = 0. STEP 4: Loop through the data building your BDC data perform build_BDC tables it_bdctab. STEP 5: At the end of VBELN and at the time to call the BDC insert our code STEP 6: Perform a DO loop. Since we don't know how many times we need to call it and since we need to control how many sessions we generate STEP 7: Increment the number of threads we are currently using STEP 8: Check if the number of threads we are using is still within our limit. STEP 9: Give the thread a unique number and call the tRFC. Notice we perform a subroutine at the end of the task. In this subroutine we'll decrement the number of active threads we are using * Call remotely enable function in update task. In this function we call the normal BDC transaction. IF sy-subrc <> 0. STEP 10: If the tRFC fails then try again but first decrement the number of used active threads. Beware not to entire an infite loop if an error is issued. Only do this if it's a technical error otherwise you should exit the DO loop in this case as well. I received SY-SUBRC = 3 on occasion so I implemented this code to retry the execution which resolved the issue. ELSE. EXIT. ENDIF. ELSE. SUBTRACT 1 FROM gv_active_threads. ENDIF. ENDDO.
ENDLOOP. IF sy-subrc = 0. STEP 11: Wait until all active threads are completed. This number is decremented in the subroutine below and incremented each time the RFC is called. PERFORM display_results. COMMIT WORK AND WAIT. ENDIF. STEP 12: On return of the call BDC we decrement the number of active threads counter. When it's zero the program will execute. DATA: lv_order TYPE vbeln. * Get Response from Threads. SUBTRACT 1 FROM gv_active_threads. ENDFORM. " UPDATE_ORDER Kevin Wilson is a senior interface consultant for QData USA Inc. and founder of ERPGenie.COM Add to: del.icio.us | Digg | Reddit
| |||||||||||||||||||||