cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the name of a file in CPI

0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member637863
Participant

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

Hi sushanth.hulkod3,

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

0 Kudos

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