We want to create a target flat file name with the current system date.
- The first method is renaming the target file name in the post session command as bellow:
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
- 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.
The following command will create the file in the format filename__dateYYYYMMDD.out on UNIX:
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.
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.
2. Create an assignment task before the session and enter the following expression in the assignment task:
3. Edit the session and enter the following file name:
FF_Example.txt is the target flat file name as defined in the target definition.