Periodic Batch Jobs or Background Jobs have a possibility of overlapping in SAP, especially, when the Batch Job runs in a high frequency like 5 mins or less. If the active Job doesn’t finish in 5 mins next Batch Job will be started in parallel to the currently active Job. Therefore, you could end up having the same Background Jobs running in parallel. This behavior can result in wrong processing of data and locking issues.
To avoid having overlapping Batch Jobs use standard program RSBTONEJOB. You need to set up the program RSBTONEJOB as the first step of the Batch Job. Variant of this program should be setup in such a way that parameter ‘JOBNAME’ is the same Job name you are trying to avoid overlapping.
Let’s assume you need to set program ‘RBDMIDOC’ which processes change pointers every 15 minutes and the name of the Background Job is ‘PROCESS_CHANGE_POINTERS’.
Usually, the Background Job is set up as below with one step.
If you suspect this Job can run for more than 15 minutes, follow the steps below to adjust the Background Job not to overlap.
Steps to Avoid the Overlapping of Batch Jobs.
Step 1: Save Variant for RSBTONEJOB with the Background Job Name.
There are several ways to save Variants for programs using transaction se38. The easiest way is to execute the program in se38 and fill in the selection screen parameters, then save it. This is the most common;ly known method to save Variants. Below, I will show another, less common way to save Variants.
Go to transaction se38 and set the program name as RSBTONEJOB. Then, select ‘Variants’ option and go to ‘Change’ mode.
In the next step, provide a Variant name and click on ‘create’. You can provide any meaningful name for the Variant.
Use the background Job name you are trying to avoid overlapping as the ‘JOBNAME’ selection parameter. In this example, we are trying to stop Batch Job ‘PROCESS_CHANGE_POINTERS’ being overlapped.
Click on ‘attribute’.
Provide the Variant description in the next step and save.
Step 2: Find the Background Job in Status ‘Released’ using Transaction SM37.
If you have already created the Batch job, you can find currently running job through transaction sm37. If you have not yet created the Batch Job, create it using transaction sm36 with the step sequence as shown in Step 4.
Go to sm37 transaction and provide the Job Name, Job Status selection and From/To Date selection, then press ‘Execute’.
Step 3: Change the Status of the Released Batch Job to ‘Scheduled’.
This step is important as we need to stop the Batch Job till we correct the Batch Job steps.
Select the Job with ‘Released’ status. This is the next Job which is queued up to start. Then go to the menu ‘Job’ then select ‘Released->Scheduled’.
Step 4: Add Overlapping Avoidance Program RSBTONEJOB to Batch Job.
In this step, we add the program ‘RSBTONEJOB’ with Variant ‘PROCESS_CHANGE’ we created in Step 1 as the first Step of the Background Job ‘PROCESS_CHANGE_POINTERS’.
Now, edit the Job steps of the Job we put on hold in Step 3.
Go to sm37, select the Job in ‘Scheduled’ status, then select Change.
Using the highlighted tools, add program RSBTONEJOB as the first step of the Background Job.
Step 5: Monitor the Batch Job.
If a Job runs more than 5 mins subsequently created Job will be canceled from the 1st Step of the Job.
If you have any questions on how to avoid overlapping Batch Jobs, please leave a comment below.