How can i change value of job parameter at run time.

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
DataStageCnu
Participant
Posts: 37
Joined: Sun Aug 01, 2004 1:18 am

How can i change value of job parameter at run time.

Post by DataStageCnu »

Hi Guys,

I have an small question. How can i change value of job parameter at run time. Here is the situation..

I had 15 stages in my job. In second stage, a value is going to generate. I need to catch that value and need to use in 15th stage for file name. So my intension is .... I will declare one job parameter. Now i have to assign that value to this Job parameter, so that i can use it in last stage as file name.

I would appreciate in advance

BB
davidnemirovsky
Participant
Posts: 85
Joined: Fri Jun 04, 2004 2:30 am
Location: Melbourne, Australia
Contact:

Post by davidnemirovsky »

Remove the last stage of your job (job1) and save the input rows for that stage into a temporary staging file (either a sequential file or hashed file).

Output the parameter you want to catch into a Sequential file or Database table.

Create another job (job2) that uses the temporary staging file as input and add the last stage you have removed from your original job.

Then create another job (job3) that uses Datastage BASIC in the Job Control tab of the 'Job Properties' dialogue to open the file/table, get the parameter and then use Job Control commands to set the parameter and also kick off the final job.
Cheers,
Dave Nemirovsky
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I think you could modify the routine in viewtopic.php?t=89419 post and change a parameter value in the current job.
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a job sequence to run the jobs.

In the job that generates the value, have it also place the value in that job's user status area.

In the next job, use Job2.UserStatus$ to retrieve the previous job's user status area value when loading the parameter value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jjrbikes
Premium Member
Premium Member
Posts: 117
Joined: Tue Nov 25, 2003 11:09 am
Location: Minneapolis

Post by jjrbikes »

Please excuse me for having a HUGE mental block - but Ray said:
In the job that generates the value, have it also place the value in that job's user status area.
How exactly would I accomplish that? With an after job routine? In the JobControl? How exactly do I get, say, a value from an output column into the UserStatus area??? I mean, I get the whole

Code: Select all

Call DSSetUserStatus (column.value)
deal and doing this process with a literal is no problem ie:

Code: Select all

Call DSSetUserStatus ("Pass This Value")
- but I'm struggling with how to move a newly computed value into the UserStatus area.

Thanks Again!
Jennifer
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I still do not like this method. I think it is cleaner to leave the result in a hash file and use the routine posted to change the parameter value to the one written to the hash file. I can do one or a hundred parameter values this way. All I need is a temporary holding place like a hash file or a sequential file. I posted the same routine which reads a complete list of parameters from a sequential file. A lot of people do this in batch files. I like sequences but need this functionality. I think more people would use sequences if they knew they could do this. They have been told for so long that you need a batch file for this that they have given up on trying to do this in a sequence. You do not need batch files any more with this technique.
Mamu Kim
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

kduke wrote:I think you could modify the routine in viewtopic.php?t=89419 post and change a parameter value in the current job.
This won't work if the job parameter is part of a filename AND the stream is continous (without a passive stage breaking the flow)

So, if your job looks like this:

SEQ --> XFM --> SEQ, then the target sequential file is created the instant the transformer output link starts. In that case, the filename is permanently fixed.

Now, if your job loks like this:

SEQ --> XFM --> HASH --> SEQ, then the target sequential file is not created until the hash file has finished receiving input rows. So, an after-transfomer routine call could in theory modify a job parameter value.

However, I failed to followup on the post Kim linked, because I am prejudiced against using internal hacks on the job design in a production jobstream. If Ascential changes ANYTHING on an upgrade it could potentially break these "hacks" and that's why I don't recommend these approaches.

There are NO documented facilities for dynamically changing a job parameter at runtime. There are MACROs that can be used to generate dynamic results in fixed fields, such as filenames, that could do what you wish. There's certainly plenty of functionality in job control APIs and Sequencers to provide your functionality. There's always my favorite, write a standard output filename and then rename into the final name, which is quick, easy, and painless.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

That may be true as far as a hack. I think it is safe to use.

This only works in a sequence job. You have to run it in a routine activity. I doubt if it would work in an ordinary job.
Mamu Kim
DataStageCnu
Participant
Posts: 37
Joined: Sun Aug 01, 2004 1:18 am

can i change value of job parameter at run time?

Post by DataStageCnu »

Hi All,

I was in vacation. Thats why i am unable to respond about this issue. I havn't used routines earlier, Could you plz assist me how to include some value in Job status in a job activity and how to retrieve in another job activity.
ray.wurlod wrote:Use a job sequence to run the jobs.

In the job that generates the value, have it also place the value in that job's user status area.

In the next job, use Job2.UserStatus$ to retrieve the previous job's user status area value when loading the parameter value.
I also want to send job name to the next job activity. How can i do?
And i am so thankful for your quick response.

Thanks,
BB
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You really need to start a new topic. This is a whole new question.
Mamu Kim
noamz
Participant
Posts: 9
Joined: Sun Oct 17, 2004 2:29 pm

Post by noamz »

Here is part of a routine I use to get parameter from SQL server during run time, and setting it to job parameter:


If ParamName = '' Then Return('')
ParamList = STAGECOM.JOB.CONFIG<CONTAINER.PARAM.NAMES>
Locate(ParamName,ParamList,1;ParamPos) Then
STAGECOM.JOB.STATUS<JOB.PARAM.VALUES,ParamPos> = ParamValue
End

Good lock,
Noam.
DataStageCnu
Participant
Posts: 37
Joined: Sun Aug 01, 2004 1:18 am

Post by DataStageCnu »

Thanks Bland,
kcbland wrote:
kduke wrote:1.) There are MACROs that can be used to generate dynamic results in fixed fields, such as filenames, that could do what you wish. There's certainly plenty of functionality in job control APIs and Sequencers to provide your functionality.

2.) There's always my favorite, write a standard output filename and then rename into the final name, which is quick, easy, and painless.
How can i generate required file name by using MACROs and what MACROs i can use?

and about point 2 is.. my job has one FTP stage and it is directly sending to our FTP server. How can i change file name(in FTP server) from UNIX env.

Could you please give clear picture..

Thanks,
BB
Post Reply