Generate the .csv file with date or timestamp

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Generate the .csv file with date or timestamp

Post by shilpa79 »

I am extracting data from EDI format file and capturing some records
and generating a .CSV file. The business wants to generate the file each and everytime with date or timestamp ans send as an attachment with that date.

Is this possible to send as an attachment with the date?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Do you want the timestamp to be part of the filename or part of the file contents?
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Post by shilpa79 »

ArndW wrote:Do you want the timestamp to be part of the filename or part of the file contents? ...
Yes , like for example 20070725_test1.csv(only date)
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Pass current date ('-' stripped off) as parameter and use that parameter in file name.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'll either need to pass in the date to use as a job parameter as noted, or rename the file after-job to include the system date.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Zhang Bo
Participant
Posts: 15
Joined: Sun Jul 15, 2007 9:22 pm

Post by Zhang Bo »

use a job sequence with a job activity to invoke the parallel job,in the job activity,pass the value Convert('-','', DSJobStartDate) (if your data format is yyyy-mm-dd)to the job parameter,then use the job parameter as part of the file name,anyone has a better idea?
MaDFroG
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Post by shilpa79 »

JoshGeorge wrote:Pass current date ('-' stripped off) as parameter and use that parameter in file name.
ate

Just go and add in the job parameters :

param1= currentdate('-' stripped off) and call param while creating the file and send as an attachment in email.

Is that right ?
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Post by shilpa79 »

Zhang Bo wrote:use a job sequence with a job activity to invoke the parallel job,in the job activity,pass the value Convert('-','', DSJobStartDate) (if your data format is yyyy-mm-dd)to the job parameter,then use the job parameter as part of the file name,anyone has a better idea?
yes, I am calling the parallel Job in sequence but I am not using Job activity stage but execute command stage .
So how I need to pass form the execute commnad stage
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I would use a User Variables Activity stage to create a variable with the full command line for the dsjob command, including using the aforementioned function to generate the date as a parameter to that job. Then use the variable in the subsequent command activity stage.
kausikMitra
Participant
Posts: 5
Joined: Fri Feb 24, 2006 1:05 am
Location: Melbourne

Re: Generate the .csv file with date or timestamp

Post by kausikMitra »

you can use unix command to rename the file ( u can use this `date +"%Y%m%d%H%M%S"`), use the command in "after job subroutine " in the job properties.
Regrads
Kausik Mitra
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Re: Generate the .csv file with date or timestamp

Post by shilpa79 »

kausikMitra wrote:you can use unix command to rename the file ( u can use this `date +"%Y%m%d%H%M%S"`), use the command in "after job subroutine " in the job properties.
Can I send file as an attachment with the date from the email notification activity stage
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Before calling the job in the sequence add a User Variable activity stage and create a variable for your file name.

Code: Select all

For variable FileName

Change(DSJobStartDate,'-',''):'_Test1.csv
And pass this in the next Execute Command state where you call Dsjob command

Dsjob -run NORMAL -param Filename=UVA.FileName ...

Now to send this file as an attachment in your email, specify this in After Successful completion of job option for DsSendMail in jobparameter window of your job and pass the Path+FileName parameter for attachment option.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
prashkvrk
Participant
Posts: 15
Joined: Tue Nov 21, 2006 1:17 am
Location: Bangalore,India

Post by prashkvrk »

Try this in the sequence:
1.In the user variable activity you must have given the job parameters definitions right?
add one more varialbe such as inftctgtfiledate(interface target file date) and the give the value as "DSJobStartDate[1,4] : DSJobStartDate[6,2] : DSJobStartDate[9,2]"
eg:if you have the date as 2007-07-26, the above macro takes the first four characters(2007), the tow characters starting frm 6th position(07), the two characters starting from 9th postion(26) is obtained and appended to your target file.

2. in runjobtfn under parameterlistparm pass the value

"inftctgtfiledate=": JobParametersDefinition.inftctgtfiledate

Hope this should work!!
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

2. in runjobtfn under parameterlistparm pass the value

"inftctgtfiledate=": JobParametersDefinition.inftctgtfiledate
What's runjobtfn? Seeing the "parameterlistparm" - I think this is a custom routine being used at your site?

JoshGeorge's post is clear enough i believe - to get things working.
------------------
Aneesh
shilpa79
Participant
Posts: 131
Joined: Thu Jan 20, 2005 5:59 pm
Location: Virginia

Post by shilpa79 »

[quote="prashkvrk"]Try this in the sequence:
1.In the user variable activity you must have given the job parameters definitions right?
add one more varialbe such as inftctgtfiledate(interface target file date) and the give the value as "DSJobStartDate[1,4] : DSJobStartDate[6,2] : DSJobStartDate[9,2]"
eg:if you have the date as 2007-07-26, the above macro takes the first four characters(2007), the tow characters starting frm 6th position(07), the two characters starting from 9th postion(26) is obtained and appended to your target file.

yes, I tried in the same and one thing is I was getting the whole path in the content of the .csv file and

If I want to get any column from the Inputfile and append in the file name then also I can still use this uv stage right
Post Reply