cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming a File to File without Mapping

Former Member
0 Kudos

Hi All,

I am having a scenario where there is a text file transfer without any conversion i.e. basically a file to file scenario with no mapping. The only requirement is to rename source file which has .csv extn to .dat. For instance if the sender file is XYZ.csv, the file at the receiver side should be XYZ.dat.

As there is no mapping, I cannot use Dynamic Configuration UDF in mapping. One other option is to write an adapter module which seems too bulky for this small requirement. So as of now I am looking at any option which I can use without having to create IR objects or do text ->XML -> text conversion.

I hope experts here can help in resolving the current problem and/or give some pointers

Best Regards,

Pratik

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Use an OS command for renaming.

Former Member
0 Kudos

Hi Stefan,

I tried to put an OS command as described below. Its a FTP scenario, in the audit log I see that File adapter has executed the following command but it doesn't rename the file.

When I tried the same command locally on Cygwin, it does convert the file extension. I am not sure on what I am missing here.

OS Command in File Receiver Channel: mv %f `basename %f .csv`.dat

The receiver system is UNIX and am trying to rename file with extn .csv to .dat. As already mentioned as the name is dynamic I cannot use the normal File name schema to achieve this and have to take the file name from Adapter specific identifiers and hence use a OS command as mentioned by Stefan.

Best Regards,

Pratik

stefan_grube
Active Contributor
0 Kudos

> OS Command in File Receiver Channel: mv %f `basename %f .csv`.dat

I think you should use the full path address, the same as you used for the folder.

You can also use an adapter module, it is just a couple of lines:

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
                      throws ModuleException{
     try {
        Message msg = (Message) inputModuleData.getPrincipalData();
        Payload payload = msg.getDocument();
        String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File","FileName");

        // do something with the filename

        msg.setMessageProperty("http://sap.com/xi/XI/System/File","FileName", fileName);

        inputModuleData.setPrincipalData(msg);

    } catch (Exception e) {
        throw new ModuleException(e);
    }

    return inputModuleData;
 }

Answers (5)

Answers (5)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Pratik,

It is possible with Java mapping, you have to use objects in ESR. Please refer this thread , follow the steps mentioned in the thread.

Regards,

Raghu_Vamsee

Edited by: Raghu Vamsee on Jan 9, 2011 5:59 PM

Former Member
0 Kudos

Hi Pratik,

Since this is a simple file to file(file transfer) scenario with no mapping involved, i would recommend the following:

In your sender channel, give the source file name as XYZ.csv

and in your receiver channel , give the target file name as XYZ.dat

In this case, you do not need any IR objects.

This should work for you. Let us know once you test this.

Regards, Gaurav.

Former Member
0 Kudos

Hi All,

Thanks for the inputs but one important part which all of you except Stefan missed out (may be I did not explain it properly) is that the File name is dynamic. For instance, the format is something like xyz_<nnn>.csv where nnn can be any dynamic number. Whicever file matching this format is picked up at the sender side has to be transferred to receiver with changed extension i.e. xyz_<nnn>.dat.

So i cannot use file name schema mentioned in sender and receiver part. Hope this clarifies the current situation.

Best Regards,

Pratik

Former Member
0 Kudos

Hi Pratik,

Try this approach:

In your sender file adapter click on ASMA properties file name, then in your receiver file adapter in the File Name give the value as *.dat.

My requirement was a little different when I tried this approach. Hope this will work for you as well.

Regards,

Rahul Grover

sunil_singh13
Active Contributor
0 Kudos

Hi Pratik,

As suggested you can just rename the file in the Receiver adapter.

If that is not working for you then you can use "Variable Substitution" option available in the Receiver file adapter. But so as to use this option you have to use an additional field that will carry the name of the file.

Please refere to help.sap for more info on this.

Thanks,

Sunil Singh

former_member183908
Active Contributor
0 Kudos

Hi Pratik,

-->If you dont have the Mapping then you can skip IR part as suggested by William Li in blog and in the receiver communication channel provide the name of the file name and format which you are expecting.

-->Even With out mapping you can go for ASMA option to fetch the same file name as source for your receiver,but i think that is not your requirement.

Thanks

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You want to change the file type or extension. Since there is no structure conversion, we dont need IR object. Do only ID configuration and change the file extension in the receiver file communication channel. I think it should work.

        • use the below link for creating ID objects and use the receiver communication channel to change the extn.

/people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository