resetting and rerunning a job from a basic datatstage job

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

resetting and rerunning a job from a basic datatstage job

Post by admin »

Hi,
I wonder if someone could help me on the following.
What I want to do is start a Datastage job from a basic Datastage controlling job. When the started job aborts, I want to reset it and run it again , this maximum 5 times. Ill try to do this because sometimes jobs abends and when one starts them again they run ok. So instead of doing this manually I want to solve it in the basic controlling job

For testing I have put an error in this GRCRESTART1 The first time GRCRESTART1 aborts
RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) gives
a 3
after resetting the job and restarting it
RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) gives
a 1 indicating that the job finished normally although it also aborted.
maybe Im overlooking the obvious but I couldnt manage to solve it

thanks in advance
Luc


jobname = "GRCRESTART1"
gosub runjob:
return


runjob:
*
Trialruns = 0
Loop
While Trialruns < 5
hJob1 = DSAttachJob(jobname, DSJ.ERRWARN)
If NOT(hJob1) Then
Call DSLogFatal("Job Failed: " :jobname , "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "ERRDIR", ERRDIR)

ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) gives a 3 the first time and a 1 the second time

Call DSLogWarn("after run" : RunStatus ,JobName)

If RunStatus = 3 Then
ErrCode = DSDetachJob(hJob1)
hJob2 = DSAttachJob(jobname, DSJ.ERRWARN)
ErrCode = DSRunJob(hJob2, DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob2)
ResetStatus = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
ErrCode = DSDetachJob(hJob2)
Trialruns = Trialruns + 1
End
Repeat

Luc Huygelen
Data Engineering
EDS (Electronic Data Systems)
Noorderlaan 147
2030 Antwerpen (Belgium)
* +32 (0)3 544 6026 or 8932 6026
> * luc.huygelen@eds.com
>
>
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Perhaps try using the sleep command either before or after the reset to wait for a few seconds.

E.g.

sleep 10

----- Original Message -----
From: "Huygelen, Luc"
To:
Sent: Friday, December 14, 2001 5:28 PM
Subject: resetting and rerunning a job from a basic datatstage job


> Hi,
> I wonder if someone could help me on the following.
> What I want to do is start a Datastage job from a basic Datastage
> controlling job. When the started job aborts, I want to reset it and
> run
it
> again , this maximum 5 times. Ill try to do this because sometimes
> jobs abends and when one starts them again they run ok. So instead of
> doing
this
> manually I want to solve it in the basic controlling job
>
> For testing I have put an error in this GRCRESTART1 The first time
> GRCRESTART1 aborts RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
gives
> a 3
> after resetting the job and restarting it
> RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
gives
> a 1 indicating that the job finished normally although it also aborted.
> maybe Im overlooking the obvious but I couldnt manage to solve it
>
> thanks in advance
> Luc
>
>
> jobname = "GRCRESTART1"
> gosub runjob:
> return
>
>
> runjob:
> *
> Trialruns = 0
> Loop
> While Trialruns < 5
> hJob1 = DSAttachJob(jobname, DSJ.ERRWARN)
> If NOT(hJob1) Then
> Call DSLogFatal("Job Failed: " :jobname , "JobControl")
> Abort
> End
> ErrCode = DSSetParam(hJob1, "ERRDIR", ERRDIR)
>
> ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
> ErrCode = DSWaitForJob(hJob1)
> RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) gives a
> 3 the first time and a 1 the second time
>
> Call DSLogWarn("after run" : RunStatus ,JobName)
>
> If RunStatus = 3 Then
> ErrCode = DSDetachJob(hJob1)
> hJob2 = DSAttachJob(jobname, DSJ.ERRWARN)
> ErrCode = DSRunJob(hJob2, DSJ.RUNRESET)
> ErrCode = DSWaitForJob(hJob2)
> ResetStatus = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
> ErrCode = DSDetachJob(hJob2)
> Trialruns = Trialruns + 1
> End
> Repeat
>
> Luc Huygelen
> Data Engineering
> EDS (Electronic Data Systems)
> Noorderlaan 147
> 2030 Antwerpen (Belgium)
> * +32 (0)3 544 6026 or 8932 6026
> > * luc.huygelen@eds.com
> >
> >
> >
>
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Thanks for the reply , the sleep command after the reset solved the problem

best regards
luc

-----Original Message-----
From: DataStage Developer [mailto:datastagedeveloper@hotmail.com]
Sent: Saturday, December 15, 2001 2:49 PM
To: datastage-users@oliver.com
Subject: Re: resetting and rerunning a job from a basic datatstage job


Perhaps try using the sleep command either before or after the reset to wait for a few seconds.

E.g.

sleep 10

----- Original Message -----
From: "Huygelen, Luc"
To:
Sent: Friday, December 14, 2001 5:28 PM
Subject: resetting and rerunning a job from a basic datatstage job


> Hi,
> I wonder if someone could help me on the following.
> What I want to do is start a Datastage job from a basic Datastage
> controlling job. When the started job aborts, I want to reset it and
> run
it
> again , this maximum 5 times. Ill try to do this because sometimes
> jobs abends and when one starts them again they run ok. So instead of
> doing
this
> manually I want to solve it in the basic controlling job
>
> For testing I have put an error in this GRCRESTART1 The first time
> GRCRESTART1 aborts RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
gives
> a 3
> after resetting the job and restarting it
> RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
gives
> a 1 indicating that the job finished normally although it also aborted.
> maybe Im overlooking the obvious but I couldnt manage to solve it
>
> thanks in advance
> Luc
>
>
> jobname = "GRCRESTART1"
> gosub runjob:
> return
>
>
> runjob:
> *
> Trialruns = 0
> Loop
> While Trialruns < 5
> hJob1 = DSAttachJob(jobname, DSJ.ERRWARN)
> If NOT(hJob1) Then
> Call DSLogFatal("Job Failed: " :jobname , "JobControl")
> Abort
> End
> ErrCode = DSSetParam(hJob1, "ERRDIR", ERRDIR)
>
> ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
> ErrCode = DSWaitForJob(hJob1)
> RunStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS) gives a
> 3 the first time and a 1 the second time
>
> Call DSLogWarn("after run" : RunStatus ,JobName)
>
> If RunStatus = 3 Then
> ErrCode = DSDetachJob(hJob1)
> hJob2 = DSAttachJob(jobname, DSJ.ERRWARN)
> ErrCode = DSRunJob(hJob2, DSJ.RUNRESET)
> ErrCode = DSWaitForJob(hJob2)
> ResetStatus = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
> ErrCode = DSDetachJob(hJob2)
> Trialruns = Trialruns + 1
> End
> Repeat
>
> Luc Huygelen
> Data Engineering
> EDS (Electronic Data Systems)
> Noorderlaan 147
> 2030 Antwerpen (Belgium)
> * +32 (0)3 544 6026 or 8932 6026
> > * luc.huygelen@eds.com
> >
> >
> >
>
Locked