Dynamic parameters in the sequencer

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
eldonp
Participant
Posts: 47
Joined: Thu Jun 19, 2003 3:49 am

Dynamic parameters in the sequencer

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post 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
eldonp
Participant
Posts: 47
Joined: Thu Jun 19, 2003 3:49 am

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
Post Reply