Skip to Content

Changing the name of a file in CPI

Hi,

I have a requirement to change the name of the file inside CPI(Cloud Platform Integration).

I am receiving a file from an external SFTP folder and need to change the name of the file inside CPI. For example, if the name of the file that I receive from the external SFTP connection is Test123, I need to change the name of the file to Test-123 inside CPI.

I tried using Camel file name and groovy script but was not able to do the same. If anyone has an example code of doing this through groovy script, it would be very helpful.

Thanks,

Sushanth

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Jun 28 at 06:42 AM

    Hi Sushanth Hulkod,

    Could you please check below blog for more details.

    https://blogs.sap.com/2016/07/10/sap-hcp-is-sap-hci-dynamic-configuration-for-sftp-adapter/

    hope this helps !

    thank and regards,

    Praveen T

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 29 at 07:41 AM

    Hi

    In content modifier read incoming filename .

    Name--FileName value--${file:name.noext}

    In groovy script change filename

    import com.sap.gateway.ip.core.customdev.util.Message;

    import java.util.HashMap;

    def Message processData(Message message) {

    String Name = message.getProperty('FileName');

    String a = "X" + Name; <modify file name as per your requirement>

    message.setProperty("FileName1",a);

    return message; }

    In Receiver adapter put filename as ${property.FileName1}.csv.

    Thanks

    Harsha

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 28 at 01:51 PM

    Hi,

    Thanks for your reply.

    I will not be able to use the technique mentioned in the blog:

    https://blogs.sap.com/2016/07/10/sap-hcp-is-sap-hci-dynamic-configuration-for-sftp-adapter/

    In my case, I will have to split the incoming file name and then use the substring function. If you have an example of a CPI artifact using groovy script that can do the above function, it would be very helpful.

    Thanks,

    Sushanth

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.