I have to take an input file INPUT_<MMDDYY99>.EXT and process it
and save the output in OUTPUT_<MMDDYY99>.EXT
How I can implement this .... Any help?
Dynamic Output File name
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 209
- Joined: Fri Jan 09, 2004 1:14 pm
- Location: Toronto, Canada
- Contact:
Re: Dynamic Output File name
I just had to do the same thing for an output file. See the link below to a thread for some good ideas on what to do on the UNIX side.murur wrote:I have to take an input file INPUT_<MMDDYY99>.EXT and process it
and save the output in OUTPUT_<MMDDYY99>.EXT
How I can implement this .... Any help?
I used the following command to rename my output file to have a timestamp:
Code: Select all
mv file file_$(date '+%Y%m%d').txt
Rob Wierdsma
www.bartonbishop.com
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
You've got two ways to go, you can ask the user to enter the date as a job parameter and then use this parameter to create INPUT and OUTPUT file names or you can retrieve the contents of the directory and find the file name using some BASIC code.
In this case you would look in the source directory, retrieve the file name, move the file to a processing directory and start processing it. That way you leave the landing directory free for files that haven't been processed yet. The date can be pulled out of the file name using various BASIC commands.
In this case you would look in the source directory, retrieve the file name, move the file to a processing directory and start processing it. That way you leave the landing directory free for files that haven't been processed yet. The date can be pulled out of the file name using various BASIC commands.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Here's an after-stage subroutine I baked earlier. It is passed the file pathname via the Input Value field - a job parameter reference can be used there. The purpose of this was to add the date between the base part of the file name and its suffix.
Code: Select all
SUBROUTINE RenameFileWithDate(InputArg, ErrorCode)
$COPYRIGHT "Copyright (c) 2004, Ray Wurlod. All rights reserved."
$* New file name has the form filename-YYYY-MM-DD.txt
EQUATE RoutineName To "RenameFileWithDate"
FilePath = InputArg
NewFilePath = Left(FilePath, Len(FilePath) - 4) ; * remove ".txt"
NewFilePath := "-" : Oconv(@DATE, "D-YMD[4,2,2]") : ".txt"
If System(91)
Then
* Windows
Call !GET.PATHNAME(NewFilePath, DirPath, BaseName, Code)
Command = "RENAME " : FilePath : " " BaseName
Shell = "DOS"
End
Else
* UNIX
Command = "mv " : FilePath : " " : NewFilePath
Shell = "UNIX"
End
Call DSExecute(Shell, Command, Output, Code)
Call DSLogInfo("Renamed " : FilePath : " to " : NewFilePath, RoutineName)
RETURN
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
To include a running oracle sequence or DS sequence
Hi guys,
Did any of you try to generate the output file name dynamically using a sequence. Basically, i want the output file to have the name as
<sequence_number><'STRING'><timestamp>.txt
The 'string' is a constant value, so no problem with that and no problem with timestamp, but generating the running sequence is a problem.
There is no restriction on how i need to generate the sequence.. I could either use DS sequence generator or the oracle sequence
Please share your suggestions with me.
Thanks,
Jyothi
Did any of you try to generate the output file name dynamically using a sequence. Basically, i want the output file to have the name as
<sequence_number><'STRING'><timestamp>.txt
The 'string' is a constant value, so no problem with that and no problem with timestamp, but generating the running sequence is a problem.
There is no restriction on how i need to generate the sequence.. I could either use DS sequence generator or the oracle sequence
Please share your suggestions with me.
Thanks,
Jyothi
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
You could maintain a sequence within a text file where you read a value in, increment it and write it back again. This is easily managed in a routine through the sequencial file commands. The routine would be called by the sequence job, it passes the name of the file, the routine opens the file and returns to the calling sequence job the next sequence number.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
And, if you do that, you can use UNIX commands to generate a file name that includes the sequence.
Yay!
It follows that you can use the same trick with dates and other bits of file names.
Code: Select all
touch myfile_`cat sequencefile`.txt
It follows that you can use the same trick with dates and other bits of file names.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.