06-29-2018 6:30 AM
Hi All,
I have gone through parallel processing concept of SAP where we are using below statement to achieve it:
'CALL FUNCTION ‘ZPARALLEL_PROCESS_FM’ STARTING NEW TASK lv_taskname
DESTINATION IN GROUP p_rfcgr'
But I wanted to know below:
We have a scenario where we are running a daily batch job and that job has parallel processing logic. But the parallel processing is not getting completed by the time the same job starts again on the very next day. Due to which the output files are generating incorrectly.
How we can control/handle a scenario to make sure the next job should not start until previous job completes or is it possible to make sure the asynchronous job should get complete with in some limited time.
There is a work around, we can write a condition in the report using lock object, we can do lock a table when job starts and unlock when it finishes in between if any the same job triggers again we will put it on wait.
But may i know is there any standard way of handling.
Regards,
Prince Joshi
06-29-2018 6:49 AM
Keep the main program active til end of execution (it would use one process) you can check execution of RFC call using option CALLING method ON END OF TASK. (add a counter when starting a task and decrement it in the end of task method, wait til 0 running tasks)
" Call
DO n TIMES.
ADD 1 TO taskname.
CALL FUNCTION ‘zparallel_process_fm’
STARTING NEW TASK taskname
CALLING method ON END OF TASK.
"
ENDDO.
" Wait
WAIT UNTIL taskname LT '0001'.
" Method
SUBTRACT 1 FROM taskname.
In the main program check that no other job (same name or same report is currently running, don't forget you are running so exit when 2 'R'unning job are found.
" Look for jobs running same program
CALL FUNCTION 'BP_FIND_JOBS_WITH_PROGRAM'
EXPORTING
abap_program_name = lv_repid
status = 'R'
TABLES
joblist = lt_joblist
EXCEPTIONS
OTHERS = 0.
" Exit if 2 jobs
DESCRIBE TABLE lt_joblist LINES lv_nbjobs. " lines( )
06-29-2018 6:49 AM
Keep the main program active til end of execution (it would use one process) you can check execution of RFC call using option CALLING method ON END OF TASK. (add a counter when starting a task and decrement it in the end of task method, wait til 0 running tasks)
" Call
DO n TIMES.
ADD 1 TO taskname.
CALL FUNCTION ‘zparallel_process_fm’
STARTING NEW TASK taskname
CALLING method ON END OF TASK.
"
ENDDO.
" Wait
WAIT UNTIL taskname LT '0001'.
" Method
SUBTRACT 1 FROM taskname.
In the main program check that no other job (same name or same report is currently running, don't forget you are running so exit when 2 'R'unning job are found.
" Look for jobs running same program
CALL FUNCTION 'BP_FIND_JOBS_WITH_PROGRAM'
EXPORTING
abap_program_name = lv_repid
status = 'R'
TABLES
joblist = lt_joblist
EXCEPTIONS
OTHERS = 0.
" Exit if 2 jobs
DESCRIBE TABLE lt_joblist LINES lv_nbjobs. " lines( )
07-03-2018 7:01 AM
Hi Raymond,
Thanks a lot for your inputs.
So, Ideally you mean we should use FM 'BP_FIND_JOBS_WITH_PROGRAM' in the starting of our main program. So, It will check if already the report is executing in parallel or not.
yes it seems to be correct for below statement where we are using END OF TASK method as our main program will still be running:
CALL FUNCTION ‘zparallel_process_fm’ STARTING NEW TASK taskname
CALLING method ON END OF TASK.
But what if we not using statement CALLING ZMETHOD END OF TASK (as i asked this in my question).
In that case, this FM 'BP_FIND_JOBS_WITH_PROGRAM' will not be useful because main program would have been finished the execution and in parallel the FM would be executing/waiting. So, how we can make sure that all the asynchronous FMs must execute before the next job starts(as it is a daily job).
Regards,
Prince Joshi
07-03-2018 8:12 AM
Then you could
07-03-2018 11:26 AM
Yes Correct, I think we have to go for Lock objects only to make sure process is consistent.
Thanks Raymond 🙂
07-01-2018 12:54 AM
07-08-2019 12:01 PM
Yes Correct!!
Parallel Processing means Asynchronous Type of function module.
Generally, when we call a function module, it will stop the current program , execute another ( called ) program and then returns control to original program and again origi...Read More