how to generate a dynamic file name

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
Angel
Participant
Posts: 18
Joined: Thu May 29, 2003 8:46 am
Location: Spain

how to generate a dynamic file name

Post by Angel »

Hi,
I want to create a file name during run time. There is the DSJobStartDate macro, but probably I not used it correctly. How can I use it?.

I am writing this one in the Sequential file stage:
File Name: /var/opt/aat/p/sl/shr/carga_fz_SLDIOMQ:'_':DSJobStartDate
but the file name result is carga_fz_SLDIOMQ:'_':DSJobStartDate and not carga_fx_SLDIOMQ_2003_09_03.

Thanks,
Angel
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

Angel

afaik, this can't be done in a sequential file stage. All you can do there to derive a file name is to use job parameters.

Stephan
ariear
Participant
Posts: 237
Joined: Thu Dec 26, 2002 2:19 pm

Post by ariear »

Hi,

You must enclose the macros like regular params i.e. #SomeDefinedParam#_#DSJobStartDate#_#DSJobStartTime#
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

You live and learn! (or better: YLAL [:D])

Stephan
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

TestDate_#DSJobStartDate#_#DSJobStartTime#.txt

this is the filename that has been generated when I have used:
#SomeDefinedParam#_#DSJobStartDate#_#DSJobStartTime#


ariear, Can anyone tell me what is the proper syntax for this and also the proper 'Type' I should use for the job parameter.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The syntax looks OK, provided that the references to job parameters or macros are properly spelled and cased.
The parameter type can be String or Pathname. I'd recommend Pathname, because (a) you can then locate the text file anywhere in the file system, and (b) the operator gets a browser when being prompted for the file name.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

I have done it using Pathname and the problem still persists.

the filename that is being generated is:

TestDate_#DSJobStartDate#_#DSJobStartTime#.txt

the macros are not being evaluated into values, and also i am not enclosing the above in any quotes.

Can Ray.Wurlod or ariear comment on this, please ?

thanks
Optico
Participant
Posts: 23
Joined: Thu Sep 18, 2003 9:32 am

Post by Optico »

I don't know if there will be any other comments that you can use, but using the DSJobStartDate encompassed by '#' in the filename works perfectly on a 5.1 installation running on W2K.
Unfortunately you cannot browse the file from the Designer afterwards but you can from the explorer.



B. Sorensen,
Optico IT ApS
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

great it worked!!.. thanks

can it also create folders dynamically?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In general, no. The Sequential File stage works with files. However, if you need to create a directory you can set up ExecSH (or ExecDOS on a Windows platform) as a before-stage subroutine with an appropriate mkdir command in the InputArg field. You can use job parameters and macros here too.
You might want to include a test for existence before trying to mkdir because, if ExecSH fails, the job aborts. For example:[-d #pathname#] !! mkdir #pathname# && chmod 664 #pathname#

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply