DSD.SEQOpen Unable to create file

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
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

DSD.SEQOpen Unable to create file

Post by pmadhavi »

Hi
I have to generate a flat with with the timestamp in the name of the file.
I gave Test_#DSJobStartTimestamp#.txt; it throws an error
DSD.SEQOpen Unable to create file

I gave Test_#DSJobStartTime#.txt; it throws an error.

DSD.SEQOpen Unable to create file D:\TestFolder\Test16:38:43.csv.

If I give Test_#DSJobStartDate#, it is working fine.

But I need to have the file with timestamp because the job may run more than once in a day.

Is it because there is a colon in the timestamp?
Somebody in one of the postings suggested to replace the ':' with '-'.
But we have to do it before we cretae the file.

Can we give the calculated column name as part of the file name?

Did anybody come across such situation? pls help me out.

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

Post by chulett »

The colon isn't valid in a Windows filename, it's part of a drive designator.

As noted many many times here, rather than fight this before or during the job, best to create a static filename and then rename it 'after job' to suit your needs. A standardized UNIX script or DOS batch file could do the trick.
-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 »

... but you still won't be able to use ":" in a Windows pathname except immediately following the drive letter. In short, you can not break the rules of the operating system.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

my requirement is to copy a file to a share drive for business users.

I need to make the file unique so that next time when i run the job it should not get overwritten.

Do we have any other way of achieving this?
pls throw some light on this.
Thanks,
Madhavi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Go with your original idea - just don't try to put colons in the filename. As noted, best to create the file with a fixed name and then write a BAT file to rename the file 'after job' to include the current date/time or whatever else you'd like to include to make it unique...

You may also be able to engineer the renaming to occur during the actual copying of the file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

I created a routine with the code given below(to remove : and spaces from the Timedate())

FileName = Arg1
Addtag=ereplace(ereplace(ereplace(TimeDate(),':',''),' ','_',1),' ','')

NewFileName = FileName:"_":Addtag:".txt"
Ans=NewFileName
-------------------------------------------------------

I have a job sequence wherein I am calling the server job first(where the actual flat file gets created)
next I am calling the routine mentioned above to cretae a new file name with timestamp details in it.
then I have Execute Command Stage where I am calling a batch file which copies the file to the shared drive. In the batch file the target file name would be the output of the routine stage.

But I am not able to view the Routine stage output in the Execute command stage.

Please suggest me how to pass the target filename from Routine stage to Execute command stage.
Thanks,
Madhavi
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

I am not sure how you are passing the filename to the Routine Activity stage in the JobSequence. But here's suggestion which might or might not meet your requirements. Use a UserVariable activity and create one parameter. In the expression editior call the Renaming routine you have created and pass the filename to that routine. Then pass this to the Execute Command Activity stage and you should be set. If not, another method I can think of would be looking at the defining a Custom trigger coming out from your Routine Activity Stage.

IHTH
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pmadhavi wrote:But I am not able to view the Routine stage output in the Execute command stage.
No idea what this means. :? Nothing should be stopping you from using the output of the routine in the Execute Command stage just like you could in any downstream stage.

Code: Select all

#YourRoutineStageName.$ReturnValue#
That would equate to the filename it builds.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

Thanks for a quick reply.

Sorry for not mentioning the version I am using. It is DS7.1r1 where most of the features are not there. Not even the User variable stage u mentioned.

The thing is the file name which is getting created when we run the job, is static. So I hardcoded the job name in the parameter section of the Routine activity to get a new file name. Till that step it is working fine.

any suggestions are welcome.
Thanks,
Madhavi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, in that case you need to replace the Execute Command stage with another Routine Activity stage. You'll also need to write a generic routine that runs an operating system command using DSExecute. In that routine you can ensure that all of the parameter arguments get evaluated properly.

Or a specific routine that just runs the script in question, passing in whatever you need as arguments to the routine... including this new filename.
-craig

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