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