I did some searching on how to clear job logs en masse and found a number of useful posts. I found some code by Ken Bland (thanks Ken ) but I can't seem to get it to work. I am using a Datastage Parallel Job. The code has been cut and paste into the Job Control tab under Job properties and the two Job Parameters used (Folder and SearchString) are set as below.
I used the Job Control tab as the original instruction was to cut and paste the code into the job and this is the only way I can see of doing that without creating a routine:
Parameters:
The SearchString above is a valid jobname.Folder is blank
SearchString is JP_01_RTCOL_CEN_LAND_010_ACC_FACTORS
Job Control Code:
Log Output from Job Run:TCL = 'SSELECT DS_JOBS'
If SearchText Then TCL:= ' LIKE "':SearchText:'"'
If Folder Then TCL:= ' WITH F3 = "':Folder:'"'
Call DSExecute("TCL", TCL, ScreenOutput, SystemReturnCode)
Call DSLogInfo("TCL Output: ":ScreenOutput, "Msg")
OPEN "DS_JOBS" TO JobsXrefTable Else
Call DSLogFatal("Unable to open DS_JOBS", "Msg")
End
JobList = ""
AllJobsDone = @FALSE
Loop
Readnext JobName Else AllJobsDone = @TRUE
Until AllJobsDone Do
If LEFT(JobName,2) # "" Then
Read Row From JobsXrefTable, JobName Then
JobList = JobName:"|":Row
End
End
Repeat
Call DSLogInfo("Processing the following jobs: ":JobList, "Msg")
JobCount = Dcount(JobList,@AM)
For Job = 1 TO JobCount
JobName = FIELD(JobList, "|",1)
TableName = "RT_LOG":FIELD(JobList, "|",2)
TCL = "CLEAR.FILE ":TableName
Call DSExecute("TCL", TCL, ScreenOutput, SystemReturnCode)
Call DSLogInfo("TCL Output: ":ScreenOutput, "Msg")
Next Job
The code is picking up the jobname as it is selecting one record. I don't really know what the '|NRO' immediately after the message "Processing the following jobs: JP_01_RTCOL_CEN_LAND_010_ACC_FACTORS|NRO" means and whether this indicates anything.Starting Job JP_99_Clear_Job_Logs.
SearchText = JP_01_RTCOL_CEN_LAND_010
Folder =
JP_99_Clear_Job_Logs..JobControl (Msg): TCL Output:
1 record(s) selected to SELECT list #0.
JP_99_Clear_Job_Logs..JobControl (Msg): Processing the following jobs: JP_01_RTCOL_CEN_LAND_010_ACC_FACTORS|NRO
\RTCOL\Jobs\01-Landing
Land contributory factors data in native format for Central RTC
486
3
Attempting to Cleanup after ABORT raised in job JP_99_Clear_Job_Logs..JobControl
However, It isn't clear to me why the job is aborting. The joblog in DS Director for this job has a number of entries.
I can't claim to understand what the code is doing 100% but I know that the 486 in the job log snippet above equates to the correct RT_LOG entry. I believe the 3 immediately after is the system return code but cannot be sure.
Any help on deciphering the above would be appreciated.
Thanks,
Daren