Page 1 of 1

Error while calling a job from Job Control Code

Posted: Mon Jul 18, 2005 12:03 pm
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

Posted: Mon Jul 18, 2005 12:27 pm
by chulett
Post your code.

Posted: Mon Jul 18, 2005 12:35 pm
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

Posted: Mon Jul 18, 2005 12:57 pm
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


Posted: Mon Jul 18, 2005 1:16 pm
by Sainath.Srinivasan
Include a check of job handle being null.

Posted: Mon Jul 18, 2005 1:18 pm
by Titto
Hi Sai,

you mean

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

Please clarify me!

Thanks

Posted: Mon Jul 18, 2005 1:20 pm
by Sainath.Srinivasan
No.

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

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

SetParam

Posted: Mon Jul 18, 2005 1:36 pm
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

Posted: Mon Jul 18, 2005 3:14 pm
by ray.wurlod
There are a couple of misspelled variable names JonHandle rather than JobHandle. Fix these.

Posted: Mon Jul 18, 2005 3:18 pm
by chulett
Good eye! I didn't notice the JonHandles. :wink:

Pass Parameter JOB Seq to another JOB Seq

Posted: Mon Jul 18, 2005 3:45 pm
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

Posted: Mon Jul 18, 2005 4:51 pm
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).

Posted: Mon Jul 18, 2005 7:19 pm
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!

Posted: Mon Jul 18, 2005 9:08 pm
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.

Posted: Tue Jul 19, 2005 2:09 am
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.