Page 1 of 1

Dynamic parameters in the sequencer

Posted: Sat May 17, 2003 11:39 am
by eldonp
I have some code that generates various dates from the DSGetJobStartTime function.I write these into a parameter file.I then read these from the file in a coded control job, assign these to variables then to other job parameters (DSSetParam).This way I do not have problems with choosing correct parameter dates.However,I need to impliment this in the job sequencer.

My problem is, how do you declare variables in the sequencer. How do you read from a flat file (ReadSeqFileLine Field(......)) and assign this to a variable.Finally, how do I pass the variable's values to other jobs.

Posted: Sat May 17, 2003 5:40 pm
by ray.wurlod
You can declare parameters in a job sequence in the normal way but, like every other job, their values are set when the job starts. There is no concept of "dynamic parameters".
This must be achieved indirectly. You need to construct your job sequence and compile it, then modify the code that was generated to read the contents of the file and load child jobs' parameters with the requisite values.
Use ReadSeq statements to read lines from the text file into variables, then use DSSetParam() to load the values from these variables into the other jobs.


TextFile = "./MyParams"
OpenSeq TextFile To TextFileVar
On Error
Msg = 'Error opening parameters file, status = ' : Status()
Call DSLogWarn(Msg, "Job Control")
End
Else
Msg = 'Cannot open parameters file, status = ' : Status()
Call DSLogWarn(Msg, "Job Control")
End
If FileInfo(TextFileVar, 0)
Then
Loop
While ReadSeq Line From TextFileVar
ParamName = Trim(Field(Line,"=",1,1))
ParamValue = Trim(Field(Line,"=",2,1))
ErrCode = DSSetParam(hJob, ParamName, ParamValue)
Begin Case
Case ErrCode = DSJE.BADPARAM
Msg = 'Parameter ' : ParamName : ' not found.'
Case ErrCode = DSJE.BADVALUE
Msg = 'Value ' : Quote(ParamValue) : ' not legal.'
Case ErrCode = DSJE.BADHANDLE
Msg = 'No Job attached.'
End Case
If Len(Msg) > 0
Then
Call DSLogWarn(Msg, "Job Control")
End
Repeat
CloseSeq TextFileVar
End


For anyone who is interested, formatting was preserved by preceding the code with a < pre > tag, and following it with a < /pre > tag.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518

Posted: Tue May 20, 2003 3:12 pm
by tonystark622
Ray,

I wanted to thank you for posting this code. I used the snippet you posted as a basis for a batch job that reads the job parameters from a file, then launches the job with those parameters. Not exactly what they wanted, but close enough for now. (they wanted to read parameter values from a file and modify Job Parmeters within the current job.)

Muchly appreciated :)

Tony Stark

Posted: Tue May 20, 2003 4:44 pm
by ray.wurlod
This has been discussed at length on this Forum; a trawl through the archives may be beneficial. The one line summary:

It is NOT POSSIBLE to modify a job's parameter values once that job has started.

Parameters are read into system variables when the job is started, and remain there unchanging.

You *could* hack the job control code, discover the names of those variables and assign different values. Some folks have gotten that far, only to discover that they have no way of compiling the code! If you re-compile from the Designer, you lose your hacks.

Posted: Wed May 21, 2003 7:14 am
by tonystark622
Ray,

Thanks! That just verifies what I told the client, "You can't do that!" :)

Thanks again for the code. It did help me to give them a way to read parameters out of a file.

I did search through the archives, but didn't come up with much. Guess I need to refine my search criteria. :)

Tony

Posted: Wed May 21, 2003 8:58 am
by eldonp
After all, I was able to do it. I created a transform routine, using the oconv funtion to get the system date and calculated the derivitives of the date I needed. In the sequencer, I used the RoutineActivity stage to call the transform routine and assigned the returnvalue to parameters of other jobs.

Posted: Wed May 21, 2003 6:24 pm
by ray.wurlod
I would make the point, though, that you did not change the values of a job's own parameters once that job was running.