how to pass filename to sequential file stage in runtime

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
rrcr
Participant
Posts: 4
Joined: Thu Jul 06, 2017 12:00 am

how to pass filename to sequential file stage in runtime

Post by rrcr »

Hi,

I want to pass file name to sequntial file stage in runtime without using parameters. I heard it can be done with routines .Pleasse let me know how to do with routines . Also if any other ways to pass.
Example . include date in filename. like abc_20180605.txt

Thanks,
Rrcr
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome!

First off, why "without using parameters"? They are a core part of the product and trying to do it without them seems to me to be an unnecessary complication. But then that could depend on what "in runtime" means... do you mean from data generated / derived inside the job rather than from outside it? Please clarify your source for this variable, this date, and where it needs to be passed from.

I'd also be curious where you heard it can be "done with routines" because (to me at least) that statement is open to interpretation. Typically to me that would mean a custom routine in BASIC, written to get the current date in a specific format, called in a Sequence job, whose output is passed as a job parameter to the Job Activity running the job with the sequential file stage. Seems to me you are thinking of something else.
-craig

"You can never have too many knives" -- Logan Nine Fingers
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

you can do it in a parallel job too if you use vb transformer or one of the others, I think there is a java one etc?

most of the time this sounds like a parallel job (with a parameter) invoked from a sequence that has either a routine or user-variable stage to cook up the text.

For file name that just has a date pattern appended to it, you can use like a row generator feeding a transform to get today's date and append it to a static text to create the name. But you have to figure out how to get it into the name field of the next stage from there, I think its doable, but might take a little encouragement. I haven't tried this, but there is probably a way... there is also a weird stage in 'file handling' boAppendToVariableFileName but it has no documentation that I can find.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Historically the method was to write to a basic file name then to use an after-job subroutine (calling an operating system command or batch file) to change the file name.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Still seeking... clarification.

Also, from what I recall isn't there a mechanism to pass row data to the file stage for it to use in the filename? Define a key with some kind of "use value" property enabled and it uses that column data in the filename? Mostly meant for creating a series of related files but you should be able to keep it at the same dynamic filename by never changing the value of the key.

From what I recall. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
rrcr
Participant
Posts: 4
Joined: Thu Jul 06, 2017 12:00 am

Post by rrcr »

Without Parameters , what i mean is you should not pass the date from outside. we should generate the date and form the file name. My requirement is i will be getting files for each day and i want to read a file that comes today when my batch runs. In Routines can be pass a value to existing filed i.e filename
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So you want to read a file source who's name changes every day? That's completely different than what everyone assumed you meant with your initial description, everything before this is about a target file.

There's no mechanism to generate a filename inside a source stage, it all has to come "from outside" in some fashion. And it sounds to me like all you need is to leverage a wildcard pattern. Or perhaps the filter option? Seems a bit overkill to me. Or if somehow those don't fit the bill, perhaps the dreaded indirect read mechanism that was all the rage about three years ago. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: how to pass filename to sequential file stage in runtime

Post by chulett »

rrcr wrote:I heard it can be done with routines.
I'd suggest you ask whomever you heard this from to explain how this would be made to work. I suspect you may be talking about some ill-advised / completely unsupported under-the-cover mechanisms I haven't heard mentioned here in many, many years. That or they are simply incorrect.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Assuming that the controlling sequence is not "outside", then you could generate the file name in a User Variables activity or a Routine activity in the sequence, and pass the file name as a job parameter in the Job activity that invokes the job.

User Variables expression:

Code: Select all

"abc_" : Oconv(@DATE,"DYMD[4,2,2]":@VM:"MCN") : ".txt"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Totally outside. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply