Job Control to execute a DS job

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
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Job Control to execute a DS job

Post by Aquilis »

Am trying to execute the job through Job Control. Job is getting executed but with parameters as Null values. when I assign parameters it's assigning Null values to the job. Can anybody figure where am going wrong.

Code: Select all

      PathName = ValueFileDir:'/':ValueFile

      Cmd2="cat ":PathName
      Call DSExecute("UNIX",Cmd2,ValueFileOutput2,SystemReturnCode2)
      File=ValueFileOutput2

      If SystemReturnCode2= 0 then
         Value1=Field((File<1>),'=',2)
        Value2=Field((File<3>),'=',2)
         Value3=Field((File<4>),'=',2)
         Value4=Field((File<5>),'=',2)
         Value5=Field((File<6>),'=',2)
         Value6=Field((File<7>),'=',2)
         Value7=Field((File<8>),'=',2)
     End
      Else
         Call DSLogFatal("Unable to open Value File ":PathName, "MyRoutine")
         Ans=1
      End

	  -------------------------
	  
* Set parameters  for the Job

      ErrCode= DSSetParam (hJob, "DirName", Value1)
      ErrCode= DSSetParam (hJob, "FileName", Value2)
      ErrCode= DSSetParam (hJob, "SchemaDirName", Value3)
      ErrCode= DSSetParam (hJob, "SchemaFileName", Value4)
      ErrCode= DSSetParam (hJob, "InsQuery", Value5)
      ErrCode= DSSetParam (hJob, "UpdQuery", Value6)
      ErrCode= DSSetParam (hJob, "FilterStmt", Value7)

      ErrCode= DSRunJob(hJob, DSJ.RUNNORMAL)


Parameters have some special characters like " / = ." , will those cause any problem. Am reading the parameters from a file & assigning them to Job.
when I read the parameters it's returning correct parameters but not assigning them to Job. point me where I went wrong.
kindly help.
Aquilis
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Test the value of ErrCode after each call to DSSetParam(). I presume that hJob is the result of an earlier successful DSAttachJob() call - did you check that it was successful?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

No, have checked this. It's not taking from previous run DSAttach().

DSSetParam() always assigning Null values. Some link is missing somewhere. I am not able to figure this.

Code: Select all

************************************************	  
	  PathName = ValueFileDir:'/':ValueFile 

      Cmd2="cat ":PathName 
      Call DSExecute("UNIX",Cmd2,ValueFileOutput2,SystemReturnCode2) 
      File=ValueFileOutput2 

      If SystemReturnCode2= 0 then 
         Value1=Field((File<1>),'=',2) 
        Value2=Field((File<3>),'=',2) 
         Value3=Field((File<4>),'=',2) 
         Value4=Field((File<5>),'=',2) 
         Value5=Field((File<6>),'=',2) 
         Value6=Field((File<7>),'=',2) 
         Value7=Field((File<8>),'=',2) 
     End 
      Else 
         Call DSLogFatal("Unable to open Value File ":PathName, "MyRoutine") 
         Ans=1 
      End 

	  
*************************************************************************
*****   Attach and execute the configurable DataStage job          ******
*************************************************************************

      * Create and Attach Job Handle
      hJob = DSAttachJob(JobHandle, DSJ.ERRWARN)
      If NOT(hJob) Then
         Call DSLogFatal("Bad Handle found ;Configurable DataStage JobName recieved is incorrect ", "MyRoutine")
         Ans=1
      End
      ErrCode = DSSetDisableProjectHandler( hJob, @FALSE)
      ErrCode = DSSetDisableJobHandler(hJob, @FALSE)
      JobStat = DSGetJobInfo (hJob, DSJ.JOBSTATUS)
      If (JobStat = DSJS.RUNFAILED) or (JobStat = DSJS.STOPPED) or (JobStat = DSJS.VALFAILED) Then
         Result = DSRunJob(hJob,DSJ.RUNRESET)
         ErrCode = DSWaitForJob(hJob)

         * Release handle for the job
         ErrCode = DSDetachJob(hJob)
      End

*************************************
*** Re-attach for execution ***
********************************
      * Attach Job and set the parameters
      hJob = DSAttachJob(JobHandle, DSJ.ERRWARN)
     If NOT(hJob) Then
        Call DSLogFatal("Bad Handle found ;Configurable DataStage JobName recieved is incorrect ", "MyRoutine")
        Ans=1
     End
     ErrCode = DSSetDisableProjectHandler( hJob, @FALSE)
     ErrCode = DSSetDisableJobHandler(hJob, @FALSE)

   
* Set parameters  for the Job 

      ErrCode= DSSetParam (hJob, "DirName", Value1) 
      ErrCode= DSSetParam (hJob, "FileName", Value2) 
      ErrCode= DSSetParam (hJob, "SchemaDirName", Value3) 
      ErrCode= DSSetParam (hJob, "SchemaFileName", Value4) 
      ErrCode= DSSetParam (hJob, "InsQuery", Value5) 
      ErrCode= DSSetParam (hJob, "UpdQuery", Value6) 
      ErrCode= DSSetParam (hJob, "FilterStmt", Value7) 

************************
*** Run the job **** 
************************
 ErrCode= DSRunJob(hJob, DSJ.RUNNORMAL)
      ErrCode= DSWaitForJob(hJob)
      Status = DSGetJobInfo(hJob, DSJ.JOBSTATUS)

      * Release the handle of the Job
      ErrCode= DSDetachJob(hJob)
      Ans=0

      IF Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then

         Call DSLogFatal("User defined: Job Execution Failed ", "MyRoutine")
         Ans=1
      End

	  
******** End of the script ***********
Aquilis
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

I tested this code and it works fine. Your file must either be empty or not contain '=' delimiters. Do a
call DSLogInfo(File,"File")
and examine the contents.

Of course if you require "=" to be included in your parameters you will have to use an index command to substring your parameters rather than the field command.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

No, Have checked everything. File is not empty & Yes I have multiple '=' for 1 parameter but atleast excluding that it should return values for other parameters.

when get DSLogInfo for the File, it showing perfect list of parameters. Don't no something going funny.
Aquilis
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

Can you paste the value of your input file ?
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Value file format is:

Code: Select all

Value1=/local/abc
Value2=/local/apps/Datastage/projects/ParameterSets/ps_abc
Value3=/local/apps/Datastage/projects/reusable
Value4=1.schema
Value5=INSERT INTO TB_OBJECTS (DEVIATION_ID, SAMPLE_ID, TEST_ID, TEST_VERSION, TEST_VARIANT, TEST_INSTANCE, IMPLICATION_DATE, DEIMPLICATION_DATE, IMPLICATED_BY, DEIMPLICATED_BY, REASON_FOR_DEIMPLICATION) VALUES (ORCHESTRATE.DEVIATION_ID, ORCHESTRATE.SAMPLE_ID, ORCHESTRATE.TEST_ID, ORCHESTRATE.TEST_VERSION, ORCHESTRATE.TEST_VARIANT, ORCHESTRATE.TEST_INSTANCE, ORCHESTRATE.IMPLICATION_DATE, ORCHESTRATE.DEIMPLICATION_DATE, ORCHESTRATE.IMPLICATED_BY, ORCHESTRATE.DEIMPLICATED_BY, ORCHESTRATE.REASON_FOR_DEIMPLICATION)
Value6=UPDATE TB_OBJECTS SET IMPLICATION_DATE = ORCHESTRATE.IMPLICATION_DATE, DEIMPLICATION_DATE = ORCHESTRATE.DEIMPLICATION_DATE, IMPLICATED_BY = ORCHESTRATE.IMPLICATED_BY, DEIMPLICATED_BY = ORCHESTRATE.DEIMPLICATED_BY, REASON_FOR_DEIMPLICATION = ORCHESTRATE.REASON_FOR_DEIMPLICATION WHERE (DEVIATION_ID = ORCHESTRATE.DEVIATION_ID AND SAMPLE_ID = ORCHESTRATE.SAMPLE_ID AND TEST_ID = ORCHESTRATE.TEST_ID AND TEST_VERSION = ORCHESTRATE.TEST_VERSION AND TEST_VARIANT = ORCHESTRATE.TEST_VARIANT AND TEST_INSTANCE = ORCHESTRATE.TEST_INSTANCE)
Value7=DEVIATION_ID <> "''" AND SAMPLE_ID <> "''" AND TEST_ID <> "''" AND TEST_VERSION <> "''" AND TEST_VARIANT <> "''" AND TEST_INSTANCE <> "''" AND IMPLICATION_DATE <> "1900-01-01 12:59:59" AND DEIMPLICATION_DATE <> "1900-01-01 12:59:59"
Aquilis
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I note in passing that there are "=" characters in the value of Value5 (you will need the fourth argument of the Field() function to be greater than 1 - any large number will do).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Now, what value is returned by each DSSetParam call?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

Ok, apart from the = issue in Value6, you have also assigned values in your parameters from 3 to 8 e.g. your code reads
Value2=Field((File<3>),'=',2)

surely you mean this to be
Value2=Field((File<2>),'=',2)
...
Value7=Field((File<7>),'=',2)


An easy fix for Value6 would be
Value6=File<6>[8,999] or
Value6=File<6>[index(File<6>,'=',1)+1,999]
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Got it fixed. One of my friends figured it out. Am using 8.1 & am directly reading Parameterset value files and assinging parameters respectively to the job.
Never came to mind about assigning parameterset with parameter value.
So when we assigned parameterset name to the value, it worked out.
Yes, there were some delimiter issue while reading through Field function as you people mentioned but managed to fix them as well.

Thank you.
Aquilis
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

De nada, I just noticed Ray's got more points than me.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

battaliou wrote:I just noticed Ray's got more points than me.
You? All of us. Combined. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply