Page 1 of 1

Generate the .csv file with date or timestamp

Posted: Wed Jul 25, 2007 6:08 pm
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?

Posted: Wed Jul 25, 2007 6:29 pm
by ArndW
Do you want the timestamp to be part of the filename or part of the file contents?

Posted: Wed Jul 25, 2007 7:16 pm
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)

Posted: Wed Jul 25, 2007 7:46 pm
by JoshGeorge
Pass current date ('-' stripped off) as parameter and use that parameter in file name.

Posted: Wed Jul 25, 2007 7:56 pm
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.

Posted: Wed Jul 25, 2007 8:56 pm
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?

Posted: Wed Jul 25, 2007 8:57 pm
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 ?

Posted: Wed Jul 25, 2007 9:02 pm
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

Posted: Wed Jul 25, 2007 9:24 pm
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.

Re: Generate the .csv file with date or timestamp

Posted: Wed Jul 25, 2007 9:49 pm
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.

Re: Generate the .csv file with date or timestamp

Posted: Wed Jul 25, 2007 11:53 pm
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

Posted: Thu Jul 26, 2007 4:27 am
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.

Posted: Thu Jul 26, 2007 6:26 am
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!!

Posted: Thu Jul 26, 2007 7:58 am
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.

Posted: Thu Jul 26, 2007 4:31 pm
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