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.
How to stop a batch control job
Moderators: chulett, rschirm, roy
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
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
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: