Page 1 of 1

how to pass filename to sequential file stage in runtime

Posted: Tue Jun 05, 2018 4:26 am
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

Posted: Tue Jun 05, 2018 6:08 am
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.

Posted: Tue Jun 05, 2018 8:32 am
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.

Posted: Tue Jun 05, 2018 11:29 pm
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.

Posted: Wed Jun 06, 2018 6:33 am
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:

Posted: Wed Jun 06, 2018 11:00 pm
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

Posted: Wed Jun 06, 2018 11:49 pm
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:

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

Posted: Wed Jun 06, 2018 11:54 pm
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.

Posted: Thu Jun 07, 2018 12:01 am
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"

Posted: Thu Jun 07, 2018 7:21 am
by chulett
Totally outside. :wink: