Page 1 of 1

The DSJ.JOBELAPSED bug

Posted: Wed Jul 04, 2007 3:40 am
by thurmy34
Hi,
I just discovered that DSJ.JOBELAPSED return 0 when a job start before midnight and end after.
It bother me a little so i wrote this :

Code: Select all

* Gestion du passage de Minuit (pas de l'execution sur plusieurs jour)
                     JobStart=DSGetJobInfo(Action <ActionOrder, ParallelOrderWait, COL_HANDLE>,DSJ.JOBSTARTTIMESTAMP)
                     JobEnd=DSGetJobInfo(Action <ActionOrder, ParallelOrderWait, COL_HANDLE>, DSJ.JOBLASTTIMESTAMP)
                     DayJobStart=Iconv(Field(JobStart," ",1),"D-YMD[4,2,2,")
                     DayJobEnd=Iconv(Field(JobEnd," ",1),"D-YMD[4,2,2,")
                     NbDay=DayJobEnd-DayJobStart
                     HMJobStart=Iconv(Field(JobStart," ",2),"MTS")
                     HMJobEnd=Iconv(Field(JobEnd," ",2),"MTS")
                     if NbDay=0 then
                        TempExec=HMJobEnd-HMJobStart
                     end
                     else
                        Midnight=Iconv("23:59:59","MTS")
                        HMJobStart=Midnight-HMJobStart
                        TempExec=HMJobEnd+HMJobStart
                     end
                     TempExec=Oconv(TempExec,"MTS")

Posted: Wed Jul 04, 2007 1:08 pm
by ray.wurlod
Had you downloaded my date routines you might have saved yourself some design effort.

Reuse, recycle.

Posted: Thu Jul 05, 2007 7:11 am
by thurmy34
Hi Ray
Your routines are fine but i don't understand the bold part of this code
(from the AddYears routine)

Ans = Iconv(NewYear "R%4" : "-" : OriginalMonth : "-" : NewDay "R%2", "DYMD")

Posted: Thu Jul 05, 2007 9:29 am
by ray.wurlod
It's a way of formatting to ensure leading zeroes. Look at the Fmt() function for possible values. Following an expression with a space and a format designator is another way in DataStage BASIC to achieve the same result. I could equivalently have written:
Ans = Iconv(Fmt(NewYear,"R%4") : "-" : Fmt(OriginalMonth,"R%2") : "-" : Fmt(NewDay,"R%2"), "DYMD")

Posted: Thu Jul 05, 2007 11:05 am
by kduke
There is a routine included with EtlStats which will calculate the elapsed time because of this bug.