Error while calling a job from Job Control Code

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
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Error while calling a job from Job Control Code

Post by Titto »

Hi all,

I am trying to run a job from Job Control in Job Parameters.
Basically i get a file and i need to read the file to get the values as a parameters and call another job. But while i am running the main Job i am getting following error.

"Job_Parms..JobControl (fatal error from DSSetParam): Job control fatal error (-1)
(DSSetParam) Invalid job handle <Missing or NULL>"


Any thoughts!!!

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

Post by chulett »

Post your code.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Titto,

Make sure you have attached to your job using DSAttachJob function shown below. Alternatively if you are referring to the current job, you can use the job handle as DSJ.ME

Code: Select all

JobHandle = DSAttachJob (JobName, ErrorMode)
Then you need to use this job handle in the DSSetParam function to set the parameters

Code: Select all

ErrCode = DSSetParam (JobHandle, ParamName, ParamValue)
It seems like your jobhandle is not getting set properly.

Thanks,
Naveen
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Here is my Code
Where A -to- K are values from ParameterFile and I am trying to call another job by passing A -to- K values as paramter.

Code: Select all

*---------------------------------------------------------------------------- 
* Get Parameters
*----------------------------------------------------------------------------
      ParameterFile = DSGetParamInfo(DSJ.ME, "parmParameterFile", DSJ.PARAMVALUE)      
      TempJobName = DSGetParamInfo(DSJ.ME, "parmJobName", DSJ.PARAMVALUE)
*----------------------------------------------------------------------------
* Open the file...
*----------------------------------------------------------------------------

      OpenSeq ParameterFile To ParameterFileVar
      On Error
         Msg = 'Error opening parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
         Call DSLogFatal(Msg, TransformName )
         Abort
      End
      Else
         Msg = 'Cannot open parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
         Call DSLogFatal(Msg, TransformName )
         Abort
      End

*----------------------------------------------------------------------------
* File Opened
* Read the parameter list from the file.
*----------------------------------------------------------------------------
      If FileInfo(ParameterFileVar, 0)
      Then
        ReadSeq Line From ParameterFileVar

      Else
         Msg = 'Cannot read parameters file, ' : SQuote(ParameterFile): ', status = ' : Status()
         Call DSLogFatal(Msg, TransformName )
         Abort
      End

*----------------------------------------------------------------------------
*All the parameters from the Parameter file
*----------------------------------------------------------------------------


        A= IsNull(Field(Line,',',1,1))
         B= IsNull(Trim(Field(Line,',',2,1)))
         C= IsNull(Left(Trim(Field(Line,',',3,1)),2))                    
         D= IsNull(Right(Trim(Field(Line,','3,1)),6)) 
         E= IsNull(Field(Line,',',4,1))
         F= IsNull(Field(Line,',',5,1))
         G= IsNull(Field(Line,',',6,1))
         H= IsNull(Field(Line,',',7,1))
         I= IsNull(Field(Line,',',8,1))
         J= IsNull(Field(Line,',',9,1))
         K= IsNull(Field(Line,',',10,1))


         CloseSeq ParameterFileVar

      End
       

      JobHandle = DSAttachJob(TempJobName, DSJ.ERRFATAL)
      Status = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)

*----------------------------------------------------------------------------
*To check is the job is in runnable state.
*If not its reset
*----------------------------------------------------------------------------

      If Status = DSJS.RUNFAILED or Status = DSJS.STOPPED Then
         Call DSLogInfo("Job is to be reset: " : TempJobName, RoutineName)
         ErrCode = DSRunJob(JobHandle, DSJ.RUNRESET)
         ErrCode = DSWaitForJob(JobHandle)
         Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
         If Status <> DSJS.RESET Then
            Call DSLogFatal("Job Failed TO RESET: " : TempJobName, RoutineName)
         End
         ErrCode = DSDetachJob(JobHandle)
         JobHandle = DSAttachJob(TempJobName, DSJ.ERRFATAL)
         If NOT(JobHandle) Then
            Call DSLogFatal("Job Attach Failed: " : TempJobName, RoutineName)
            Abort
         End
      End

*----------------------------------------------------------------------------
*The parameters are set for the job
*----------------------------------------------------------------------------

          ErrCode = DSSetParam(JobHandle, "A", A)     
          ErrCode = DSSetParam(JobHandle, "B", B)      
          ErrCode = DSSetParam(JobHandle, "C", C)
          ErrCode = DSSetParam(JobHandle, "D", D)
          ErrCode = DSSetParam(JonHandle, "E" ,E)
          ErrCode = DSSetParam(JonHandle, "F" ,F)
          ErrCode = DSSetParam(JonHandle, "G" ,G)
          ErrCode = DSSetParam(JonHandle, "H" ,H)
          ErrCode = DSSetParam(JonHandle, "I" ,I)
          ErrCode = DSSetParam(JonHandle, "J" ,J)
          ErrCode = DSSetParam(JobHandle, "K", K)
         

      ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
      ErrCode = DSWaitForJob(JobHandle)
      Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
      If Status = DSJS.RUNFAILED Then
         ErrMsg = "PollingJob Job failed to run!"
         Call DSLogFatal("Job Failed: PollingJob", "JobControl")
      End

Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Include a check of job handle being null.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Hi Sai,

you mean

JobHandle = IsNull(DSAttachJob(TempJobName, DSJ.ERRFATAL))

Please clarify me!

Thanks
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

No.

JobHandle = IsNull(DSAttachJob(TempJobName, DSJ.ERRFATAL))

If IsNULL(JobHandle) Then
Write message
Error ??
End

SetParam
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Hi Sai,
I am kind of confused!!!
i added this code just before DSSetparm

If IsNull(JobHandle) Then
Msg = "job handle is Null:"
End

Guide me pls
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are a couple of misspelled variable names JonHandle rather than JobHandle. Fix these.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Good eye! I didn't notice the JonHandles. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Pass Parameter JOB Seq to another JOB Seq

Post by Titto »

Thanks Ray!!!
I changed it - it is passing the parameters to next job and next job working fine but the main job aborted with following error

"Job_Parms..JobControl (fatal error from DSGetJobInfo): Job control fatal error (-1)
(DSGetJobInfo) Invalid job handle <Missing or NULL>"

-----
I have a question - Is it possible to pass parameter from JOB Sequencer to another JOB Sequencer.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Definitely yes.

A job sequence is simply a special case of a server job, one that consists solely of job control code (which is read-only).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Hi Ray,

May be my question was wrong.
my requrement is - I will get a fine with values, i need to read those values and pass as parameters to next job and from that job to next job.
I am trying to use JOB control to write a small code to read the seq file and Attach a Job with DSSetparam and call next JOB1 and after successful of JOB1 same parameters needs to pass to JOB2 then JOB3 and then to JOB4.

For the above process, I used a Dummy job to read the Seq file(JOB1) and JOB2. For JOB1 and JOB2 i used a JOB Sequencer (Job2 will get called inturn from job1). so for now JOB3 and JOB4 do i need to use the same job sequencer or different one? If i correct we can't use same parameter which got populated in same job.

[img]JOB1%20----->%20JOB2------>%20JOB3%20----->%20JOB4[/img]


Please direct me!

Thanks in Advance!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You appear to have a one-line parameter file containing ten comma-delimited values with which you want to replace eleven job parameters.
The IsNull functions in your original code thwart this intent.

Assuming you're using version 7.5, you can create a job sequence that begins with an Execute Command activity to cat the file. The output from this is available when setting parameter values for downstream jobs.

For example, parameter B would be set as

Code: Select all

Field(ExecCmd.$CommandOutput, ",", 2, 1)
Note there is no IsNull() function involved. I've assumed ExecCmd to be the name of the Execute Command activity; you would choose this from the displayed list of job parameters when editing a downstream Job Activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can also load your param file in memory and them use scripts to process them. But ensure that your passwords are properly encrypted or hidden.
Post Reply