Date parameter

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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How and where do you want to "recover" the file? What do you mean by this term?

If what you are looking to do is read a file whose name contains a date, you need to generate the file name in a job parameter - perhaps in the calling sequence or job control code - before starting the job, then using the parameter reference in the Sequential File stage.

Given that your example is using today's date (the Date() function), the code would look like the following. Assume that the job has a parameter called FileName, and the actual file name is of the form xxxxx_yyyymmdd.

Code: Select all

ParamName = "FileName"
ParamValue = "xxxxx_" : Oconv(Date(), "DYMD":@VM:"MCN")
ErrCode = DSSetParam(hJob, ParamName, ParamValue)
If ErrCode <> 0
Then
   * Code for handling "failed to set parameter value" error goes here
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
besco
Participant
Posts: 33
Joined: Wed Jun 09, 2004 1:44 am

Post by besco »

I have a sequential File with the filename :

#Rep#/#NomClient#/BlackList#date#.txt

When I call this job, I want that it will be get the file with the date of the day.

Ray, you told me : perhaps in the calling sequence or job control code.
But I will not recreate a job right for that. Have you got another idea ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It is not possible to do it within the job. Filenames, whether or not they contain resolved parameter values, are determined when the job starts; they can not be changed subsequently.

You must calculate values for job parameters before the job is started. This is a fundamental rule for DataStage jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The preceding post was based on the assumption that you're reading from the file. If you're writing to the file there is another way.
Write to a generic file (say, blacklist.txt) then use an after-job subroutine to change its name.
This has been discussed a number of times on this Forum; do a search for mv. You use ExecSH as an after-job subroutine to execute a UNIX command such as

Code: Select all

mv #Rep#/#NomClient#/BlackList.txt #Rep#/#NomClient#/BlackList`date +"%C%M%D" | cut -d' ' -f6`.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.
besco
Participant
Posts: 33
Joined: Wed Jun 09, 2004 1:44 am

Post by besco »

We can determinate value of my parameter before the job starts because it's just the date of the day.
I'm reading from the file and not writing.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

But you can not automate this within the job itself, unless by a reverse of the procedure I outlined earlier. Change the name of (or copy) the file to a generic name with ExecSH called as a before-job subroutine. Then have DataStage process from the generic file name. Perhaps remove or rename the processed file using ExecSH called as an after-job subroutine.

Note the use of back-quotes around the date command. This is a shell technique to capture the value returned by the command. Check the man pages for date about how to generate the appropriate format; you will probably need to pipe the output through cut to obtain just the pieces of date you require.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply