Page 1 of 1

DS Job hagging when called an After Job routine

Posted: Sat Feb 26, 2011 2:58 am
by anusha
Hi All,

I have written an After-Job routine to retrive the Job statistics. My job is hanging when it is encoutering the command DSAttachJob and the State of the job is always running. I am not sure why it is behaving this way.
Here is my roUtine:

Code: Select all

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF    
*** Get the Statistics for the Current Job 
      JOBNAME= DSJobName
      Call DSLogInfo ( "JobName ":JOBNAME,"dsrAuditCntrlInfo")
      Hjob = DSAttachJob(JOBNAME,DSJ.ERRFATAL)
      if NOT(Hjob) then
      call DSLogFatal( "Job Failed ":JOBNAME,"dsrAuditCntrlInfo")
      ABORT
      end
      Return= SOURCE_NAME matches "0X'TB_ODS_ZINC'0X"
      Call DSLogInfo ( "Value of Return Code ":Return,"dsrAuditCntrlInfo")
      if Return = 1 then
          SUBJECT='ABC'
      end
      else
          SUBJECT='XYZ'
      end
      Call DSLogInfo ( "Value of SUBJECT ":SUBJECT,"dsrAuditCntrlInfo")
      EXECSTATUS = DSGetJobInfo (Hjob, DSJ.JOBSTATUS)
      Call DSLogInfo ( "Value of EXECSTATUS ":EXECSTATUS,"dsrAuditCntrlInfo")
      JOBSTARTTIME = DSGetJobInfo (Hjob, DSJ.JOBSTARTTIMESTAMP)
      Call DSLogInfo ( "Value of JOBSTARTTIME ":JOBSTARTTIME,"dsrAuditCntrlInfo")

      JOBENDTIME = DSGetJobInfo (Hjob, DSJ.JOBLASTTIMESTAMP)
      Call DSLogInfo ( "Value of JOBENDTIME ":JOBENDTIME,"dsrAuditCntrlInfo")

      JOBELAPSTIME = DSGetJobInfo (Hjob, DSJ.JOBELAPSTIMESTAMP)
      Call DSLogInfo ( "Value of JOBELAPSTIME ":JOBELAPSTIME,"dsrAuditCntrlInfo")

      DetachResult = DSDetachJob(Hjob)
Can any one please help me to resolve the issue. I have used the Job control macros in After Job Subroutine

Posted: Sat Feb 26, 2011 3:41 am
by anusha
Now i am getting the following error after running for few minutes.

Code: Select all

AfterJob (fatal error from DSAttachJob): Job control fatal error (0)
(DSCloseJob) Cannot refer to own job handle
(DSAttachJob) Failed to lock job after 1800 seconds
Since i am calling the DSAttachJob in After Job routine by checking in the job property Omly run After-jon routine on successful completion of the job it should not be a problem.

Any help is highly appriciated!

Thanks.

Posted: Sat Feb 26, 2011 5:26 am
by ray.wurlod
A job can not attach to itself. Do not call DSAttachJob() at all. Use DSJ.ME for the job handle in the other functions.