Renaming a file...

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
Arun8006
Participant
Posts: 2
Joined: Fri Apr 24, 2009 4:22 am
Location: India

Renaming a file...

Post by Arun8006 »

Hi All,

I have a parallel job, which picks a flat file from a specified folder. I want the job to terminate if the file is missing with a required information. And also to rename the file.
Can this be done, if yes, can any one please suggest how to accomplish this.

Thank you
Arun
Arun Gautam
Business Objects, Cognos and Datastage
India
nikhilanshuman
Participant
Posts: 58
Joined: Tue Nov 17, 2009 3:38 am

Post by nikhilanshuman »

Hi Arun,

In sequential file stage there is a property "Missing File Mode".You have to set this property value to "ERROR".

After setting this property,if a specified file does not exist,the job will abort.

To rename a file,you may try following:

a) In Execute command activity of a sequence,you can run the command

mv old_name new_name

b) In the parallel job you can use a before job routine.Inside the routines the command mv old_name new_name can be executed using DSExecute().
Nikhil
Arun8006
Participant
Posts: 2
Joined: Fri Apr 24, 2009 4:22 am
Location: India

Post by Arun8006 »

Thank you for the reply Nikhil.

I think I did not convey my problem correctly, let me rephrase the problem statement.

I have a flat file, lets it has about 400 columns (comma delimited) and a million rows. And out of those 400 columns about 20 columns are mandatory. If any of these 20 columns have a NULL or does not contain a value, the job should be terminated and the flat file should be renamed. If the flat file name was FF1.txt then it should be renamed to FF1_Err.txt.

Thanks
Arun
Arun Gautam
Business Objects, Cognos and Datastage
India
nikhilanshuman
Participant
Posts: 58
Joined: Tue Nov 17, 2009 3:38 am

Post by nikhilanshuman »

Arun,
This can be used using two transformer stages.

From the first transformer stage take two output link say Err_out and Clean_Out

For the link Err_Out,put the conditions in the constraints for checking null values. e.g. ISNULL(Link_Name.Column_Name) or ISNULL(Link_Name.Column_Name)

The output Err_Out should go to the second transformer.In the second transformer there is property "Abort After rows" in constraints.Set its value to 1.

Flow :

Seq_File_Stage--->Transformer1-----Err_Out--->Transformer2

Here,when any column is null the record will go to the second transformer.The second transformer will abort the job.

=============
Renaming the file :

The parallel job will be called from a sequence.In the sequence you can set the flow to "Execute Command activity"(Using Trigger of job activity).
In the execute command activity the file can be renamed by using

mv old_name new_name

=================

If the file name is dynamic,you can capture the file name using Field function in user variable activity.

Example :

Field("FF1.txt ", "." ,1):"_Err.txt"

The above function will pick FF1 from FF1.txt .Then it will append "_Err.txt" to FF1.Hence the name would be "FF1_Err.txt".This can be assigned to a variable and user variable activity and passed to Execute command activity.
Nikhil
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In my mind, the biggest question re: failing the job is - do you want to fail it when the first issue is found or after all issues are found and logged? Also, the rename can be done "after job" by checking the INTERIMSTATUS to see if the job is on its way to Abortsville.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply