Ds Job
Ds Job
H *---- Getting Directory path--------------* strStatsFileLoc = DSGetParamInfo(DSJ.ME, "$HMK_DIRLOGS", DSJ.PARAMVALUE) Call DSLogInfo("Statistics File Will be located at (strStatsFileLoc) :":strStats FileLoc, DSJ.ME) *---- getting Job Name-------------* strJobName = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME) Call DSLogInfo("Job Name (strJobName) :":strJobName, DSJ.ME) strWorking = DSGetParamInfo(DSJ.ME,"$HMK_DIRWORKING", DSJ.PARAMVALUE) Call DSLogInfo("Working Directory (strWorking) :":strWorking, DSJ.ME) *-----Getting Current Date ------* Call DSExecute("UNIX",'echo `date "+%Y%m%d%H%M%S"`', Output, SystemReturnCode) Call DSLogInfo(Output,DSJ.ME) Jobrun_datetime = Output[1,14] Jobrun_date = Output[1,4]:'-':Output[5,2]:'-':Output[7,2] *------Parse Input args ------* * "#POPAPPL.ANALYSIS_VERSION" vTableName=Field(InputArg,'#',2) FOUND= ' ' *------Searching for all jobs with vTableName ------* cmd = "SELECT DS_JOBS.NAME AS JOB_NAME,EVAL DS_JOBOBJECTS."if index(@RECORD,'POP APPL.ANALYSIS_VERSION',1) > 0 then 'FOUND' else 'NTFND'" FROM DS_JOBS, DS_JOBOBJ ECTS WHERE DS_JOBS.JOBNO = DS_JOBOBJECTS.OBJIDNO;" execute cmd capturing output returning RtnValue Lines = DCount(output,@FM) Jobs="" for i=3 to Lines Space = Count(output,' ') if Trim(Field(output,' ',1))<>"" Then Jobs := ',' : Field(output,' ',1): ' ' : F ield(output,' ',Space+1) next i *Ans = Right(Jobs,LEN(Jobs)-1) *------- Writing to the File----------* WriteFile: strFileName = "SEARCH.":strJobName:Jobrun_datetime:".log" strFile = strStatsFileLoc:'/':strFileName OpenSeq strFile To objFileVar Else Create objFileVar Else ErrorCode =1 WeofSeq objFileVar WriteSeq "Start Search TableName for Jobs Report" To objFileVar Then End WriteSeq "vTableName: " :vTableName To objFileVar Then End WriteSeq "Jobs: " :output To objFileVar Then End WriteSeq FMT("Jobs: ","8L"):FMT(Jobs,"20L") To objFileVar Then End WriteSeq FMT("Lines: ","6L"):FMT(Lines,"6L") To objFileVar Then End WriteSeq "End Search TableName for Jobs Report" To objFileVar Then
End CloseSeq objFileVar Call DSLogInfo("Search file ":strFile:" created.",DSJ.ME) ErrorCode = 0 ; =========================================================================// Ans = @FALSE RoutineName = "RtrGetSeqStages" Usage = RoutineName:'(JobName)' * ----------------------------------------------------------------DebugSw = @FALSE cmd = "SELECT DS_JOBOBJECTS.NAME, max(DS_JOBOBJECTS.OLETYPE) from DS_JOBS, DS_JO BOBJECTS where DS_JOBS.NAME='":JobName:"' and DS_JOBS.JOBNO=DS_JOBOBJECTS.OBJIDN O group by DS_JOBOBJECTS.NAME" Call DSExecute("UV", cmd, Res , ReturnCode) If ReturnCode<>0 Then Ans = "ERROR ": ReturnCode Goto TheEnd End Ans = Res<1> * ---------------------------------------------------------------------TheEnd: if DebugSw then print if DebugSw then print if DebugSw then print Ans if DebugSw then print =====================================================// This is my new code and it works fine. A bit slow, but it's ok, it's not part of the regular process: Ans = @FALSE RoutineName = "RtrGetSeqStages" Usage = RoutineName:'(JobName)' * ----------------------------------------------------------------DebugSw = @FALSE cmd = "SELECT DS_JOBOBJECTS.NAME, max(DS_JOBOBJECTS.OLETYPE) from DS_JOBS, DS_JO BOBJECTS where DS_JOBS.NAME='":JobName:"' and DS_JOBS.JOBNO=DS_JOBOBJECTS.OBJIDN O group by DS_JOBOBJECTS.NAME;" execute cmd capturing output returning RtnValue Lines = DCount(output,@FM) Stages="" for i=3 to Lines Space = Count(output,' ') if Trim(Field(output,' ',1))<>"" Then Stages := ',' : Field(output,' ',1): ' ' : Field(output,' ',Space+1) next i
Ans = Right(Stages,LEN(Stages)-1) ExitRtn: goto TheEnd * ---------------------------------------------------------------------TheEnd: if DebugSw then print if DebugSw then print if DebugSw then print Ans if DebugSw then print ==========================================================// CMD = "SELECT MAX(CAST(JOBNO AS INTEGER)) FROM DS_JOBS;" Call DSExecute("UV", CMD, Output, ReturnCode) If ReturnCode=0 Then Ans = @NULL End ELSE Ans = Trim(Oconv(Output,"MCN"),"1","T") End RETURN(Ans) ============================This Work???================================ GetAllJobsNo(Arg1)-----????job?jobno?jobname,??array GetAllJobsLog(JobArray)----??JobArray??jobno?????RT_LOGxx(??jobno=20,RT_LOG20)?? ??log,????? ????: *##################################################################### * * FUNCTION GetAllJobsNo * ----Get all the jobs' JOBNO and NAME of the project * RETURN(Ans)<--JobList ---- the Array stores * <1> ---- JOBNO * <2> ---- NAME * Written by: LynnLiu 2004-11-03 * *##################################################################### INCLUDE DSINCLUDE JOBCONTROL.H Init: Ans = "" RoutineName = "GetAllJobsNo" aBlank = '' cJobNo = 1 cJobName = 2 JobList = aBlank Number = 0 OutOrder = 1 Main: InputArg = "SELECT JOBNO,NAME FROM DS_JOBS;" Call DSExecute("TCL", InputArg, Output, SystemReturnCode) If SystemReturnCode >= 0 Then Out = Trim(Output) Number = DCOUNT(Out,@FM)
For i =1 to Number PerLine = trim(Field(Out,@FM,i)) if Seq(PerLine[1,1]) > 47 and Seq(PerLine[1,1]) < 58 then JobList<1,OutOrder> = Field(PerLine," ",1) JobList<2,OutOrder> = Field(PerLine," ",2) OutOrder = OutOrder + 1 End Next End Else call DSLogWarn("Error when executing command: ":InputArg:' *** ':Output :'*** ':SystemReturnCode, RoutineName) End Ans = JobList ############################################################# * FUNCTION GetAllJobsLog(FilePath) *-----Get all jobs' logs, *-----especially "Warning" and "Fatal" log, in the Project * FilePath * -----Logfile * * Written by: LynnLiu 2004-11-05 *############################################################ deffun GetAllJobsNo(A) calling "DSU.GetAllJobsNo" Ans = "" RoutineName = "GetAllJobsLog" JobArray = GetAllJobsNo(Arg1) P = (DCOUNT(JobArray,@VM) + 1) / 2 OpenSeq FilePath to FileVar Then w=@True WeofSeq FileVar For i = 1 to P InputArg = 'SELECT SEVERITY,TIMESTAMP,"FULL.TEXT", "WAVE.NO" FROM "RT_LOG' InputArg = InputArg : JobArray<1,i>: '" ' InputArg = InputArg : "WHERE SEVERITY IN ('Warning', 'Fatal', 'Reject')" : " ORDER BY @ID;" Call DSExecute("TCL", InputArg, Output, SystemReturnCode) If Trim(Output) <> "" THEN call DSLogInfo("*** Output from UniVerse command was: ":Output, Routine Name) End Else call DSLogInfo("*** No output from UniVerse command ***", RoutineName) End If SystemReturnCode < 0 Then call DSLogWarn("Error when executing command: ":InputArg:' *** ':Outpu t:'*** ':SystemReturnCode, RoutineName) End Data = trim(Output) If Index(Data,"Severity",1) <> 0 then B = DCOUNT(Data,@FM) JobName = "**************":JobArray<2,i>:"***************" WriteSeq JobName To FileVar Then w=@True For j = 0 to B WriteSeq trim(Field(Data,@FM,j)) To FileVar Then w=@True Next End