Routine to reset a job

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
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Routine to reset a job

Post 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
davidnemirovsky
Participant
Posts: 85
Joined: Fri Jun 04, 2004 2:30 am
Location: Melbourne, Australia
Contact:

Post 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 :lol: ):

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).
Cheers,
Dave Nemirovsky
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post 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 :lol: ):

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).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post 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.
mandyli
Premium Member
Premium Member
Posts: 898
Joined: Wed May 26, 2004 10:45 pm
Location: Chicago

Post 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
rajeev_prabhuat
Participant
Posts: 136
Joined: Wed Sep 29, 2004 5:56 am
Location: Chennai
Contact:

Post 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
Post Reply