Capturing Abort of a 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
memrinal
Participant
Posts: 74
Joined: Wed Nov 24, 2004 9:13 pm

Capturing Abort of a Job

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

Post 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.
Mamu Kim
memrinal
Participant
Posts: 74
Joined: Wed Nov 24, 2004 9:13 pm

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

Post by kduke »

Change the DSLogFatal() to a DSLogInfo().
Mamu Kim
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Post your code again.
Mamu Kim
memrinal
Participant
Posts: 74
Joined: Wed Nov 24, 2004 9:13 pm

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