cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming a file after the file is completely written

former_member223432
Participant
0 Kudos

Hi Experts,

I am working on File interface, where i am writing a huge data into the file at the target side...Since the file is processed by another oracle application, my client is asking me to rename the file after it is completely written.

the file is first written using another name and is renamed when it is complete..how can i acheive this?

Please adivse.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achieve it through standard file adapter. Here is the text from help.sap.com-

  • Under Write Mode, specify whether the target file is to be written directly in the specified directory.

If an additional step is to be added using a temporary file, choose Use Temporary File.

  • You can specify a naming schema for the temporary file under Temporary File Name Schema.

This schema is used to determine the prefix and extension of the temporary file; to ensure a unique file name, the message ID is also added to the name during processing.

The schema xitemp.tmp, for example, results in the file name xitemp<messageID>.tmp.

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

-Amol

Answers (3)

Answers (3)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Smith,

          there is a feature in receiver file adapter/communication channel  called Run Operating System command After Message Processing. Here you try typing the command

ren %F targetfilename    ----------------------WINDOWS OS

mv -f %F targetfilename    ----------------------LINUX/UNIX OS

Regards

Anupam

Hi Grzegorz,

      Could you state any reason for OS command to fail? This is a basic OS command and I can see no reason why it should fail.

The only reason I can suggest of its failure is that, OS is down, in that case PI won't be able to process the mesage as well.

so if the scenario works for once with OS command feature atleast once for the first time, be sure that it will work everytime. I agree to your point that I cannot find reason of failure from SXMB_MONI . But from communication channel logs you can find out if OS command was executed successfully or not.

A lot scenarios in my project is working with OS command line feature and its running successfully for last 6 years.

Regards

Anupam

Message was edited by: Anupam Ghosh

former_member184681
Active Contributor
0 Kudos

Hi Anupam,

I wouldn't recommend that - if OS command execution fails for some reason, no error would be shown in PI and the message would be visible as successful. Using the standard "Use Temporary File" Write Mode of the receiver channel would be a much safer option.

Regards,
Greg

Shabarish_Nair
Active Contributor
0 Kudos

Agree with Grzegorz ... Always stick to the standards

Shabarish_Nair
Active Contributor
0 Kudos

use the temporary file name option in the File adapter. The adapter will use that temporary file name and once completely processed rename it to actual file name.

former_member184681
Active Contributor
0 Kudos

Hi,

There is a standard option in receiver file CC that matches your requirement perfectly: Write Mode. Set it to "Use Temporary File" and provide some Temporary File Name Scheme, that will be used by PI to create the temporary file. Once the content is fully written, PI will automatically rename the file to the name provided in the "ordinary" File Name Scheme on the main tab.

Hope this helps,
Greg