Page 1 of 1

Capturing Abort of a Job

Posted: Wed Feb 23, 2005 6:52 am
by memrinal
I am using a job to run several job. This Job has a sequential file as it input which contains the names of the jobs to be run. This job is supposed to run each job from the file. For this i have a transform routine which runs the job and writes the status in a status file.
This whole thing is working fine when the jobs in the list are run with status DSJS.RUNOK and DSJS.RUNWARN.
But when a job from the list aborts - status DSJS then even the main job which is calling all the other jobs also aborts. How can i prevent the main job from aborting. the job that calls the other jobs has a routine that looks like this
JobHandles = DSAttachJob(JobName,DSJ.ERRNONE)
ErrCode = DSWaitForJob(JobHandles)
JobHandles = DSPrepareJob(JobHandles)
ErrCode = DSWaitForJob(JobHandles)
RunErr = DSRunJob(JobHandles, DSJ.RUNNORMAL)
begin case
case RunErr = DSJE.BADHANDLE
call DSLogFatal("Bad Job Handle", JobName)
case RunErr = DSJE.BADSTATE
call DSLogFatal("Bad Job State", JobName)
end case
ErrCode = DSWaitForJob(JobHandles)

ErrCode = DSGetJobInfo(JobHandles, DSJ.JOBSTATUS)

begin case
case ErrCode = DSJS.RUNFAILED
call DSLogFatal("Job Run Failed", JobName)
Result = 3
case ErrCode = DSJS.RUNOK
call DSLogInfo("Job Completed Successfully", JobName)
Result = 1
case ErrCode = DSJS.RUNWARN
call DSLogWarn("Job Completed with Warnings", JobName)
Result = 2
case ErrCode = DSJS.STOPPED
call DSLogWarn("Job was Stopped by User", JobName)
Result = 4
end case
if RunErr <> 0 Then
ErrCode = DSDetachJob(JobHandles)
Abort
End
ErrCode = DSDetachJob(JobHandles)
Ans = Result
where JobName is the name of the job to be run

Posted: Wed Feb 23, 2005 7:31 am
by kduke
If I understand your question correctly then delete the lines with "Abort" on them. This will keep the main job from aborting.

Next time mark your code with the Code button and not the Quote button.

Posted: Wed Feb 23, 2005 7:39 am
by memrinal
Hi Duke,
Thanks for the tip. I did remove the "abort" but still the main job thats calling the other jobs is getting aborted. is there anyway i can prevent this.

Posted: Wed Feb 23, 2005 7:40 am
by kduke
Change the DSLogFatal() to a DSLogInfo().

Posted: Wed Feb 23, 2005 7:41 am
by kduke
Post your code again.

Posted: Wed Feb 23, 2005 7:49 am
by memrinal
Thanks a lot Duke,
it worked by changing the DSLogFatal to DSLogWarn. Actually i want to capture a warning when a job aborts.
Thanks a lot
Mrinal