Scenario
We want to create a target flat file name with the current system date.
Solution 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
- 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:
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.
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:
Output filename=FF_Example$$timestamp.out
FF_Example.txt is the target flat file name as defined in the target definition.
I tried above command. Its not working. Could you please explain in detail
solution 2 worked perfectly for me, thanks