Problems running a routine to compile a single 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

CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Problems running a routine to compile a single job

Post by CharlesNagy »

I have been tasked with writing a routine which can be called from a master Job Control which runs a list of specified jobs. We have opted not to use sequencer jobs because our job scheduling requirements are somewhat complicated. My routine tries to attach a job, and if it won't attach it assumes it is uncompiled and tries to compile it.

The routine works. If you look at the Director afterwards, it shows that the Job is compiled, and if you then try to run it, it runs, no problem. However, if the job is run from job control, whilst it completes with no errors, the job control which runs it falls over with:

Job control process (pid 13976) has failed

That is the only error I get. The routine is posted below, the only argument passed is Job Name

I pinched the job compile logic from a routine I found called "CompileAllJobs" which does in fact work, but I suspect that when run under Job Control, it must leave the job in some indeterminate status, which therefore causes the process to abort.

Would appreciate any comments or ideas about the below code.

Code: Select all

********************************************************************************
** This routine tries to compile the job specified                            **
** If unsuccessful, will report on it                                         **
********************************************************************************

$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H

      RoutineName = "CheckJobCompile"

      Equate LOG.WARN.NAME To RoutineName
      Equate LOG.OK.NAME   To RoutineName

      JobsCompiled = ""
      CompileStatus = 0

* Get the current job's name and number:

      MyJobNo = JobName
      SUBR = DSR.SUB.JOB
      Key = DSR.SUB.JOB.GETNO
      Call @SUBR(Key, MyJobNo)
      Dummy1 = "" ; Dummy2 = ""

      SUBR = DSR.SUB.JOB
      Key = DSR.SUB.JOB.RESERVE

      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)
      If Key <> "" Then
         WarnMsg = DSRMessage("", "Cannot attach to job '%1'", JobName):@FM:Key
         Call DSLogWarn(Lower(WarnMsg),LOG.WARN.NAME)
         CompileStatus = 0               ; * Unsuccessful compile
      End

      * try to compile it:
      Key = DSR.SUB.JOB.COMPILE
      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)
      If Key <> "" Or Arg2<1> <> "" Then
         WarnMsg = DSRMessage("", "Problems compiling job '%1'", JobName):@FM:Key:@FM:Arg2
         Call DSLogWarn(Lower(WarnMsg), LOG.WARN.NAME)
         CompileStatus = 0               ; * unsuccessful compile
      End Else
         JobsCompiled<-1> = JobName
         CompileStatus = 1               ; * successful compile
         Call DSLogInfo("Job ":JobName:" Successfully Compiled", LOG.OK.NAME)
         * Clear the RT_STATUS and RT_LOG files
         Ignore = 0
         JobNo = DSRGetJob(JobName,Ignore)
         Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
         Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo
      End

      Key = DSR.SUB.JOB.RELEASE          ; * unlock job, ignoring any errors
      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)

      Ans = CompileStatus
Last edited by CharlesNagy on Wed Nov 28, 2007 7:51 am, edited 2 times in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Problems running a routine to compile a single job

Post by chulett »

CharlesNagy wrote:(Sorry if the code is not indented, indents seem to have been stripped out in the posting process)
That's what the Code tags are for.

Code: Select all

********** Begin ******************

********************************************************************************
** This routine tries to compile the job specified                            **
** If unsuccessful, will report on it                                         **
**
**                                                                            **
********************************************************************************

$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H

      RoutineName = "CheckJobCompile"

      Equate LOG.WARN.NAME To RoutineName
      Equate LOG.OK.NAME   To RoutineName

      JobsCompiled = ""
      CompileStatus = 0

* Get the current job's name and number:

      MyJobNo = JobName
      SUBR = DSR.SUB.JOB
      Key = DSR.SUB.JOB.GETNO
      Call @SUBR(Key, MyJobNo)
      Dummy1 = "" ; Dummy2 = ""

      SUBR = DSR.SUB.JOB
      Key = DSR.SUB.JOB.RESERVE

      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)
      If Key <> "" Then
         WarnMsg = DSRMessage("", "Cannot attach to job '%1'", JobName):@FM:Key
         Call DSLogWarn(Lower(WarnMsg),LOG.WARN.NAME)
         CompileStatus = 0               ; * Unsuccessful compile
      End

      * try to compile it:
      Key = DSR.SUB.JOB.COMPILE
      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)
      If Key <> "" Or Arg2<1> <> "" Then
         WarnMsg = DSRMessage("", "Problems compiling job '%1'", JobName):@FM:Key:@FM:Arg2
         Call DSLogWarn(Lower(WarnMsg), LOG.WARN.NAME)
         CompileStatus = 0               ; * unsuccessful compile
      End Else
         JobsCompiled<-1> = JobName
         CompileStatus = 1               ; * successful compile
         Call DSLogInfo("Job ":JobName:" Successfully Compiled", LOG.OK.NAME)
         * Clear the RT_STATUS and RT_LOG files
         Ignore = 0
         JobNo = DSRGetJob(JobName,Ignore)
         Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
         Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo
      End

      Key = DSR.SUB.JOB.RELEASE          ; * unlock job, ignoring any errors
      Arg2 = JobName
      Call @SUBR(Key, Arg2)
      Call DSD.Init(MyJobNo, Dummy2)

      Ans = CompileStatus

****************** End *********
-craig

"You can never have too many knives" -- Logan Nine Fingers
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Re: Problems running a routine to compile a single job

Post by CharlesNagy »

chulett wrote:
CharlesNagy wrote:(Sorry if the code is not indented, indents seem to have been stripped out in the posting process)
That's what the Code tags are for.

Yup, just tried to repost with code tags, you were too quick for me...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This was actually 'pinched' from Kenneth Bland's KBA Job Control Utilities, comments and all. It even still includes the structures it needs to process an array of job names at a time or that are part of his job control. :?

Looks to me like you've got your CompileStatus values bass-ackwards. Zero would be considered success while a non-zero value (1, in your case) would indicate failure. I'm assuming that is what is tripping up your job control code.
-craig

"You can never have too many knives" -- Logan Nine Fingers
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

chulett wrote:This was actually 'pinched' from Kenneth Bland's KBA Job Control Utilities, comments and all. It even still includes the structures it needs to process an array of job names at a time or that are part of his job control. :?

Looks to me like you've got your CompileStatus values bass-ackwards. Zero would be considered success while a non-zero value (1, in your case) would indicate failure. I'm assuming that is what is tripping up your job control code.
Thanks Craig,

I didn't realise this was one of Ken Bland's routines, otherwise I would have given him credit. I just happened to find it on the server under "Utilities".

The CompileStatus flag is my own addition, which is just returned by my version of the routine so that I know wether the job compiled or not. Looking at the original code, it seemes to be around the right way... Whatever, after my routine is run, the Job Control attches the Job and runs it with no errors, it only falls over when it returns to Job control after running the job.....
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Yeah, it's from my stuff, but then again, my stuff is a conglomeration of 10 years worth of other peoples stuff. :lol:

If the compile works, and the function call returns successfully, I don't know what's going wrong with the calling process. If it fails, that means the code aborted. My guess is that your logic here is fine, your problem is in the calling code.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I think found your problem! Remove these lines.

Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo

My mass-compiler has this logic, but if you're using this logic as part of job control you can get into trouble whiping out the status information of a job if you're attached to it or have many instances you're currently running. See if this makes a difference.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

kcbland wrote:I think found your problem! Remove these lines.

Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo

My mass-compiler has this logic, but if you're using this logic as part of job control you can get into trouble whiping out the status information of a job if you're attached to it or have many instances you're currently running. See if this makes a difference.
Thanks Ken!

Will give it a go...
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

kcbland wrote:I think found your problem! Remove these lines.

Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo

My mass-compiler has this logic, but if you're using this logic as part of job control you can get into trouble whiping out the status information of a job if you're attached to it or have many instances you're currently running. See if this makes a difference.
Nope.... Still got the problem, but your suggestion has given me a couple of ideas. Perhaps the code is losing track of which job number it is on.... I will investigate further....

Thanks
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

CharlesNagy wrote:
kcbland wrote:I think found your problem! Remove these lines.

Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo

My mass-compiler has this logic, but if you're using this logic as part of job control you can get into trouble whiping out the status information of a job if you're attached to it or have many instances you're currently running. See if this makes a difference.
Nope.... Still got the problem, but your suggestion has given me a couple of ideas. Perhaps the code is losing track of which job number it is on.... I will investigate further....

Thanks
Further to my last post, I can't seem to resolve this any way I try. I removed the lines suggested by Ken but no luck. I ran the whole thing through as a function in test mode, and it works fine. (I put DslogInfo comments throughout). As soon as I try to run it from a job however, as soon as it hits the first call to DSD.Init, it craps out with the original error. The job gets compiled fine, but no other info messages are forthcoming.

I even tried creating a stand alone routine, compiling and cataloging it from the command line, and running it via an execute from within the job, so it wouldn't know it was being run from a job. Still no joy....

I suspect that a variable in common may be the culprit, but not having access to the code for DSD.Init, I have no clue as to which it could be.

I will probably implement a version of the CompileAll routine, and run it before I run the scheduler, to get around the problem. Thanks to everyone for their thoughts...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is it even valid to call DSD.Init after DSR.SUB.JOB.RELEASE ?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

ray.wurlod wrote:Is it even valid to call DSD.Init after DSR.SUB.JOB.RELEASE ?
It is my understanding that DSR.SUB.JOB.RELEASE is the argument that DSD.Init is called with. Anyhow, it was in the code I inherited. I don't pretend to understand what it does. I have tried to log on to Kens website to see if I can get his original code (but he hasn't approved me yet :( ), just in case the version I have has been "Imoroved".

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

Post by chulett »

Hmmm... since the routine seems to work when run stand-alone and only has issues when launched from your job control, perhaps we should look there rather than focus on the routine itself? If you are willing to post the code which calls the routine, that is. And it might help explain what you meant by this:
after my routine is run, the Job Control attaches the Job and runs it with no errors, it only falls over when it returns to Job control after running the job.....
No quite clear exactly where/how this error manifests itself in the grand scheme of things. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Just FYI, the job control goodies on my site has the major job control function that features compilation of jobs at startup as well as prior to running a job. My point is that compiling a job is not your problem, it's the code calling the compiling routine. That's why I thought clearing the status file was interfering with your running the same job.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

kcbland wrote:Just FYI, the job control goodies on my site has the major job control function that features compilation of jobs at startup as well as prior to running a job. My point is that compiling a job is not your problem, it's the code calling the compiling routine. That's why I thought clearing the status file was interfering with your running the same job.
Thanks Ken,

After you very kindly gave me access to your site, I was able to download the "Compile all jobs" code, and compare it with the code I had inherited. There was one slight difference, whether inadvertant or not.

The section right at the beginning of the code I was using says:

MyJobNo = JobName
SUBR = DSR.SUB.JOB
Key = DSR.SUB.JOB.GETNO
CALL @SUBR(Key, MyJobNo)

In your code it says:

MyJobNo = DSJobName

This makes all the difference. The routine now works when called from job control. (It always worked stand alone, ie in test mode)

I am going to mark this resolved now.

Thanks Ken!
Post Reply