DSWaitForJob

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
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

DSWaitForJob

Post by tostay2003 »

I need to wait for 4 or 5 sequences to run before I run another sequence. But these 4 or 5 sequences come within a span of 2 weeks to 1 month. How do I remove the time out option (or) specify particular time for time out??
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

Post by tostay2003 »

I created a new job and had this as first job in a sequence, where I want to wait for two jobs to be completed, before I could move on. I am using the following code in the job control, but this job doesn't wait at all. It compiles and runs properly. and then proceeds to next job in a sequence (I even had conditional ok in the trigger field).

Code: Select all


      ErrorCode = 0
      rtnName = "Wait"


* Attach to Job

      jobHandle1 = DSAttachJob(iJob1, DSJ.ERRWARN)

      If jobHandle1 = 0 Then
         Call DSLogFatal("Invalid job name : ":iJob1,rtnName)
      End
* Attach to Job

      jobHandle2 = DSAttachJob(iJob2, DSJ.ERRWARN)

      If jobHandle2 = 0 Then
         Call DSLogFatal("Invalid job name : ":iJob2,rtnName)
      End

ErrorCode= DSWaitForJob (jobHandle1:',':jobHandle2)
I tried to write a routine and called it from before/after routines. But upon compilation I get warnings that there are no stages in the job.

What am i doing wrong?
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,

hJobU2PM23 is the job handle from DSattach function for job named Updatejob

ErrCode = DSWaitForJob(hJobU2PM23)
Status = DSGetJobInfo(hJobU2PM23, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: Updatejob", "JobControl")
End


Use this code at completion of first job and before start of next job

Ketfos
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DSWaitForJob only waits for a running job to finish. If the job is not running, DSWaitForJob returns immediately. You need a different strategy.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
tostay2003
Participant
Posts: 97
Joined: Tue Feb 21, 2006 6:45 am

Post by tostay2003 »

:o For a while I thought I figured out how to do it.

Next approach what I can think of is to write files from Seq1 and Seq2, and Seq3 Waits for those 2 files written by Seq1, Seq2, using Wait for File Activity (with Do not time out checked).

After that I remove those files (which I will use just to indicate status).

Is this a good approach or should I use another approach?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's a good approach; if you understand it and can maintain it, it's probably the right approach.

If you can afford to have long-running jobs, you might consider a job sequence that does what you require. Use "All" sequencers to govern what executes when.

Code: Select all

Seq1 ------>  
              A  -------> Seq4 -----> A
Seq2 ------>  L                       L  -----> Seq6
              L  -------> Seq5 -----> L
Seq3 ------>  
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Post by vsi »

Next approach what I can think of is to write files from Seq1 and Seq2, and Seq3 Waits for those 2 files written by Seq1, Seq2, using Wait for File Activity ( with Do not time out checked ).
Wait for File Activity is used just for synchronization isnt it??? I guess here the Seq3 need to be started by dsjob or DSRunJob??

Where will it be appropriate to introduce this dsjob or DSRunJob?
Post Reply