Appending timestamp to filename

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Appending timestamp to filename

Post by swathi.raoetr »

Building some simple enough extracts, but need to append filename. I have a sequence job, in which I have a user variable activity. I have used DSJObStartTimestamp. Then used this on the parameter at Job Activity calling the parallel job. No compilation or validation errors. But the job gets aborted on run time. Any suggestions? I want to avoid post unix scripting, as I think DataStage should be able to handle this.
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

You didn't provide any messages from Director, so this is a guess: is the file being written to a Unix server or a Windows server? If Windows, your timestamp format might violate Windows file name restrictions.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

you can just do this in the user variable stage..

'filename':CurrentTimestampMS()
or
variable:CurrentTimestampMS()

if the format is not acceptable for your filesystem, you can to a replacement of the offending characters ( : is probably the issue, replace that with - or something), or run the timestamp with a formatting string
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Post by swathi.raoetr »

FranklinE:

Writing to a hdfs@unix with a file connector.
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Post by swathi.raoetr »

UCDI:

For some reason, when I use 'filename':CurrentTimestampMS() in user variable activity stage it is giving the error variable CurrentTimestampMS() not defined; PS: We are not admins for this environment.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You may not need to pass in the timestamp, the DSJobStarttime macro should be able to be used directly in the parallel job as part of the filename in the connector stage. Unless you need to reformat it, as noted, then that would need to happen in the sequence job before passing it to the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Post by swathi.raoetr »

Tried few options... only way the timestamp's not throwing an error, is by calling the system variable and not the macro. @Date... but this is giving converted 5 digit integer, rather than actual timestamp. Using ereplace.... need to sort the syntax for replacing the special characters.
koti9
Participant
Posts: 52
Joined: Wed Nov 09, 2005 10:51 am

Post by koti9 »

You may simply call unix shell command in sequence `date +%Y%m%d%H%M%S` and pass it as parameter the next job activity
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Post by swathi.raoetr »

Wanted to avoid shell if possible thru DS... this worked at runtime
ereplace(ereplace(ereplace(DateCurrentGMTTime(-3),':',''),'.',''),'-','')
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... resolved?
-craig

"You can never have too many knives" -- Logan Nine Fingers
swathi.raoetr
Participant
Posts: 22
Joined: Tue May 09, 2017 8:46 am

Post by swathi.raoetr »

Yes, Thanks for the inputs given :o
Post Reply