Error handling in server routines
Moderators: chulett, rschirm, roy
Error handling in server routines
Dear All,
I am using the below code for job statistics in server routine
If the job name which we are not passing is invalid or not avaialable then how to handle the error which occur with the routine.
Can any one suggest me how to handle this case with failing the routine.
I am using the below code for job statistics in server routine
If the job name which we are not passing is invalid or not avaialable then how to handle the error which occur with the routine.
Can any one suggest me how to handle this case with failing the routine.
RD
sorry missed out to give the code which i am using
below is the code
below is the code
Code: Select all
SINCLUDE JOBCONTROL.H
Equate RoutineName To 'GetJobInfo'
JobHandle = ''
Int = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
Begin Case
Case Int = DSJS.RUNFAILED
Info = 'Aborted'
Case Int = DSJS.RUNOK
Info = 'Completed'
Case Int = DSJS.RUNWARN
Info = 'Warning'
Case Int = DSJS.RUNNING
Count = DSGetJobInfo(JobHandle, DSJ.DSJ.JOBEOTCOUNT)
Info = 'Running' : 'Count of Rows Complete' : Count
Case @True ; * all other values
Info = 'Not Defined'
End Case
StartTime = DSGetJobInfo(JobHandle, DSJ.JOBSTARTTIMESTAMP)
EndTime = DSGetJobInfo(JobHandle, DSJ.JO
RD
sorry,below is the code:
The input variable which i am using is JobName
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
Equate RoutineName To 'GetJobInfo'
JobHandle = ''
JobHandle = DSAttachJob(JobName, DSJ.ERRNONE)
Int = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
Begin Case
Case Int = DSJS.RUNFAILED
Job_Status = 'Aborted'
Case Int = DSJS.RUNOK
Job_Status = 'Finished'
Case Int = DSJS.RUNWARN
Job_Status = 'Finished with Warnings'
Case @True; * all other values
Info = 'UnKnown'
End Case
StartTime = DSGetJobInfo(JobHandle, DSJ.JOBSTARTTIMESTAMP)
EndTime = DSGetJobInfo(JobHandle, DSJ.JOBLASTTIMESTAMP)
Ans = Job_Status : '|' : StartTime : '|' : EndTime
The input variable which i am using is JobName
RD
It is important not to try to DSAttachJob() your own job, that can cause a hang situation, so you should add:
Note you forget DSJS.RUNNING in your list.
Generally if the DSAttachJob() call fails, the return value will be 0. While this is not explicitly documented, it does work that way and that is what I use to determine if a DSAttachJob() call was succesfull or not.
Code: Select all
IF (JobName <> DSGetJobInfo(DSJ.ME,DSJ.JOBNAME) )
THEN
... your code
END
ELSE
Job_Status = 'Running'
END
Generally if the DSAttachJob() call fails, the return value will be 0. While this is not explicitly documented, it does work that way and that is what I use to determine if a DSAttachJob() call was succesfull or not.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Make this the first option within your CASE construct.
Code: Select all
Case Int = DSJE.BADHANDLE
Job_Status = 'Error'
Call DSLogWarn("Unable to attach job " : DQuote(JobName) : ".", RoutineName)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.