Jobcontrol Reset Failure

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Jobcontrol Reset Failure

Post by myukassign »

I am having a controler job with the following code. If it abort it should reset the job but not working.

hJob1 = DSAttachJob("TestJob", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: TestJob", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "inFile", inFile)
ErrCode = DSSetParam(hJob1, "outFile", outFile)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
Call DSLogInfo(Status,"Custom program calling":Status)
Call DSRunJob(hJob1, DSJ.RUNRESET)
End

In the above code, when it is aborting, it is successfully calling that Call DSLogInfo(Status,"Custom program calling":Status) but the it is not able to call the next statement to rest job.

any input will be a help?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The aborted job is "attach locked". You need to detach then re-attach it before you can reset it.

Would it not be easier to call DSPrepareJob() before attempting to run the job? This is the function behind the "reset if required, then run" functionality in job sequences.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

In the above code I modified the IF condition like the following . But still it is not resetting. Any help?

If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
Call DSLogInfo(Status,"Custom program calling":Status)
Call DSDetachJob(hJob1)
hJob1= DSAttachJob("TestJob", DSJ.ERRFATAL)
Call DSRunJob(hJob1, DSJ.RUNRESET)
END
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

Sorry. I got answer for this problem.

The code should be like this

hJob1 = DSAttachJob("TestJob", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: TestJob", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "inFile", inFile)
ErrCode = DSSetParam(hJob1, "outFile", outFile)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)

Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)

If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
DSRunJob(hJob1, DSJ.RUNRESET)
END

ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
Call DSLogInfo(Status,"Custom program calling":Status)
End
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: If your problem is solved, then please mark the post as Resolved using the big button at the top of the screen.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply