Skip to Content

Document to demonstrate only one instance of active job is running for a single Job

Hi,

Please go through below to know how to keep only one instance of batch job active.

Requirement :

Keep only one instance of active job is running for a single Job

Solution:

SAP  provided a standard program to handle this scenario. The program name is RSBTONEJOB2.


Please find the below steps :-


1. Create a variant for the program which you want to schedule the batch job.


2. Create a variant for  RSBTONEJOB2 with job name , report name and variant. I create the variant ‘DEMO_VARIANT’.

   

   

   

3. Go to SM36, create a job with same name give in variant of RSBTONEJOB2 .

    

4. Click on step, enter abap program name RSBTONEJOB2 and variant DEMO_VARIANT. Start the job immediately and save.

   

5. Go to SM37 and you can see the job ZDEMO_KEEP_ONE_ACTIVE_INSTANCE will be in active status.

6. Copy the job and release it. The second job will be finished with below job log.

   

7. The log of first job

   

This scenario is been asked number of times in SCN. Hope this helps to fellow SCN member.

Therefore I request all SAP folks to share there comments and add something i missed here.

Thanks

-Always Learner

2 Comments
You must be Logged on to comment or reply to a post.
  • Hi,

    this scenario only displays, that there could be more instances running, but is there any way how to stop the second step of the job from running once there already is one? I would like to schedule a job for importing of idocs hourly, but there are situations, when one hour is not enough to process all the idocs.

    So once the previous run of idocs import is not finished, I would not like to start another one. How to achieve this?

  • The program does that. However, it will not guarantee that only one instance of the job will be running at any given time. You could easily go to SM37 and copy an instance of a job and tell it to start now, effectively giving you two running instances of the job. The program will(!) however guarantee that for this very periodic scheduled job it will not add another instance to already running instances, effectively resulting in only one running instance if no manual interference

     

    However, IMHO this RSBTONEJOB2 has a serious shortcoming over RSBTONEJOB as it will not run with jobs having multiple steps.

     

    Cheers

    Jens