To Run a Job thro Routines

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
suma
Participant
Posts: 32
Joined: Fri Jun 11, 2004 8:18 am

To Run a Job thro Routines

Post by suma »

I just want to create a simple routine that should run my Job,If the Job failed the error should be logged! Can any one help me out in solving my Problem. I tried writing routines through some examples.But it throws errors
Here is the sample routine,,, Can anyone correct me where i am wrong!!

Hjob1 = DSAttachJob("test1",DSJ.ERRFATAL)
Dummy = DSSetParam(Hjob1,"Param1","Value1")
Dummy = DSRunJob(Hjob1,DSJ.RUNNORMAL)
J1stat = DSGetJobInfo(Hjob1, DSJ.JOBSTATUS)
If J1stat = DSJS.RUNFAILED
Then Call DSLogFatal("Job DailyJob1 failed","JobControl")
End
mleroux
Participant
Posts: 81
Joined: Wed Jul 14, 2004 3:18 am
Location: Johannesburg, South Africa
Contact:

Post by mleroux »

Why write something when it can be written for you?

In designer, go to Job Properties, Job Control tab, drop down the box and select the job you want to generate code for, and click Add Job.

You can of course use the generated code as a template and modify it to your needs.
Morney le Roux

There are only 10 kinds of people: Those who understand binary and those who don't.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Might help to know what errors you are seeing. Also would help to wait for the job to finish before you check its status. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Error checking!!!

You didn't check whether the job was attached successfully, and you didn't check whether DSSetParam succeeded. You (like way too many others) blithely assumed that all would be well, and proceeded to issue a run request. And, as Craig pointed out, you didn't wait for the job to complete before checking its status; when you checked its status was either "starting" or "running".

How do you know the job failed? Do you know that DSJS.RUNFAILED actually means? Is it the same? Are you aware that there are other possibilities (such as DSJS.CRASHED) that your code does not handle?

I have a number of areas of concern with the automatically generated code. which could be improved greatly. It's better than it used to be, but there's a lot more that could be done. Code generated by compiling a Job Sequence is better, in that it retains control (does not abort) but it, too, could be improved.
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