Page 1 of 1

Job Control Aborting with "Job is not a runnable state&

Posted: Fri Aug 04, 2006 1:53 am
by fgallet
Hi !

I have a job control which failed with the message below :

[i]DTMCtrlFaitSCMMens..JobControl (fatal error from DSRunJob): Job control fatal error (-2)
(DSRunJob) Job DTMAlimNBOS is not in a runnable state[/i]

When i check the DTMAlimNBOS job, it's correctly compiled and the job have [b][u]Run[/u][/b] !!! :shock:

here a piece of the job control code :

* Setup DTMAlimNBOS, run it, wait for it to finish, and test for success
hJob3 = DSAttachJob("DTMAlimNBOS", DSJ.ERRFATAL)
If NOT(hJob3) Then
Call DSLogFatal("Job Attach Failed: DTMAlimNBOS", "JobControl")
Abort
End
LimitErr= DSSetJobLimit(hJob3,DSJ.LIMITWARN,MaxWarning)
ErrCode = DSSetParam(hJob3, "dsn_cible", dsn_DTM)
ErrCode = DSSetParam(hJob3, "usr_cible", usr_DTM)
ErrCode = DSSetParam(hJob3, "pwd_cible", pwd_DTM)
ErrCode = DSSetParam(hJob3, "dsn_source", dsn_DWH)
ErrCode = DSSetParam(hJob3, "usr_source", usr_DWH)
ErrCode = DSSetParam(hJob3, "pwd_source", pwd_DWH)
ErrCode = DSRunJob(hJob3, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob3)
Status = DSGetJobInfo(hJob3, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: DTMAlimNBOS", "JobControl")
End
If Status = DSJS.RUNWARN Then
Call DSLogWarn("Job Warning : DTMAlimNBOS" ,"JobControl")
End

Any Idea ?

thanks a lot

Fred

Posted: Fri Aug 04, 2006 2:14 am
by kumar_s
Your code seem to be ok. Try to recompile the both the job and the routine and try again. If this the same case for most of other job, tyr REINDEX with complet access to the project.

Posted: Fri Aug 04, 2006 3:16 am
by loveojha2
instead

Code: Select all

ErrCode = DSRunJob(hJob3, DSJ.RUNNORMAL)
Try with

Code: Select all

ErrCode = DSRunJob(hJob3, DSJ.RUNRESET)

Posted: Fri Aug 04, 2006 6:38 am
by chulett
Doing that would only reset the job, not reset it and then run it. If you want to emulate the 'Reset if required then run' functionality of a Sequence job, you need to do both.

And if you want to do it 'right', check the status of the job and only issue the RUNRESET if you need to. :wink:

Posted: Fri Aug 04, 2006 6:44 am
by chulett
As noted, your code seems to be 'fine', being pretty much exactly what DataStage generates when you use the 'Add Job' button.

That being said, this kind of problem is just usually a timing problem. Some other process (or person) ran the job and when this one tried to you got the dreaded 'job is not in a runnable state' message - because it was already running! :wink: