Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use the current date in a file name

Status
Not open for further replies.

brindavoine

Programmer
Jul 3, 2005
6
FR
Hello every body,

I am beginning with DataStage. I need to develop a job that generates a file, and the name of the file must include the current date (e.g. FileName_2005-07-03.txt).

-1) I know how to load the current date into a variable, inside a job. But is it possible to use such a variable in a file name ?

-2) I know how to use a parameter to build a file name, but I don't know how to insert the current date into a parameter (my job is launched by the DS scheduler, and not by a unix shell)

Can anybody help me ?
Thanks a lot
 
Why dont you add a date parameter to the job, and use this date parameter in the file name, then build a batch to run the job setting the job's date parameter from the current date? Then you would schedule the batch that calls the job with the current date, rather than scheduling the job itself?
 
I'm sorry, but what do you mean by "build a batch" ?

If it is a Unix shell or DOS script, I'm looking for another solution : my job will have to run either on Unix or NT servers, so I try to be independant of the OS. All my code has to be inside DS.

If "batch" is a DS object, I don't know it. I know "server jobs" and "job sequencers". Is there anything else ?

I think my problem could be solved if a DS job could set the value of a parameter, and then launch another DS job using the parameter. Is that possible ?
 
Hi,

By "Build a batch" I mean create a DataStage batch. In DataStage, you would create a batch to run one or more DataStage jobs. The benefit of the batch is that you can include additional code between the job calls, and this is how you would be able to set the value of the current date into the job's date parameter.

I havent used DataStage for a little while so my terminology might be a little bit outdated (Sorry!)...I dont know if the "Job Sequencer" replaces the "batch" element....You create batches from the Director interface rather than from Designer.

Let me know if I'm still not making sense...
J
 
OK, thanks, this will be very helpful.
But I have to investigate and find out how to program in DS Basic...
 
You should just be able to add the job to the batch using DataStage's functionality, and it will automatically generate the code to run and call the job. Then all you would need to do would be to set a variable in the batch code before the job is added, something like (you will probably need to tweak the Oconv to format the date correctly)
Code:
TodaysDate = Oconv(Date(),"D-YMD")

Then you would just replace the parameter call into the job from whatever the hardcoded value is to the TodaysDate variable that you defined and set in the code above.

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top