How to obtain the starttimestamp of the parent-sequencer

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

Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

How to obtain the starttimestamp of the parent-sequencer

Post by Jdrost »

Hello,

I have several DS-server-jobs grouped into several sequence-jobs. These sequence-jobs are also combined into other sequence-jobs. This hierarchy is 4 levels.

I want to obtain the start-timestamp of the 'highest' sequence-job in the DS-jobs on the lowest level.

Can someone tell me how to do this?

Thanks in advance.

Johannes Drost
Kind regards,

Johannes Drost
rkdatastage
Participant
Posts: 107
Joined: Wed Sep 29, 2004 10:15 am

Post by rkdatastage »

Hi

the routine UtilityGetRunJobInfo will help u to find the start time and end time of a job

i think u had to use this routine and find a logic to get your required output

Thanks
RK
Andal
Participant
Posts: 124
Joined: Thu Dec 02, 2004 6:24 am
Location: Bangalore, India

Post by Andal »

I hope DSJobStartTimestamp will do this. If not write a custom routine to return date and time, then call it in the sequencer and pass this value as a parameter to the server jobs.
Rgds
Anand
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Assign JobHandle = DSJ.ME and then write a loop that uses a call to DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER) to get the parent job, then open up that job and issue the call again until you have found the ultimate parent process and then use another call to DSGetJobInfo to retrieve the start time.
Even with error handling it is just a couple of lines of code when finished and quite fast. I've had to do this before, so I know it works.
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

Post by Jdrost »

What do you mean by '..., then open up that job and issue the call again.'? DSGetJobInfo(jobhandle, DSJ.JOBCONTROLLER) returns a string of the parent-job. How do I vovert this string into a jobhandle?

Below the code I wrote based on your remarks:

JobHandle = CurrentJob

Loop
ParentJob = DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER)
If ParentJob <> DSJE.BADHANDLE Then
JobHandle = ParentJob
Else
Exit
End
Repeat

Is this code correct?

Thanks in advance for your response.

Johannes Drost
Kind regards,

Johannes Drost
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

Post by Jdrost »

I also tried the code below, but this code also did not work (the previous code did not work either):

JobHandle = CurrentJob

Loop
ParentJob = DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER)
If ParentJob <> @NULL Then
ParentJobHandle = DSAttachJob(Parentjob,DSJ.ERRFATAL)
JobHandle = ParentJobHandle
DET = DSDetachJob(ParentJobHandle)
End
Else
Exit
End
Repeat

Could you send me the an example of the code you used?

Thanks in advance.

Johannes Drost
Kind regards,

Johannes Drost
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I used JobHandle = DSJ.ME and you changed that, so that part won't work.
After you get a job name you need to issue a call to DSAttachJob() to open up a new handle and then use that handle for the next call to DSGetJobInfo(). Any more code would only be visible to you if you were a premium member, so I didn't include it.
nisaumande
Participant
Posts: 13
Joined: Fri Aug 11, 2006 11:57 am
Location: Toulouse, France

Post by nisaumande »

About the DSAttachJob function :

I was wondering how it works when you have multiple instances of the same job runing ?

How do DS know which job handle to use as he only get the name of the job ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

When you call DSAttachJob() you need to specify the instance you want, i.e. doing DSAttachJob("MyJob.ThisInstance",DSJ.ERRNONE) will open up that instance.
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

Wrong output from DSGetJobInfo("MyJob", DSJ.JOBCON

Post by Jdrost »

Thanks for your response(s).

I have build a function 'getUltimateParent' based on your response(s), but when I test it it doesn't seem to work correct. To debug the function I write the jobname(s) which are returned by DSGetJobInfo to a text-file.

I have made a testcase of a job of 3 levels:
Job_Level1 (highest level)
Job_Level2 (is called by Job_Level1)
Job_Level3 (is called by Job_Level2)

In Job_Level3 I call getUltimateParent.

The call to DSGetJobInfo only returns the name of the parent-job directly in control of the current job ('Job_Level2'), not the total structure of parent-jobs ('Job_Level1.Job_Level2') as is described in the help-text:'DSJ.JOBCONTROLLER String - name of the job controlling the job referenced by the job handle. Note that this may be several job names separated by periods if the job is controlled by a job which is itself controlled, etc.'.

Is this a bug, or do interpret the helptext wrong?
Kind regards,

Johannes Drost
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I recall that the help text is wrong, which is why I used the loop method I described earlier.
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

Post by Jdrost »

How can I then retrieve the jobHandle of the next parent level? What is wrong in my code?

My code:
JobHandle = DSJ.ME

Loop
ParentJob = DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER)
If ParentJob <> @NULL Then
ParentJobHandle = DSAttachJob(ParentJob,DSJ.ERRFATAL)
JobHandle = ParentJobHandle
End
Else
Exit
End
Repeat
Kind regards,

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

Post by ray.wurlod »

Probably the overwriting of the job handle. Definitely the illegal comparison with @NULL (you must use the IsNull() function to test for null). Failure to detach jobs when done with them probably doesn't help either.

A possiblity would be re-cast this routine so that it could call itself recursively. What does DSGetJobInfo(hJob, DSJ.JOBCONTROLLER) return if the job is not run under control? I suspect it's "" rather than @NULL.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Can you really get the handle of the parent job, at a time if a job is running, you can't get its handle. :?
Success consists of getting up just one more time than you fall.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Of course you can, how else could you determine its running status to be "running"?!
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