calculate Job EndDateTime and Job ElapsedTime.

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

vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

calculate Job EndDateTime and Job ElapsedTime.

Post by vsi »

How to calculate

1)Job EndDateTime
2)Job ElapsedTime?

I know JobStartDateTime from "DSJobStartTimestamp".

is there any routine or macro?

Thanks
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Check out Mr. Duke's EtlStats, especially the job DSJobReportDB.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

DSJobStartTimestamp and DSJobEndTimestamp, itself are macros.

try to write a routine yourself,
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Post by vsi »

I guess "DSJobEndTimestamp" is not DS Macro.

Thanks
vsi
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Use these in your routine

Code: Select all

JobStarted = DSGetJobInfo(JobHandle,DSJ.JOBSTARTTIMESTAMP)
JobEnded = DSGetJobInfo(JobHandle,DSJ.JOBLASTTIMESTAMP)
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
vsi
Premium Member
Premium Member
Posts: 507
Joined: Wed Mar 15, 2006 1:44 pm

Post by vsi »

i am trying to use this in the Derivation Field.
is something wrong? this field showing in Red color.

Code: Select all

 DSGetJobInfo(DSJ.ME,DSJ.JOBLASTTIMESTAMP)

Thanks
vsi
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You cannot use it in a derivation. It has to be called from inside a routine.

I wrote a quick routine for you. I have formatted the output in a presentable way,
You can change as per your needs.(Of course there is always scope for improvement)

Create a new routine from Manager/Designer
Name it whatever you like say DisplayJobDetails
Rename Arg1 to InputJobName
Copy and paste below code into your code window.
Click on Compile, then Test.
Enter the job name for which you want details of in the InputJobName column.
Click Run.. You see the results you want to see :!:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

      JobHandle = DSAttachJob(InputJobName,DSJ.ERRFATAL)
      JobStarted = DSGetJobInfo(JobHandle,DSJ.JOBSTARTTIMESTAMP)
      JobEnded = DSGetJobInfo(JobHandle,DSJ.JOBLASTTIMESTAMP)
      JobTimeElapsed = DSGetJobInfo(JobHandle,DSJ.JOBELAPSED)
      Ans = Char(10) :'Job Start Time = ' : JobStarted : Char(10): 'Job End Time = ' : JobEnded : Char(10): 'Job Elapsed Time in seconds = ' : JobTimeElapsed
Get back if you have trouble running this.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

All of these CAN be used in derivations, if DSJ.ME is used for the job handle argument. Most of them have associated macros.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

ray.wurlod wrote:All of these CAN be used in derivations, if DSJ.ME is used for the job handle argument. Most of them have associated macros.
Nice to know that.
Ray, can you elaborate on that please..
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

These functions appear under DS Function in the operand menu. DSJ.ME is a DS Constant, and can serve as the job handle for the current job. This is made clear in on-line help. All DS macros are predefined as calls to these functions with DSJ.ME as the job handle.
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 »

Narsimha,
Thank you very much for your routine.

But i wonder why this is not possible to use

Code: Select all

DSGetJobInfo(DSJ.ME,DSJ.JOBLASTTIMESTAMP)
inside Derivation?

But i can use

Code: Select all

DSGetJobInfo(DSJ.ME,DSJ.JOBSTARTTIMESTAMP)
inside Derivation field,WithOUT any problem.

did someone tried using these in Derivation field?

Thanks
vsi
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Strange!
The derivation column does not recognize

Code: Select all

DSGetJobInfo(DSJ.ME,DSJ.JOBLASTTIMESTAMP)
but I tried(with only one T)

Code: Select all

DSGetJobInfo(DSJ.ME,DSJ.JOBLASTIMESTAMP)
Now it does not complain, I run the job in the log I get this warning message

Code: Select all

Variable "InfoType" previously undefined.  Empty string used.
Which does not surprise me.
My question is why does the Derivation column complain for the first piece of code and not for the second(which is not a valid "InfoType")

Another question is it possible to get the DSGetJobInfo(DSJ.ME,DSJ.JOBLASTTIMESTAMP) from the derivation or this information has to be got from a routine later?
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Are you choosing the DS Constants from the drop down list from the Expression Editor menu?

Review the header file JOBCONTROL.H in the DSINCLUDE subdirectory on the server. This contains all of the constants, as well as DEFFUN declarations for the DS Functions and the DS Macro definitions.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

ray.wurlod wrote:Are you choosing the DS Constants from the drop down list from the Expression Editor menu?
Yes.

I checked the JOBCONTROL.H file it does have an entry

Code: Select all

Equ DSJ.JOBLASTTIMESTAMP  To 11     ;* Server date/time of job last finished: "YYYY-MM-DD HH:MM:SS"
Now if you check in the DS Constants, going through the drop down list from the Expression Editor menu, I find DSJ.JOBLASTIMESTAMP but no DSJ.JOBLASTTIMESTAMP.
All documentation refer to DSJ.JOBLASTTIMESTAMP but none to DSJ.JOBLASTIMESTAMP

Is something wrong here?
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes. Notify the documentation fault via your support provider. Use the tokens in JOBCONTROL.H.
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