How to stop a batch control job

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
Post Reply