Page 1 of 1

How to pause job execution for availability of the job

Posted: Mon Sep 30, 2013 10:30 am
by katragadda86
Hi All,

we have a scenario where job A will be used by sequencers X and Y and we can not make job A multiple instance because of a limitation with the ABAP stage RFC connections.

If X and Y sequencers are started at the same time, one of the sequencers will fail because job A will already be in 'running' status from the other sequencer.

Is there a way we can make the second sequencer wait for the job to become available instead of aborting? something like get job status, if it is not in ready to run status, wait for 30 seconds and re check the job status...

We don't have any external scheduling tools...we run our jobs from director, on demand.

Appreciate your help!


Thanks.
Preethi

Posted: Mon Sep 30, 2013 11:05 am
by chulett
You could write a custom routine, use the API to check the status of the status of the job in question and then do whatever seems appropriate should it be running. Sleep, check again... repeat as needed. Use a routine activity stage before the job that may need to wait.

Posted: Mon Sep 30, 2013 11:24 am
by ArndW
Oddly enough, I wrote a function today that does exactly that (although it uses a list of jobs).
The basic skeleton, without the error handling and other calls typed in from memory so there might be some syntax errors is:

Code: Select all

JobHandle=DSAttachJob("YourJobToWaitFor",DSJ.ERRNONE)
Ans = -1
LOOP UNTIL(JobHandle=0)
   JobStatus = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
   IF JobStatus <> DSJS.JOBRUNNING
   THEN
      JobHandle = DSDetachJob(JobHandle)
      JobHandle = 0 ;** so we exit the loop
      Ans = 0 ;** return OK status
   END
   ELSE SLEEP 10 ;** sleep 10 seconds before checkig again
REPEAT

Posted: Tue Oct 01, 2013 1:19 am
by arunkumarmm
Is it not possible to make another copy of the job?

If not maybe you can also simply create a dummy file 'running.txt' at the beginning of the job and delete it in after job sub routine. And use wait for file activity's 'wait for file to disappear' in either of the job sequence to determine the completion of the job.