Page 1 of 1

Posted: Mon Jun 30, 2003 1:18 pm
by kduke
Emma

I batch job stops in the Director just like any other job. If you stop a batch job then it does not stop until all the running jobs stop. You can also tell them to stop. It is a little tricky to programatically stop a job if that is what you need but within a batch job if you have a stop statement then it will stop. To stop the jobs running in the background is a little more complicated.

Posted: Mon Jun 30, 2003 2:55 pm
by kduke
Emma

Here is the code to stop a job:

$INCLUDE DSINCLUDE JOBCONTROL.H
RunHandle = DSAttachJob(JobName, DSJ.ERRNONE)
JStat = DSGetJobInfo(RunHandle, DSJ.JOBSTATUS)
ContinueFlag = @true
begin case
case JStat = 0
JobStatus = 'Running'
JStat = DSStopJob(RunHandle)
case JStat = 1
JobStatus = 'Finished'
case JStat = 2 ; * Finished with warnings
JobStatus = 'Finished (see log)'
case JStat = 3
ContinueFlag = @false
JobStatus = 'Aborted'
case JStat = 11
JobStatus = 'Validated OK'
case JStat = 12 ; * Validated with warnings
JobStatus = 'Validated (see log)'
case JStat = 13
* ContinueFlag = @false
JobStatus = 'Failed validation'
case JStat = 21
JobStatus = 'Has been reset'
case JStat = 96
ContinueFlag = @false
JobStatus = 'Aborted'
case JStat = 97
* ContinueFlag = @false
JobStatus = 'Stopped'
case JStat = 98
JobStatus = 'Finished'
case JStat = 99
JobStatus = 'Compiled'
case @true
ContinueFlag = @false
JobStatus = 'Not Compiled'
end case
if ContinueFlag then
JStat = DSStopJob(RunHandle)
end
JStat = DSDetachJob(RunHandle)

Thanks Kim.

Kim Duke
DwNav - ETL Navigator
www.Duke-Consulting.com

Posted: Sun Jul 27, 2003 1:05 am
by spracht
Emma,

I don't know if you still need this. I assume that you don't mean how to stop a batch job from director, but from within itself. I think there are at least 2 possibilities:

- 'Call DSLogFatal(....)' would abort the controlling job
- 'Return' would pass control back to the caller, i.e. the batch job would end, but not abort. You could also do a 'goto exitlabel' to a label in your program where no processing follows.

Stephan

Posted: Sun Jul 27, 2003 6:43 pm
by ray.wurlod
Buried in Kim's code you would see a function called DSStopJob.
I think this is the function you seek.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518