Skip to main content

Data & Intelligence

Informatica: How to Set a Target Flat File Name with Timestamp

Scenario

We want to create a target flat file name with the current system date.

Solution 1

  1. The first method is renaming the target file name in the post session command as bellow:

Example:

The following command will rename the file in the format filename_MMDDYYYY.out in Windows:

move $PMTargetFileDir\filename $PMTargetFileDir\filename_%date:~4,2%%date:~7,2%%date:~10%.out

Informatica: How to Set a Target Flat File Name with Timestamp

  1. The second method is to use a command output type as follows:
  • In the Workflow Manager, edit the session task and go to the Mappings tab.
  • Select the flat file target.
  • Set the Output type as Command under Properties .
  • In the Command option, enter the shell command.

Example:

The following command will create the file in the format filename__dateYYYYMMDD.out   on UNIX:

Data Intelligence - The Future of Big Data
The Future of Big Data

With some guidance, you can craft a data platform that is right for your organization’s needs and gets the most return from your data capital.

Get the Guide

cat  – > /$PMTargetFileDir/filename_’date ‘ +%Y%m%d’.out

Using this option, the Integration Service will send the output data of the session to the command, and the command will generate a file with a dynamic file name that contains the target data.

 

Solution 2

To append a timestamp to the name of a flat file target using a PowerCenter workflow variable:

1. Create a workflow variable with datatype NSTRING.

Informatica: How to Set a Target Flat File Name with Timestamp

2. Create an assignment task before the session and enter the following expression in the assignment task:

Informatica: How to Set a Target Flat File Name with Timestamp

3. Edit the session and enter the following file name:

Output filename=FF_Example$$timestamp.out

FF_Example.txt is the target flat file name as defined in the target definition.

Informatica: How to Set a Target Flat File Name with Timestamp

 

Thoughts on “Informatica: How to Set a Target Flat File Name with Timestamp”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.