Page 1 of 1

Forcing the JobStatus in a Routine

Posted: Mon Aug 08, 2005 11:06 pm
by davidnemirovsky
I am trying to set a special JobStatus for jobs which reject rows based on certain business rules. The job is invoked using dsjob run from a third party scheduler and support needs to know when this situation occurs.

I am using a Transform Routine invoked in a derivation of a Reject link.

If we get any rejects then I need to set the JobStatus to something other than 0 or 1 or 2 (ie. 3 or 4 or 5...).

At the moment my Routine looks like this:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H
Equate RoutineName To "SetRejectionStatus"
Call DSSetUserStatus("2")
MyStatus = DSGetJobInfo(DSJ.ME, DSJ.JOBSTATUS)
Call DSLogInfo("MyStatus=" : MyStatus, RoutineName)
Ans = "Rejects"
MyStatus=0 is what I get from the DSLogInfo statement.

How do I accomplish this?

Posted: Mon Aug 08, 2005 11:14 pm
by ArndW
David,

I'm away from a DS installation (and documentation), but I think there is another code in the DSGetJobInfo() call for the User status vs. the job status.

Posted: Mon Aug 08, 2005 11:19 pm
by davidnemirovsky
Arnd,

I believe that would be 'DSJ.USERSTATUS' but that's not what I'm after.

I want to force the JOB status not the UserStatus so that the third party controlling tool gets a different return code from the unix script that runs dsjob.

Does that make more sense?

Posted: Tue Aug 09, 2005 12:10 am
by davidnemirovsky
After a bit of lateral thinking...

How would I output the UserStatus of a job in a unix script?

Posted: Tue Aug 09, 2005 12:16 am
by chulett
Isn't there a -userstatus option for the dsjob command? :?

Posted: Tue Aug 09, 2005 12:56 am
by ray.wurlod
You don't get any mechanism for altering the job status apart from DSLogWarn and DSLogFatal, and setting the ErrorCode argument of a before/after subroutine to a value of other than 0. All of these except DSLogWarn cause the status to be 3; DSLogWarn causes the status to be 2 unless the job aborts for some other reason.

That's why user status is there. It's yours. Job status isn't: it's theirs.

The only other choice you might have is DSStopJob(DSJ.ME), which will change the status to DSJS.STOPPED - not, I suspect, your desired outcome.

Posted: Tue Aug 09, 2005 6:45 am
by chulett
But - as noted - you can launch the job with the -userstatus option and then it (if set) will be returned as the exit status when the job completes. :wink:

Seems to be exactly what David is after.

Posted: Tue Aug 09, 2005 7:55 am
by roy
Hi,
AFAIK,
Using dsjob will result in more info then just the user status.
Download Ken's kshell script from ADN and apply your changes if needed.
Basicly it outputs the stdout & stderr to a file and sample the file to gain whatever data you need.
I implemented such a script to function as a ^M DS jobs launcher utility.

IHTH,

Posted: Tue Aug 09, 2005 4:42 pm
by davidnemirovsky
I suppose I should have taken a step back and not gone into solutions mode :oops:

So now I'm running a sequence using DSJOB but I've changed a UserStatus of a job within that sequence. If I use the -userstatus option I pressume I'll get the UserStatus of the sequence and not the job? Is this correct? If so, I should use something like a DSJOBINFO from the unix script? Is there such a command? I've been looking through the doco but can't remember where it's located!

Thanks for everyone's input. Nothing like being a little rusty and then getting thrown in the deep end!