The routine works. If you look at the Director afterwards, it shows that the Job is compiled, and if you then try to run it, it runs, no problem. However, if the job is run from job control, whilst it completes with no errors, the job control which runs it falls over with:
Job control process (pid 13976) has failed
That is the only error I get. The routine is posted below, the only argument passed is Job Name
I pinched the job compile logic from a routine I found called "CompileAllJobs" which does in fact work, but I suspect that when run under Job Control, it must leave the job in some indeterminate status, which therefore causes the process to abort.
Would appreciate any comments or ideas about the below code.
Code: Select all
********************************************************************************
** This routine tries to compile the job specified **
** If unsuccessful, will report on it **
********************************************************************************
$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H
RoutineName = "CheckJobCompile"
Equate LOG.WARN.NAME To RoutineName
Equate LOG.OK.NAME To RoutineName
JobsCompiled = ""
CompileStatus = 0
* Get the current job's name and number:
MyJobNo = JobName
SUBR = DSR.SUB.JOB
Key = DSR.SUB.JOB.GETNO
Call @SUBR(Key, MyJobNo)
Dummy1 = "" ; Dummy2 = ""
SUBR = DSR.SUB.JOB
Key = DSR.SUB.JOB.RESERVE
Arg2 = JobName
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
If Key <> "" Then
WarnMsg = DSRMessage("", "Cannot attach to job '%1'", JobName):@FM:Key
Call DSLogWarn(Lower(WarnMsg),LOG.WARN.NAME)
CompileStatus = 0 ; * Unsuccessful compile
End
* try to compile it:
Key = DSR.SUB.JOB.COMPILE
Arg2 = JobName
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
If Key <> "" Or Arg2<1> <> "" Then
WarnMsg = DSRMessage("", "Problems compiling job '%1'", JobName):@FM:Key:@FM:Arg2
Call DSLogWarn(Lower(WarnMsg), LOG.WARN.NAME)
CompileStatus = 0 ; * unsuccessful compile
End Else
JobsCompiled<-1> = JobName
CompileStatus = 1 ; * successful compile
Call DSLogInfo("Job ":JobName:" Successfully Compiled", LOG.OK.NAME)
* Clear the RT_STATUS and RT_LOG files
Ignore = 0
JobNo = DSRGetJob(JobName,Ignore)
Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo
End
Key = DSR.SUB.JOB.RELEASE ; * unlock job, ignoring any errors
Arg2 = JobName
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
Ans = CompileStatus