Page 1 of 1
Job Control to execute a DS job
Posted: Tue Mar 08, 2011 4:26 am
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.
Posted: Tue Mar 08, 2011 4:56 am
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?
Posted: Tue Mar 08, 2011 6:00 am
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 ***********
Posted: Tue Mar 08, 2011 7:10 am
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.
Posted: Tue Mar 08, 2011 9:29 am
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.
Posted: Tue Mar 08, 2011 10:01 am
by battaliou
Can you paste the value of your input file ?
Posted: Tue Mar 08, 2011 11:22 am
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"
Posted: Tue Mar 08, 2011 2:54 pm
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).
Posted: Tue Mar 08, 2011 2:55 pm
by ray.wurlod
Now, what value is returned by each DSSetParam call?
Posted: Wed Mar 09, 2011 3:53 am
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]
Posted: Wed Mar 09, 2011 2:27 pm
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.
Posted: Thu Mar 10, 2011 3:32 am
by battaliou
De nada, I just noticed Ray's got more points than me.
Posted: Thu Mar 10, 2011 7:42 am
by chulett
battaliou wrote:I just noticed Ray's got more points than me.
You? All of us.
Combined.