Page 1 of 3

Concatenating Timestamp With a Sequential file

Posted: Wed Jul 12, 2006 7:30 am
by mdtauseefhussain
HI! All

I have a job which is loading data in to a sequential file ,This jobs runs 5 times a day. I want to generate a file with filename concatenated with timestamp every time the job finishes. Therefore I need to generate five files a day for example: "OrderInvoice 23/06/2006 00:00:00 AM"

Is there any method in DataStage or through UNIX to achieve it? Please help me out/

Thanks in advance!

Tausif

Re: Concatenatnating Timestamp With a Sequential file

Posted: Wed Jul 12, 2006 7:33 am
by DSguru2B
In the sequential file stage, use macro DSJobStartTimeStamp
OrderInvoice#DSJobStartTimeStamp#.txt

I am not exactly sure if this functionality is available in version 5.

Posted: Wed Jul 12, 2006 7:51 am
by mdtauseefhussain
I tried with that Macro ,but just that Macro name is coming not the time satmp

Posted: Wed Jul 12, 2006 7:59 am
by DSguru2B
Opps, sorry, its with a small 's' in Timestamp.
try
OrderInvoice#DSJobStartTimestamp#.txt

Posted: Wed Jul 12, 2006 8:11 am
by mdtauseefhussain
HI!

iam able to create the file with the required file name but iam not able to open it

Posted: Wed Jul 12, 2006 8:19 am
by chulett
You might want to explain that a wee bit more. :?

Posted: Wed Jul 12, 2006 8:23 am
by DSguru2B
Offcourse you wont be able to open it. The timestamp will have a space in between and unix doesnt like that.
Use this

Code: Select all

OrderInvoice_#DSJobStartDate#_#DSJobStartTime#.txt

Posted: Wed Jul 12, 2006 8:24 am
by mdtauseefhussain
When i try to open the file iam getting this error "Encountered one error during transfer"

Posted: Thu Jul 13, 2006 2:12 am
by kumar_j
mdtauseefhussain wrote:When i try to open the file iam getting this error "Encountered one error during transfer"

Same error for me too'
what can be the reason for this

Posted: Thu Jul 13, 2006 3:35 am
by opdas
It may be because of the timestamp format eg "14:44:36" as unix has problem creating/reading file having ":" in the name

Posted: Thu Jul 13, 2006 6:26 am
by DSguru2B
opdas wrote:It may be because of the timestamp format eg "14:44:36" as unix has problem creating/reading file having ":" in the name
Says who.
The problem is not with the charcter ":" but instead a space.
The macro "DSJobStartTimestamp" creates a date part and a time part with a space between the date and time part. That is the culprit. Thats why i gave an alternative solution without any space in between.

Posted: Thu Jul 13, 2006 7:06 am
by opdas
DSguru2B wrote: Thats why i gave an alternative solution without any space in between.
The alternative solution without space also throws the same error

Posted: Thu Jul 13, 2006 7:20 am
by DSguru2B
Are you trying to open the file via seq. file stage?
If yes then it wont open it because you have a macro in the name. YOu need to go at the unix level and do a cat of the file.
And also, just for your own satisfaction, at the unix level type
touch 22:22 and see that it does get created.

Posted: Thu Jul 13, 2006 7:32 am
by chulett
:!: There is no problem with either spaces or colons in UNIX pathnames. And using the DSJobStartTimestamp macro in a sequential filename works fine as I just built a quick test job to verify that fact for myself. It will also 'open in the sequential file stage' (aka View Data) just fine as well with the macro in the name.

So, bottom line, something else is wrong. Something in your file or in what you are doing or with your version of DataStage... who knows, but it ain't the macro per se.

:idea: Post some details for us so we no longer need to guess. What operating system? How exactly are you 'opening' the file? Paste the entire error here, don't hand type it, don't paraphrase it. Let's see what happens next.

ps. My test was done using 7.5.1A on H-PUX. Mr 'me too' Kumar_j - what version of DataStage are you running? :?

Posted: Thu Jul 13, 2006 7:43 am
by DSguru2B
Even i built a test job yesterday with DSJobStartTimestamp, but i never hit view data. I went at the unix level and did a cat.
It wasnt reading it due to the space between the Date and Time.
I just ran the job again and hit view data, and yes you are right, it is able to view data.
But i would still advise to use DSJobStartDate and DSJobStartTime seperately to avoid getting that pesky space in between. Unix file names with spaces, not good.