Page 1 of 1
Routine to reset a job
Posted: Wed Dec 08, 2004 11:31 pm
by rajeev_prabhuat
Hi,
I am new to Routines in DS, i am trying to write a routine which will reset a job and will make it available to run. The routine that i have made is as follows:
h$V0S0 = DSAttachjob(Arg1,DSJ.ERRNONE)
If (h$V0S0) Then
hErrcode = DSRunJob(h$V0S0 , DSJ.RUNRESET )
End
I am getting error as follows:
Compiling: Source = 'DSU_BP/DSU.ResetJob', Object = 'DSU_BP.O/DSU.ResetJob'
Array 'DSAttachjob' never dimensioned.
WARNING: Variable 'DSJ.ERRNONE' never assigned a value.
Array 'DSRunJob' never dimensioned.
WARNING: Variable 'DSJ.RUNRESET' never assigned a value.
WARNING: Variable 'Ans' never assigned a value.
2 Errors detected, No Object Code Produced.
How can i solve this.
Regards,
Rajeev Prabhu
Posted: Thu Dec 09, 2004 12:05 am
by davidnemirovsky
You might want to have a look at the following code. Originally this design came to me on a Datastage BASIC course that Ray Wurlod took (Thanks Ray
![Laughing :lol:](./images/smilies/icon_lol.gif)
):
Code: Select all
**************************************
* Run Job: PocketSportsMasterControl *
**************************************
* Run Job if in runnable state, if not then Reset and Run
hJob = DSAttachJob("PocketSportsMasterControl", DSJ.ERRWARN)
ActualJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
$IfDef DebugMode
Message = "Actual Job Name ":ActualJobName:"."
Call DSLogInfo(Message, RoutineName)
$EndIf
If ActualJobName <> DSJE.BADHANDLE
Then
$IfDef DebugMode
Message = "Runnable returned :":Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS))
Call DSLogInfo(Message, RoutineName)
$EndIf
If Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS)) = 'Y'
Then
ErrCode = DSSetParam(hJob, "SrcSvr", SrcSvr)
ErrCode = DSSetParam(hJob, "SrcUser", PSSrcUser)
ErrCode = DSSetParam(hJob, "SrcUserPwd", PSSrcUserPwd)
ErrCode = DSSetParam(hJob, "PublishDate", PublishDate)
ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Call DSLogWarn("Job Failed: ":ActualJobName:".", RoutineName)
End
End
If Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS)) = 'R'
Then
Message = "Job is resetting..."
Call DSLogInfo(Message, RoutineName)
ErrCode = DSRunJob(hJob, DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Message = "Job Reset Failed: ":ActualJobName:"."
Call DSLogWarn(Message, RoutineName)
End
Else
ErrCode = DSDetachJob(hJob)
hJob = DSAttachJob("PocketSportsMasterControl", DSJ.ERRWARN)
Message = "Job has been reset, Running Job..."
Call DSLogInfo(Message, RoutineName)
ErrCode = DSSetParam(hJob, "SrcSvr", SrcSvr)
ErrCode = DSSetParam(hJob, "SrcUser", PSSrcUser)
ErrCode = DSSetParam(hJob, "SrcUserPwd", PSSrcUserPwd)
ErrCode = DSSetParam(hJob, "PublishDate", PublishDate)
ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Call DSLogWarn("Job Failed (After auto-reset): ":ActualJobName:".", RoutineName)
End
End
End
End ; * ActualJobName Loop
Else
Message = 'Job ':ActualJobName:' not found in this project.'
Call DSLogWarn(Message, RoutineName)
End
* Detach current job handle to re-use
ErrCode = DSDetachJob(hJob)
You will of course have to modify it based on your job (Ie parameters, job name etc).
Posted: Thu Dec 09, 2004 12:13 am
by rajeev_prabhuat
Hi,
Thank you. We will modify and execute it.
Regards,
Rajeev Prabhu
djhigh wrote:You might want to have a look at the following code. Originally this design came to me on a Datastage BASIC course that Ray Wurlod took (Thanks Ray
![Laughing :lol:](./images/smilies/icon_lol.gif)
):
Code: Select all
**************************************
* Run Job: PocketSportsMasterControl *
**************************************
* Run Job if in runnable state, if not then Reset and Run
hJob = DSAttachJob("PocketSportsMasterControl", DSJ.ERRWARN)
ActualJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
$IfDef DebugMode
Message = "Actual Job Name ":ActualJobName:"."
Call DSLogInfo(Message, RoutineName)
$EndIf
If ActualJobName <> DSJE.BADHANDLE
Then
$IfDef DebugMode
Message = "Runnable returned :":Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS))
Call DSLogInfo(Message, RoutineName)
$EndIf
If Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS)) = 'Y'
Then
ErrCode = DSSetParam(hJob, "SrcSvr", SrcSvr)
ErrCode = DSSetParam(hJob, "SrcUser", PSSrcUser)
ErrCode = DSSetParam(hJob, "SrcUserPwd", PSSrcUserPwd)
ErrCode = DSSetParam(hJob, "PublishDate", PublishDate)
ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Call DSLogWarn("Job Failed: ":ActualJobName:".", RoutineName)
End
End
If Runnable(DSGetJobInfo(hJob, DSJ.JOBSTATUS)) = 'R'
Then
Message = "Job is resetting..."
Call DSLogInfo(Message, RoutineName)
ErrCode = DSRunJob(hJob, DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Message = "Job Reset Failed: ":ActualJobName:"."
Call DSLogWarn(Message, RoutineName)
End
Else
ErrCode = DSDetachJob(hJob)
hJob = DSAttachJob("PocketSportsMasterControl", DSJ.ERRWARN)
Message = "Job has been reset, Running Job..."
Call DSLogInfo(Message, RoutineName)
ErrCode = DSSetParam(hJob, "SrcSvr", SrcSvr)
ErrCode = DSSetParam(hJob, "SrcUser", PSSrcUser)
ErrCode = DSSetParam(hJob, "SrcUserPwd", PSSrcUserPwd)
ErrCode = DSSetParam(hJob, "PublishDate", PublishDate)
ErrCode = DSRunJob(hJob, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob)
Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
Call DSLogWarn("Job Failed (After auto-reset): ":ActualJobName:".", RoutineName)
End
End
End
End ; * ActualJobName Loop
Else
Message = 'Job ':ActualJobName:' not found in this project.'
Call DSLogWarn(Message, RoutineName)
End
* Detach current job handle to re-use
ErrCode = DSDetachJob(hJob)
You will of course have to modify it based on your job (Ie parameters, job name etc).
Posted: Thu Dec 09, 2004 12:38 am
by ray.wurlod
Your original problem was casing. Function names are case sensitive.
The function name you wanted was DSAttachJob. The function name you specified was DSAttachjob. Not the same function.
Posted: Thu Dec 09, 2004 2:11 am
by rajeev_prabhuat
Hi Ray,
Thank you. I added the header file and then changed the j to J it got compliled sucessfully. My first Routine is sucessfull.
Thank you once again.
Regards,
Rajeev Prabhu
ray.wurlod wrote:Your original problem was casing. Function names are case sensitive.
The function name you wanted was DSAttachJob. The function name you specified was DSAttachjob. Not the same function.
Posted: Thu Dec 09, 2004 4:17 am
by mandyli
Hi Rajeev,
use the following code in your routine. it will reset the job & run.
AuditHandle = DSAttachJob(" your Job name " ,DSJ.ERRNONE)
RunErr = DSRunJob(AuditHandle, DSJ.DSJ.RUNRESET )
try this.
Thanks
Man
Posted: Thu Dec 09, 2004 4:20 am
by rajeev_prabhuat
Hi Mandyli,
I got it done. Thank you.
Regards,
Rajeev Prabhu
mandyli wrote:Hi Rajeev,
use the following code in your routine. it will reset the job & run.
AuditHandle = DSAttachJob(" your Job name " ,DSJ.ERRNONE)
RunErr = DSRunJob(AuditHandle, DSJ.DSJ.RUNRESET )
try this.
Thanks
Man