Before/After routines for checking job completion

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
johnno
Participant
Posts: 50
Joined: Wed Mar 05, 2003 5:33 am

Before/After routines for checking job completion

Post by johnno »

I am trying to use before/after routines to set the UserStatus depending on the JobStatus of a job (am using UserStatus as requested by our support people so they can check jobs within our scheduling software). From reading the manuals I get the impression that I could set the UserStaus at the start of a job and again at the end of the job depending on the JobStatus by using before/after routines - but I can't get this to work. I don't seem to have access to the macros DSJobStatus, DSJobName, etc. and the DSJobStatus value seems to differ from the value returned by DSGetJobInfo(DSJ.ME, JOBSTATUS). The manual also refers to using the DSWaitForJob and DSGetJobInfo (which I use in DSBasic jobs but have never used in a pictoral job). How and where do I do this? Am I barking up the wrong tree? Should I be doing this in an entirely different way?

As usual, any help greatly appreciated.

Thanks in advance.

John
ariear
Participant
Posts: 237
Joined: Thu Dec 26, 2002 2:19 pm

Post by ariear »

If you understood that UserStatus is actually an exit status (which OS shells can interpret like 'errorlevel' or $? ) that it's not. DSUserStatus is a way to comunicate between DataStage jobs only. You can set it up in a Job/routine by writing your own utility transform routine something like:

UtilitySerUserStatus(Arg1)
$include DSINCLUDE JOBCONTROL.H
Call DSSetUserStatus(Arg1)
Ans=0

Now a subsequent DSGetJobInfo can get the value that was set by this routine.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Before/After routines for checking job completion

Post by ray.wurlod »

johnno wrote:I am trying to use before/after routines to set the UserStatus depending on the JobStatus of a job (am using UserStatus as requested by our support people so they can check jobs within our scheduling software). From reading the manuals I get the impression that I could set the UserStaus at the start of a job and again at the end of the job depending on the JobStatus by using before/after routines - but I can't get this to work. I don't seem to have access to the macros DSJobStatus, DSJobName, etc. and the DSJobStatus value seems to differ from the value returned by DSGetJobInfo(DSJ.ME, JOBSTATUS). The manual also refers to using the DSWaitForJob and DSGetJobInfo (which I use in DSBasic jobs but have never used in a pictoral job). How and where do I do this? Am I barking up the wrong tree? Should I be doing this in an entirely different way?

As usual, any help greatly appreciated.

Thanks in advance.

John
Yes, you're barking up the wrong tree, for the simple reason that, while the after-job subroutine is executing (remember that this is part of the job) the status of the job is, necessarily, always RUNNING.

What you need is an external mechanism, perhaps a job sequence, perhaps job control code, perhaps an operating system command line interface such as dsjob, to interrogate the status of the job and, once the job is no longer running, the job status is what you require. If the job was run in normal mode, there are three possibilities; finished OK, finished (see log), and aborted.

There are, however, twelve possible job status values; you can find these in JOBCONTROL.H in the dsinclude sub-directory in each project. Constants for each status value have names beginning with DSJS., for example DSJS.RUNOK.

If you're doing this in a sequence, run one or more links from the job activity that runs the job to other activities (for example to a notification activity). You will then see, on the Triggers tab for the job activity, the ability to detect the job's exit status and other information, based on which your job sequence can decide what to do next.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply