Page 1 of 1

Passing before routine output in the datastage job parameter

Posted: Wed Oct 18, 2006 9:14 pm
by avi21st
Hi

I need to get the file name from a Database table(DB2). The table has a job name and file name cross reference.Then pass the file name as a job parameter to the sequential file which processes it.

I would like to have a before job shell which gets the file name and passes it to the job parameter. Is it possible?
( I can do it with a hash file with job name file name and file name- he look it up and pass it to the parameter-but have to change all the jobs which are already coded. A before routine would make it easy and nobody would even notice the change in design :lol: )

Posted: Wed Oct 18, 2006 9:30 pm
by avi21st
I forgot to add the main requirement:


Actually I do not want to hard code the file name in the Sequential stage..

I know the pattern <Some ID field>_<FileType>_<TimeStamp>

for examle 1121_UCSINV_10192006082945..

at the time of running the job we can hard code the first two values. I need to run the once having the most recent time stamp value in it.

I thought about putting it in table and then assign the job parameter...Is there some other way to run a file without hardcoding its whole name?

Posted: Wed Oct 18, 2006 11:29 pm
by ray.wurlod
Job parameter values must be set before the job run request is issued, and can not legally be changed thereafter.

Parsing is easy, use the Field() function with a delimeter argument of "_".

Posted: Thu Oct 19, 2006 12:21 am
by Kirtikumar
ray.wurlod wrote:can not legally be changed thereafter
Ray, just a bit curious to know - does this mean there is a illegal way to do this?

Search the forum for the setting job params and you find the way to set params in before job routines.
Use the job parameters and set their values in before job as suggested by Ray and you will have value from database.

If this filename is just a target filename, there is one more way.
You can do the samething using after job routines. Store the result in some temp job and write an after job routine which will rename the temp file to actual file. Here you can get the value from DB or have it whatever you want.

Posted: Thu Oct 19, 2006 4:43 am
by avi21st
Kirtikumar wrote:Use the job parameters and set their values in before job as suggested by Ray and you will have value from database.
I think I am not able to explain my requirements:

In a Unix directory I have a file. My job knows the direcoty path at run time and also knows the first part of the file name. I want my job to run any file that matchs the pattern.

How would I give the pattern in the Sequential Stage.

If I can do that- I do not need to assign job parameters.

Thanks for your help

Posted: Thu Oct 19, 2006 7:32 am
by chulett
How does your job 'know' these things? :? If it knows them, go ahead and use that knowledge in the Sequential File stage.

What you should be doing is parameterizing both pieces and use those parameters in the stage.

Forget about all this 'before routine sets parameter values in running job' or seeking any... 'illegal' means of doing so, that path only leads to the Dark Side.

Posted: Thu Oct 19, 2006 7:48 am
by DSguru2B
And Dark side can get scary :twisted: , right Craig ?

Posted: Thu Oct 19, 2006 8:11 am
by vsi
Hi Avishek

Though I did not understand your req. this might be helpful ,When you want to process all the files which has a particular pattern why don't you use Folder stage.



Thanks

Posted: Thu Oct 19, 2006 10:16 am
by avi21st
vsi wrote:Hi Avishek

Though I did not understand your req. this might be helpful ,When you want to process all the files which has a particular pattern why don't you use Folder stage.
Thanks
My doesn't know what is the file name. So I cannot use this parameter. What I know is the file pattern..

Like Unix uses metacharacters- can we use them in Datastage...so that the sequential file stage picks up any file if it matches the pattern

Posted: Thu Oct 19, 2006 10:28 am
by DSguru2B
Nop. Sorry, wild cards are not allowed in a server job. You will have to pre-determine the values of all the parameters and pass it to this job.

Posted: Thu Oct 19, 2006 10:46 am
by chulett
You'll need to either process all the files one by one in a loop or concatenate all files together pre-job and then process the combo file.

Posted: Thu Oct 19, 2006 12:42 pm
by ray.wurlod
Kirtikumar wrote:
ray.wurlod wrote:can not legally be changed thereafter
Ray, just a bit curious to know - does this mean there is a illegal way to do this?
Yes. I don't go there. And it may not work in version 8.0 and later.