Restartability of User Variables

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Restartability of User Variables

Post by fmou »

asorrell wrote:... You have a job sequence running 10 jobs. You need to set a parameter to a value and then pass that value to all 10 jobs. . . in the job sequence setup a "user variable" using the User Variable Activity stage first (before the jobs). . .
If your UVA stage is called SetVar and your actual variable is called Yesterday (for example), then you can use it to set the appropriate parameters in your jobs. It would show up under "Activity Variables" as SetVar.Yesterday
Hi,

Following on this, I want to know the restartability of User Variables.

Say I set a User Variable at the beginning of job sequence that runs 10 jobs. If the job sequence failed in the middle, and I need to restart the job sequence from where it failed, would the User Variables set in the previous run still available in the restarted run?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Split from this topic.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Inspecting the Job Control code generated by compiling the sequence will answer this question for you. Please post the results of your deliberations.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post by fmou »

Inspecting the Job Control code generated by compiling the sequence will answer this question for you
thanks, will do, and post back.
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post by fmou »

hmm.... not that obvious to me. I was having a hard time trying to decipher the following extremely simple case. Any help?

Thanks

Code: Select all

* Tokens were replaced below as follows:
* IdV1S1%%UserVar%%0 <= uv2.var3
* IdV1S1%%UserVar%%1 <= uv1.uv_var1
* IdV1S2%%UserVar%%3 <= uv1.uv_var2
* IdV1S0%%Result2%%4 <= Job_Activity_11.$UserStatus
* IdV1S0%%Result1%%5 <= Job_Activity_11.$JobStatus
* IdV1S0%%Name%%6 <= Job_Activity_11.$JobName
*
*** [Generated at 2011-08-05 17:31:48 - 7.5.0.69]
   $INCLUDE DSINCLUDE DSJ_XFUNCS.H
   EQU Time$$ Lit "Oconv(Time(), 'MTS:'):': '"
****************************************
* Graphical Sequencer generated code for Job uv2
****************************************
   
   handle$list = ""
   id$list = ""
   abort$list = ""
   b$Abandoning = @False
   b$CPRestarted = @False
   b$InErrorRef = @False
   summary$restarting = @False
*** Create new checkpoint for sequence if not restarting
   If DSCheckPointExists(DSJ.ME, cp$dtm) Then GoTo L$RESTART
   Call DSLogInfo(DSMakeMsg("DSTAGE_JSG_M_0015\Starting new run of checkpointed Sequence job", ""), "@Coordinator")
   If (Not(DSCheckPointValidate(DSJ.ME, cp$msg))) Then
      err$source = "@Coordinator"; err$number = -1
      msg$ = DSMakeMsg("DSTAGE_JSG_M_0016\Error creating checkpoint record<L>%1", cp$msg)
      msg$id = "@Coordinator"; GoTo L$ERROR
   End
   GoTo L$MAINSTART
L$RESTART:
*** Validate restarted job matches prior state
   summary$restarting = @True
   Call DSLogInfo(DSMakeMsg("DSTAGE_JSG_M_0017\Sequence job is being restarted after failure<L>Checkpoint record last modified at %1", cp$dtm), "@Coordinator")
   b$CPRestarted = @True
   If Not(DSCheckPointValidate(DSJ.ME, cp$msg)) Then
      Call DSLogWarn(cp$msg, "@Coordinator")
   End
L$MAINSTART:
*** Sequence start point
   summary$ = DSMakeMsg("DSTAGE_JSG_M_0048\Summary of sequence run", "")
   If summary$restarting Then
      summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0049\Sequence restarted after failure", ""))
   End Else
      summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0050\Sequence started (checkpointing on)", ""))
   End
   GoTo L$V1S2$START
L$RETURN$1:
   GoTo L$WAITFORJOB
**************************************************
L$V1S0$START:
*** Activity "Job_Activity_11": Initialize job
   b$InErrorRef$V1S0 = b$InErrorRef
   jb$V1S0 = "nothing"
   b$V1S0skipping = @False
   h$V1S0$cp = "h$V1S0"
   If DSCheckPointGetValue(DSJ.ME, h$V1S0$cp, cp$value) = DSJE.NOERROR Then
      Call DSLogInfo(DSMakeMsg("DSTAGE_JSG_M_0021\Skipped run of job '%1' on restart", jb$V1S0), "@Job_Activity_11")
      job$V1S0$status = Raise(cp$value<1>)
      job$V1S0$userstatus = Raise(cp$value<2>)
      IdV1S0%%Result2%%4 = job$V1S0$userstatus
      IdV1S0%%Result1%%5 = job$V1S0$status
      IdV1S0%%Name%%6 = jb$V1S0
      summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0060\%1 (JOB %2) skipped", "Job_Activity_11":@FM:jb$V1S0))
      b$V1S0skipping = @True
      Goto L$V1S0$SKIPPED
   End
   summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0057\%1 (JOB %2) started", "Job_Activity_11":@FM:jb$V1S0))
   h$V1S0 = DSAttachJob(jb$V1S0, DSJ.ERRNONE)
   If (Not(h$V1S0)) Then
      err$source = "Job_Activity_11"; err$number = -1
      msg$ = DSMakeMsg("DSTAGE_JSG_M_0001\Error calling DSAttachJob(%1)<L>%2", jb$V1S0:@FM:DSGetLastErrorMsg())
      msg$id = "@Job_Activity_11"; GoTo L$ERROR
   End
   h$V1S0 = DSPrepareJob(h$V1S0)
   If (Not(h$V1S0)) Then
      err$source = "Job_Activity_11"; err$number = -1
      msg$ = DSMakeMsg("DSTAGE_JSG_M_0012\Error calling DSPrepareJob(%1)<L>%2", jb$V1S0:@FM:DSGetLastErrorMsg())
      msg$id = "@Job_Activity_11"; GoTo L$ERROR
   End
L$V1S0$PREPARED:
   p$V1S0$1 = (IdV1S1%%UserVar%%1)
   err$code = DSSetParam(h$V1S0, "p1", p$V1S0$1)
   If (err$code <> DSJE.NOERROR) Then
      err$source = "Job_Activity_11"; err$number = -1
      msg$ = DSMakeMsg("DSTAGE_JSG_M_0002\Error calling DSSetParam(%1), code=%2[E]", "p1":@FM:err$code)
      msg$id = "@Job_Activity_11"; GoTo L$ERROR
   End
   err$code = DSRunJob(h$V1S0, DSJ.RUNNORMAL)
   If (err$code <> DSJE.NOERROR) Then
      err$source = "Job_Activity_11"; err$number = -1
      msg$ = DSMakeMsg("DSTAGE_JSG_M_0003\Error calling DSRunJob(%1), code=%2[E]", jb$V1S0:@FM:err$code)
      msg$id = "@Job_Activity_11"; GoTo L$ERROR
   End
   handle$list<-1> = h$V1S0
   id$list<-1> = "V1S0"
   GoTo L$V1S1$RETURN$1
**************************************************
L$V1S0$FINISHED:
   job$V1S0$status = DSGetJobInfo(h$V1S0, DSJ.JOBSTATUS)
   job$V1S0$userstatus = DSGetJobInfo(h$V1S0, DSJ.USERSTATUS)
   summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0063\%1 (JOB %2) finished, status=%3[E]", "Job_Activity_11":@FM:jb$V1S0:@FM:job$V1S0$status))
   IdV1S0%%Result2%%4 = job$V1S0$userstatus
   IdV1S0%%Result1%%5 = job$V1S0$status
   IdV1S0%%Name%%6 = jb$V1S0
   rpt$V1S0 = DSMakeJobReport(h$V1S0, 1, "CRLF")
   dummy$ = DSDetachJob(h$V1S0)
   If b$InErrorRef$V1S0 Or (job$V1S0$status <> DSJS.RUNOK And job$V1S0$status <> DSJS.RUNWARN) Then Goto L$V1S0$SKIPPED
   cp$value = Lower(job$V1S0$status)
   cp$value<2> = Lower(job$V1S0$userstatus)
   dummy$ = DSCheckPointSetValue(DSJ.ME, h$V1S0$cp, cp$value)
   Call DSLogInfo(DSMakeMsg("DSTAGE_JSG_M_0025\Checkpointed run of job '%1'", jb$V1S0), "@Job_Activity_11")
**************************************************
L$V1S0$SKIPPED:
   If b$V1S0skipping Then GoTo L$V1S1$RETURN$1
   GoTo L$WAITFORJOB
**************************************************
L$V1S1$START:
*** Set user variables: "uv2"
   IdV1S1%%UserVar%%0 = (456)
   IdV1S1%%UserVar%%1 = (IdV1S1%%UserVar%%1 + 30)
   GoTo L$V1S0$START
L$V1S1$RETURN$1:
   GoTo L$V1S2$RETURN$1
**************************************************
L$V1S2$START:
*** Set user variables: "uv1"
   IdV1S1%%UserVar%%1 = (123)
   IdV1S2%%UserVar%%3 = ("abc")
   GoTo L$V1S1$START
L$V1S2$RETURN$1:
   GoTo L$RETURN$1
**************************************************
L$WAITFORJOB:
   If handle$list = "" Then GoTo L$FINISH
   handle$ = DSWaitForJob(handle$list)
   If handle$ = 0 Then handle$ = handle$list<1>
   Locate handle$ In handle$list Setting index$ Then
      id$ = id$list<index$>
      Del id$list<index$>; Del handle$list<index$>
      b$Abandoning = abort$list<index$>; Del abort$list<index$>
      Begin Case
      Case id$ = "V1S0"
         GoTo L$V1S0$FINISHED
      End Case
   End
* Error if fall though
   handle$list = ""
   err$source = "@Coordinator"; err$number = -1
   msg$ = DSMakeMsg("DSTAGE_JSG_M_0008\Error calling DSWaitForJob(), code=%1[E]", handle$)
   msg$id = "@Coordinator"; GoTo L$ERROR
**************************************************
L$ERROR:
   Call DSLogWarn(DSMakeMsg("DSTAGE_JSG_M_0009\Controller problem: %1", msg$), msg$id)
   summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0052\Exception raised: %1", msg$id:", ":msg$))
   If Not(b$InErrorRef) Then
      dummy$ = DSCheckPointSetValue(DSJ.ME, "!", DSMakeMsg("DSTAGE_JSG_M_0031\Failed at: %1, Reason=%2", err$source:@FM:msg$))
   End
   abort$list = Ifs(handle$list, Str(1:@FM, DCount(handle$list, @FM)), "")
   b$Abandoning = @True
   GoTo L$WAITFORJOB
L$ABORT:
   summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0055\Sequence failed (restartable)", ""))
   Call DSLogInfo(summary$, "@Coordinator")
   Call DSLogFatal(DSMakeMsg("DSTAGE_JSG_M_0014\Sequence job (restartable) will abort due to previous unrecoverable errors", ""), "@Coordinator")
**************************************************
L$FINISH:
   If b$Abandoning Then GoTo L$ABORT
*** At successful exit remove checkpoint record
   If Not(b$InErrorRef) And DSCheckPointExists(DSJ.ME, cp$dtm) Then
      dummy$ = DSCheckPointDelete(DSJ.ME)
      Call DSLogInfo(DSMakeMsg("DSTAGE_JSG_M_0018\Removed checkpoint record at successful completion of sequence", ""), "@Coordinator")
   End
   summary$<1,-1> = Time$$:Convert(@VM, " ", DSMakeMsg("DSTAGE_JSG_M_0054\Sequence finished OK", ""))
   Call DSLogInfo(summary$, "@Coordinator")
   L$EXIT: Return To L$EXIT
Post Reply