Most of the time when we process flat files in Informatica PowerCenter, we do some kind of file pre or post processing, such as unzip the source file, create a custom header or footer for the target file etc. Such processing is normally done using Unix or Windows scripts, which is called using pre or post session script. Now Informatica PowerCenter has provided Source, Target Commands to make such processing easy than before.
File Command PropertyUsing Source or Target Command property, either a Unix or a Windows command can be used to generate flat file source data input rows or file list or a session. Command writes data into stdout and PowerCenter interprets this as a file list or source data. We can use service process variables like $PMSourceFileDir in the command.
Use Cases for File Command Property
Use Case 1 : Read a Compressed Source File.
Before the file is read, the file need to be unzipped. We do not need any other pres session script to achieve this. This can be done easy with the below session setting.
This command configuration generates rows to stdout and the Flat file reader reads directly from stdout, hence removes need for staging data.
Use Case 2 : Generating a File List.
For reading multiple file sources with same structure, we use indirect file method. Indirect file reading is made easy using File Command Property in the session configuration as shown below.
Command writes list of file names to stdout and PowerCenter interprets this as a file list.
Use Case 3 : Zip the Target File.
We can zip the target file using a post session script. but this can be done with out a post session script as shown in below session configuration.
Use Case 4 : Custom Flat File Column Headings.
You can get the column heading for a flat file using the session configuration as below. This session setting will give a file with header record 'Cust ID,Name, Street #,City,State,ZIP'
Use Case 5 : Custom Flat File Footer.
You can get the footer for a flat file using the session configuration as given in below image. This configuration will give you a file with ***** End Of The Report ***** as the last row of the file.