How to rename and run daily basis jobs?

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
pkll
Participant
Posts: 73
Joined: Thu Oct 25, 2012 9:45 pm

How to rename and run daily basis jobs?

Post by pkll »

Hi,

I have one file:201304040048.SDP101.00011.7190054(Today file)
tomorrow may be i will get same file like
201304050048.SDP101.00011.8040073 and dayafter tomorrow i will get like 201304060048.SDP101.00011.8140813....

In the above example 2013(Year),04(month),04(day),0048( time),SDP101.00011(Filename)7190054(No.of Records).

In the above example year,month,day,time and number of records will change daily.I don't want to change paramer file and aut
omatically it has to pick latest file.

In which basis i have to take file and run the same job daily?(means daily file name is changing.so,How can i take file)

Please suggest me how can i rename and run jobs daily?.....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A script or routine can be used to detect the current name of the file and then you can either update your values file or pass it as a parameter to the processing job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pkll
Participant
Posts: 73
Joined: Thu Oct 25, 2012 9:45 pm

Post by pkll »

I have not yet work on script and routines.Can any one help me how to write script or routines about this senario?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

I think you know the commands to check the files in directory or other unix commands by now.

Start writing them in a sequence. For a starter i would say you can use

ls -1 or ls -lt to list the files/files in order. If you are using ls -lt you need awk command to get just the file name.

Take the first file name using head -1. And you have the file name.

Now run dsjob command and use -param and assign the value of file name to file name parameter.

Once the job is complete move that file already processed to some other directory as archive.

and you are done. Check for syntax using man page in UNIX. You can run this in loop if you expect multiple file.

If you do not care which file is processed first, just you file pattern in the sequential file stage. Be sure to move the files to another folder once the job is done. So that its ready for next day.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Clarify something for us - is the 'filename' a standalone parameter to be passed to the job or is it part of a parameter set with a values file that needs to be updated?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pkll
Participant
Posts: 73
Joined: Thu Oct 25, 2012 9:45 pm

Post by pkll »

Hi Chulett,
Filename is a standalone parameter(in my example file is SDP101.00011)daily the filename will be change(means date or month and records also).

Code: Select all

Ex:today file is=201304040048.SDP101.00011.7190054
tomorrow file is like=201304050048.SDP101.00011.8040073
In the above example date has been changed(04 to 05) and record count is also incremented 7190054 to 8040073).
And latest data need to store one folder and remaing data(old data) need to move another folder).
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That makes it something that can be done rather easily in a Sequence job. An Execute Command stage can get the filename and the result can go to the Job Activity stage's filename parameter.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Neha_DS
Participant
Posts: 3
Joined: Tue Aug 14, 2012 5:03 am

Post by Neha_DS »

Or what can be done is move all the processed file into a separate folder, by using "Execute Command" activity in sequencer. By doing so, fo a given day, you would have a single file and can be processed without checking for date time etc.
Neha Jain
Post Reply