call another job from job control and wait if it is running

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
catiechase
Participant
Posts: 2
Joined: Tue Dec 07, 2004 1:35 pm

call another job from job control and wait if it is running

Post by catiechase »

I'm trying to use a job control in one job to call another job. I want to wait (sleep) if that other job is running. Multple instances won't really work, so i need to have the controlling job wait to call the job once it has finished.

I'd like to just look up the job status on that job, but I don't have a handle since it was called by a separate process.

The next thing I tried was to run the job DSAttacheJob and if it didn't work, wait (sleep) and try again later. I'm just not quite sure how to make that work.
CatieHannah
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Welcome! You can get the status using the command line program dsjob without needing a job handle. Otherwise, you can try to use DSAttach and see the value returned from a DSGetJobInfo and see if the return value is DSJE.BADHANDLE. I never tried it, but the DS BASIC documentation has to be correct, right? :wink:
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Wait a minute, what do I mean welcome? You've been lurking quite a awhile. How about: Thanks for piping up! :lol:
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Did you try DSWaitForJob(JobHandle) ?


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

Post by ray.wurlod »

DSAttachJob() is necessary before issuing the run request with DSRunJob(). So retrying that function isn't going to help; it's still attached to the controller while it's running.

Try creating a new server job, open its job properties then the Job Control tab. Select a job from the drop down list and click Add Job. Inspect the generated code; it will show you how DSWaitForJob is used.

If you need to use Sleep for some other reason (for example a busy loop that does other things in the meantime) then you need to write a loop that checks to see if the job is still running.

Code: Select all

Loop
While DSGetJobStatus(hJob, DSJ.JOBSTATUS) = DSJS.RUNNING
    * do other things
    Sleep 2    ; * sleep for two seconds
Repeat         ; * loop exits once status is no longer "running"  
This is not a perfect solution, but will get you started.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

The stated issue is that if ControlJob#1 has attached and started TransformJob, how can ControlJob#2 attached to TransformJob and see its status? I don't believe two jobs can have a job handle for the same job simultaneously, but maybe I'm wrong.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
catiechase
Participant
Posts: 2
Joined: Tue Dec 07, 2004 1:35 pm

Post by catiechase »

I'm doing this in the job control of a job, so it is in the BASIC. I can't user the dsjob command from there. But your other suggestion works - I get a return value of 0 if the job is already running. THANKS!!!!

kcbland wrote:Welcome! You can get the status using the command line program dsjob without needing a job handle. Otherwise, you can try to use DSAttach and see the value returned from a DSGetJobInfo and see if the return value is DSJE.BADHANDLE. I never tried it, but the DS BASIC documentation has to be correct, right? :wink:
CatieHannah
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Okay, but you can always issue system command line commands via a CALL DSExecute(....). You can run dsjob as a command. Search the forum for DSExecute for ways folks have used it.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply