Page 1 of 1

Reset a job automatically

Posted: Tue Sep 08, 2009 7:19 am
by parag.s.27
Hi All,

I am having a requirement where I need to design an After Job Subroutine that will be called in each job via job properties.

As soon as the job has status aprt from Finished OK, the after job subroutine should be called and it should reset the job. I wrote the following code: -

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H   
 
Input=Trim(InputArg)   
JobStatus  = DSGetJobInfo(DSJ.ME,DSJ.JOBINTERIMSTATUS)   
  
If JobStatus ne 1 
Then ErrCode = DSRunJob(DSJ.ME,DSJ.RUNRESET)
Else ErrCode = 0

ErrorCode = ErrCode;
  
Here The InputArg is doing nothing.
The above code is not giving any result. I think DSJ.ME does not run with ErrCode. When I wrote a separate function with following code then it reset the job for which the job name is provided: -

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H   
 
Input=Trim(InputArg) 
handle = DSAttachJob(Input,DSJ.ERRFATAL)  
JobStatus  = DSGetJobInfo(handle,DSJ.JOBSTATUS)   
  
If JobStatus ne 1 
Then ErrCode = DSRunJob(handle,DSJ.RUNRESET)
Else ErrCode = 0
DSDetachJob(handle)
ErrorCode = ErrCode;

Posted: Tue Sep 08, 2009 7:24 am
by chulett
You can't reset a job 'after job' as it actually hasn't finished yet. Why do you think you need to do this? Your job control should reset before running, not after. IMHO.