Job report syntax and logic
Posted: Fri May 04, 2007 8:53 am
I'm creating some jobs to do job reports. Firstly, I have the names of the jobs that I want statistics for defined in a table. I put these into a file so that I can loop through the file and obtain the statistics.
I've attached the code (which doesn't compile at this stage) which is still a WIP, but would like some guidance as to whether this is a smooth process, where it could be improved and whether my logic is flawed in any way.
The aim is to write the statistics back into a file and upload that into a database for reporting......
This is the error that I get when compiling:
I've attached the code (which doesn't compile at this stage) which is still a WIP, but would like some guidance as to whether this is a smooth process, where it could be improved and whether my logic is flawed in any way.
The aim is to write the statistics back into a file and upload that into a database for reporting......
This is the error that I get when compiling:
Here's the code:Compiling: Source = 'RT_BP110/JOB.333537651.DT.1431754350', Object = 'RT_BP110.O/JOB.333537651.DT.1431754350'
**************************************************************************************************?
0084 On error
^
End of Line unexpected, Was expecting: '!', '=', "AND", "OR", "LT", "LE",
"GT", "GE", "NE", "EQ", "MATCH", "GOSUB", "GOTO"
0090 End
^
End of Line unexpected, Was expecting: END, "REPEAT", "UNTIL", "WHILE"
0092 Call DSLogFatal("Cannot open file ":Pathname, "JobControl")
^
WARNING: Text found after final END statement
Label 'ErrorExit' not defined
Array 'DSJ.DSGetJobInfo' never dimensioned.
Array 'DSJ.GetJobInfo' never dimensioned.
WARNING: Variable 'error' never assigned a value.
WARNING: Variable 'PathName' never assigned a value.
WARNING: Variable 'Pathname' never assigned a value.
5 Errors detected, No Object Code Produced.
(GenerateStatistics)
Code: Select all
***** GET DATE *****
GetDate:
vDate = oconv(@date,"D/YMD[4,2,2]")
***** GET DATE *****
ResetFile:
cmd="rm -f /DsSeqfiles/Adhoc/icmsstats.txt"
Call DSExecute("UNIX",cmd, Output, SystemReturnCode)
cmd="touch /DsSeqfiles/Adhoc/icmsstats.txt"
Call DSExecute("UNIX",cmd, Output, SystemReturnCode)
***** COUNT FOR LOOPS *****
CountLoops:
hJob1 = DSAttachJob ("PrepareStatistics", DSJ.ERRFATAL)
vLoops = DSGetLinkInfo (hJob1, "Transform", "tTransform" ,DSJ.LINKROWCOUNT)
ErrCode1 = DSDetachJob (hJob1)
***** ASSIGN ARGUMENTS *****
GetJobs:
ParamFileName="/DsSeqfiles/Adhoc/icmsjobs.txt"
OpenSeq ParamFileName To ParamFileHandle
Else
Call DSLogFatal ("Cannot open ":ParamFileName, "JobControl")
GoTo ErrorExit
End
Loop
ReadSeq ParamFileLine from ParamFileHandle
On error
Call DSLogFatal ("Cannot Process ":ParamFileName:status(), "JobControl")
GoTo ErrorExit
end
then
vJobname = Field (ParamFileLine,"|",1)
vCategory = Field (ParamFileLine,"|",2)
vLinkname = Field (ParamFileLine,"|",3)
vStagename = Field (ParamFileLine,"|",4)
vProject = Field (ParamFileLine,"|",5)
***** GET STATS *****
GetStats:
hJob1 = DSAttachJob (vJobname, DSJ.ERRFATAL)
vRowcount = DSGetLinkInfo (hJob1, vStagename, vLinkname,DSJ.LINKROWCOUNT)
vTime = DSJ.DSGetJobInfo (hJob1,DSJ.JOBELAPSED)
vRundate = DSJ.GetJobInfo (hJob1, DSJ.JOBSTARTTIMESTAMP)
***** GET DATE *****
WriteToFile:
ParamFileName2="/DsSeqfiles/Adhoc/icmsstats.txt"
OpenSeq ParamFileName2 To ParamFileHandle2
Else
Call DSLogFatal ("Cannot open ":ParamFileName2, "JobControl")
GoTo ErrorExit
End
Loop
ReadSeq Dummy From ParamFileHandle2 Else Exit ; * at end-of-file
Repeat
WriteSeqF vDate : "|" : vCategory : "|" : vJobname : "|" : vRowcount : "|" : vTime : "|" : vRundate To ParamFileHandle2 Else
On error
Call DSLogWarn("Error from ":PathName:" status=":Status(),"JobControl")
GoTo ErrorExit
End
Call DSLogFatal("Cannot write to ":Pathname, "JobControl")
GoTo ErrorExit
End
End Else
Call DSLogFatal("Cannot open file ":Pathname, "JobControl")
GoTo ErrorExit
End
*** Next
CloseSeq ParamFileHandle2
End Else
Exit ; * at end-of-file
End
Repeat
CloseSeq ParamFileHandle
***** ERROR EXIT *****
ErrorExit:*************************************************************************************
***** THIS JOB GENERATES SOME STATISTICS TO ENABLE REPORTING ON JOB RUNS
***** WRITTEN BY PHILLIP KHUMALO/ELDON PHUKUILE
*************************************************************************************
***** GET DATE *****
GetDate:
vDate = oconv(@date,"D/YMD[4,2,2]")
***** GET DATE *****
ResetFile:
cmd="rm -f /DsSeqfiles/Adhoc/icmsstats.txt"
Call DSExecute("UNIX",cmd, Output, SystemReturnCode)
cmd="touch /DsSeqfiles/Adhoc/icmsstats.txt"
Call DSExecute("UNIX",cmd, Output, SystemReturnCode)
***** COUNT FOR LOOPS *****
CountLoops:
hJob1 = DSAttachJob ("PrepareStatistics", DSJ.ERRFATAL)
vLoops = DSGetLinkInfo (hJob1, "Transform", "tTransform" ,DSJ.LINKROWCOUNT)
ErrCode1 = DSDetachJob (hJob1)
***** ASSIGN ARGUMENTS *****
GetJobs:
ParamFileName="/DsSeqfiles/Adhoc/icmsjobs.txt"
OpenSeq ParamFileName To ParamFileHandle
Else
Call DSLogFatal ("Cannot open ":ParamFileName, "JobControl")
GoTo ErrorExit
End
Loop
ReadSeq ParamFileLine from ParamFileHandle Else Exit ; * at end-of-file
On error
Call DSLogFatal ("Cannot Process ":ParamFileName:status(), "JobControl")
GoTo ErrorExit
end
then
vJobname = Field (ParamFileLine,"|",1)
vCategory = Field (ParamFileLine,"|",2)
vLinkname = Field (ParamFileLine,"|",3)
vStagename = Field (ParamFileLine,"|",4)
vProject = Field (ParamFileLine,"|",5)
***** GET STATS *****
GetStats:
hJob1 = DSAttachJob (vJobname, DSJ.ERRFATAL)
vRowcount = DSGetLinkInfo (hJob1, vStagename, vLinkname,DSJ.LINKROWCOUNT)
vTime = DSJ.DSGetJobInfo (hJob1,DSJ.JOBELAPSED)
vRundate = DSJ.GetJobInfo (hJob1, DSJ.JOBSTARTTIMESTAMP)
***** GET DATE *****
WriteToFile:
ParamFileName2="/DsSeqfiles/Adhoc/icmsstats.txt"
OpenSeq ParamFileName2 To ParamFileHandle2
Else
Call DSLogFatal ("Cannot open ":ParamFileName2, "JobControl")
GoTo ErrorExit
End
Loop
ReadSeq Dummy From ParamFileHandle2 Else Exit ; * at end-of-file
Repeat
WriteSeqF vDate : "|" : vCategory : "|" : vJobname : "|" : vRowcount : "|" : vTime : "|" : vRundate To ParamFileHandle2 Else
On error
Call DSLogWarn("Error from ":PathName:" status=":Status(),"JobControl")
GoTo ErrorExit
End
Call DSLogFatal("Cannot write to ":Pathname, "JobControl")
GoTo ErrorExit
End
End Else
Call DSLogFatal("Cannot open file ":Pathname, "JobControl")
GoTo ErrorExit
End
*** Next
CloseSeq ParamFileHandle2
End Else
Exit ; * at end-of-file
End
Repeat
CloseSeq ParamFileHandle
***** ERROR EXIT *****
ErrorExit: