Page 1 of 1
Running & error handling of Parallel Job from Server Rou
Posted: Thu Oct 09, 2008 2:00 am
by Abhijit180
Hi
Please any body share some routine snippet with a perfect error handling of the parallel job call.
TIA
Abhi
Posted: Thu Oct 09, 2008 4:46 am
by ray.wurlod
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
ErrMsg = ""
RoutineName = "MyRoutine"
hJob = DSAttachJob(TheJobName, DSJ.ERRNONE)
JobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If JobName Matches "'-'1N0N"
Then
ErrMsg = "Could not attach job."
End
Else
* Optionally include call to DSPrepareJob here to "reset if required".
GoSub SetParameters
* how this is done depends heavily on where you get your parameter values
ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
If ErrCode Matches "'-'1N0N"
Then
ErrMsg = "Run request failed. Error code = " : ErrCode
End
Else
ErrCode = DSWaitForJob(hJob)
ExitStatus = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
Ans = ExitStatus
Begin Case
Case ExitStatus = DSJS.RUNOK
Call DSLogInfo("Job finished OK", RoutineName)
Case ExitStatus = DSJS.RUNWARN
Call DSLogWarn("Job finished with at least one warning.", RoutineName)
Case ExitStatus = DSJS.RUNFAILED
Call DSLogWarn("Job failed (aborted).", RoutineName)
Case ExitStatus = DSJS.STOPPED
Call DSLogWarn("Job stopped by operator.", RoutineName)
Case @TRUE ; * otherwise
Call DSLogWarn("Job exit status is " : ExitStatus : ".", RoutineName)
End Case
End
ErrCode = DSDetachJob(hJob)
End
If ErrMsg > ""
Then
Call DSLogWarn(ErrMsg, RoutineName)
Ans = -1
End