Page 1 of 1
DSWaitForJob
Posted: Mon Sep 25, 2006 12:27 pm
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??
Posted: Mon Sep 25, 2006 2:27 pm
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?
Posted: Mon Sep 25, 2006 2:38 pm
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
Posted: Mon Sep 25, 2006 3:57 pm
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.
Posted: Mon Sep 25, 2006 5:45 pm
by tostay2003
![Surprised :o](./images/smilies/icon_surprised.gif)
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?
Posted: Mon Sep 25, 2006 11:04 pm
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 ------>
Posted: Tue Sep 26, 2006 6:22 am
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?