Page 1 of 2

calculate Job EndDateTime and Job ElapsedTime.

Posted: Wed Nov 01, 2006 4:37 pm
by vsi
How to calculate

1)Job EndDateTime
2)Job ElapsedTime?

I know JobStartDateTime from "DSJobStartTimestamp".

is there any routine or macro?

Thanks

Posted: Wed Nov 01, 2006 5:48 pm
by lstsaur
Check out Mr. Duke's EtlStats, especially the job DSJobReportDB.

Posted: Wed Nov 01, 2006 6:01 pm
by keshav0307
DSJobStartTimestamp and DSJobEndTimestamp, itself are macros.

try to write a routine yourself,

Posted: Thu Nov 16, 2006 6:15 pm
by vsi
I guess "DSJobEndTimestamp" is not DS Macro.

Thanks
vsi

Posted: Thu Nov 16, 2006 6:21 pm
by narasimha
Use these in your routine

Code: Select all

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

Posted: Thu Nov 16, 2006 6:32 pm
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

Posted: Thu Nov 16, 2006 6:58 pm
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.

Posted: Thu Nov 16, 2006 7:02 pm
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.

Posted: Thu Nov 16, 2006 7:05 pm
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..

Posted: Thu Nov 16, 2006 7:09 pm
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.

Posted: Thu Nov 16, 2006 7:11 pm
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

Posted: Thu Nov 16, 2006 8:26 pm
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?

Posted: Thu Nov 16, 2006 9:33 pm
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.

Posted: Thu Nov 16, 2006 11:01 pm
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?

Posted: Fri Nov 17, 2006 7:14 am
by ray.wurlod
Yes. Notify the documentation fault via your support provider. Use the tokens in JOBCONTROL.H.