Run and Reset if Required

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
theverma
Participant
Posts: 91
Joined: Tue Jul 18, 2006 10:41 am
Location: India

Run and Reset if Required

Post by theverma »

Hi everybody,

I am using dsjob command to run Datastage Jobs.
Online Manual doesnot refer anything regarding the parameter which should be used for running the job with 'Run and Reset if required' Option using dsjob.
We have a '-mode' option but this has only three options : NORMAL,RESET,VALIDATE
But my requirement is to run a job with 'RUN and RESET if required' which we got in Datastage Designer.

And also please tell me how to use more than one parameter in dsjob command.
Do we have to comma(,) between different parameters?

Thanks in Advance
Arun
Arun Verma
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

While multiple parameters *can* be on the command line, you can only use one mode at a time. To emulate the 'Reset if Required then Run' functionality of Sequence jobs, you'll need a script that does 3 things:

1. Checks the status of the job to be run
2. If the job is in an Aborted state, issue the RESET dsjob command
3. Then issue the actual dsjob NORMAL command to run the job

Searching should return at least two complete examples of scripts that do that posted here, from what I recall. Perhaps even a Windows .bat example as well, not certain, but whatever you find can certainly be adapted.

:idea: You can also examine the job control code any Sequence job with a Job Activity stage using that option has generated to see how it's done with BASIC.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

dsjob with option "RESET IF REQD THEN RUN"

Post by ds2000 »

Use following code in .bat file. First command resets the job in any state and resetting a job takes few seconds. Then second command runs it.

C:\myserver\APPS\Ascential\DataStage\Engine\bin\dsjob -server myserver -user myuser -password mypassword -run -wait -mode RESET myproject myjob

C:\myserver\APPS\Ascential\DataStage\Engine\bin\dsjob -server myserver -user myuser -password mypassword -run -wait -mode NORMAL myproject myjob
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

dsjob with option "RESET IF REQD THEN RUN"

Post by ds2000 »

Use following code in .bat file. First command resets the job in any state and resetting a job takes few seconds. Then second command runs it.

C:\myserver\APPS\Ascential\DataStage\Engine\bin\dsjob -server myserver -user myuser -password mypassword -run -wait -mode RESET myproject myjob

C:\myserver\APPS\Ascential\DataStage\Engine\bin\dsjob -server myserver -user myuser -password mypassword -run -wait -mode NORMAL myproject myjob
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

chulett wrote: 1. Checks the status of the job to be run
2. If the job is in an Aborted state, issue the RESET dsjob command
3. Then issue the actual dsjob NORMAL command to run the job
ds2000 has given you the dsjob command to issue a RESET, and then a NORMAL run, which would take care of steps 2 and 3 above.

Regarding step 1, use the following BASIC code to get the job status-

Code: Select all

DSGetJobInfo(DSAttachJob(JobName, DSJ.ERRNONE), DSJ.JOBSTATUS) 
gateleys
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or - since we're talking about a script - capture and interrogate the output from the -jobinfo option. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

chulett wrote:Or - since we're talking about a script - capture and interrogate the output from the -jobinfo option. :wink:
In which case you will have to extract just the first field for the job status and disregard the rest of the information that the -jobinfo option returns.
gateleys
theverma
Participant
Posts: 91
Joined: Tue Jul 18, 2006 10:41 am
Location: India

Post by theverma »

Thank you Friends,

I got your idea regarding RESET ing a job and then run.
But I am still facing problems while running dsjob with parameters.

I am running this command :
D:\Ascential\DataStage\Engine\bin\dsjob -run -param ApplicationCode=Invocation ID -wait -jobstatus PPInterface Create_Files.Invocation ID

We are trying to integrate TIVOLI Workload Schedular(TWS) with Datastage.We are planning to execute all the Datastage Jobs from TWS.

(1) When we run the above command directly from TWS it gives problems.It Does not start the Job.

(2) When I run this command in the Command Prompt of the Datastage server , this worked fine

(3) And Also we tried executing a batch file containing this command from TWS.It also worked fine.

Now my question is why we are not able to run the command directly from TWS.

Please Suggest

Thanks
Arun
Arun Verma
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What 'problems' does it give? Can you post the actual errors?

ps. I would never have an Enterprise Scheduler execute dsjob directly, it should always be wrappered in a script that sets up the proper environment. Etc. IMHO.
-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 »

Craig has almost certainly identified the problem, without saying so. I believe that the TWS process has not executed the DataStage dsenv script and therefore does not have the appropriate environment variables set.

Once you post the actual error messages we will be on firmer ground with our diagnoses.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
theverma
Participant
Posts: 91
Joined: Tue Jul 18, 2006 10:41 am
Location: India

Post by theverma »

Hi Friends,

One more observation to add on is that when we execute dsjob command without parameter from TWS,it works fine.

Thanks and Regards,
Arun
Arun Verma
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

Easiest way out... schedule your job the normal way via the DataStage gui's. Then look at what DataStage puts into the scheduler, if you put that in TWS it will work.

On Unix it works the same with crontab. If you even want to go a step further you can make sure that DataStage first sees your own "crontab" in its path and then you can plugin your own scheduler more directly into DataStage. Little experience with DataStage on Windows so I don't know whether it would work there as well.
In theory there's no difference between theory and practice. In practice there is.
theverma
Participant
Posts: 91
Joined: Tue Jul 18, 2006 10:41 am
Location: India

Post by theverma »

Hello Friends,

I am closing this post as I have got the solution to my problem.

Thanks a lot for all your support.
And also one learning i want to share.
If we want to use multiple parameters in dsjob comand we have to use it like this :
dsjob -run -param P1=V1 -param P2=V2 -wait -Jobstatus Project_Name JobID
Arun Verma
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

theverma wrote:One more observation to add on is that when we execute dsjob command without parameter from TWS,it works fine.
Ah... then - as you've discovered - your syntax was wrong.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply