cancel
Showing results for 
Search instead for 
Did you mean: 

Removing space in the File name

former_member188885
Active Participant
0 Kudos

Hi All,

aI am generating file names dynamically using variable substitution in PI. So the file name gets created as Shop (G1). But we have requirement to remove the spaces from the file name and name the file as ShopG1. This comes in from the plant name field. So how can this be handled?

Regards,

Lavanya Ravi

Accepted Solutions (1)

Accepted Solutions (1)

former_member188885
Active Participant
0 Kudos

I tried using replace string functionality and was successful in replacing the spaces in File name. But the problem is that the File name field is also appearing inside the file. I dont want the file name to be populated inside the file. Please help.

Regards,

Lavanya Ravi

former_member184720
Active Contributor
0 Kudos

As i mentioned, it can be easily handled with dynamic configuration UDF.

Just pass your input field -> replace string -> UDF ->

String filename = new String("");

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");

filename = var1;

conf1.put(key1,filename);

return filename;



former_member188885
Active Participant
0 Kudos

Okay.. have done this. But one issue is the File name is getting generated in the file as well. I dont want it inside te file. How can it be done?

former_member184720
Active Contributor
0 Kudos

If you are going with dynamic configuration(UDF) then don't map anything for that field.

Whatever the field you were using earlier for the variable substitution, either delete that field from the structure/ don't map.

former_member188885
Active Participant
0 Kudos

I am not getting it. I am using Plant name field for dynamic file name. But this field is also mapped to Plant name one to one. Actually the same DT is used for sender and receiver side. I am not sure how to go about

former_member184720
Active Contributor
0 Kudos

Do you need to send this plant name information to your target system?

If so i don't see any issue. Just do a direct mapping and leave it.

If you don't need to send any value, then remove the mapping for that field(don't map anything).

if you don't want the tags/empty line(in case of FCC), create new DT,MT,SI without this plant name field.

former_member188885
Active Participant
0 Kudos

I need to send the Plant name and i have mapped it one to one.

For File Name, i have mapped Plant Name -> Replace String -> UDF -> File Name.

Now because of this, the file name is also appearing in the file content.

The file should be in the below format:

Header Data Row

Record Data Row

But the file is now appearing as:

Header Data Row

Record Data Row

File Name

Now i dont want this File name to be a part of the file. I just want it to name my file dynamically.

former_member184720
Active Contributor
0 Kudos

You don't need to map it to a field file name.

Just map this to your message type.

Plant Name -> Replace String -> UDF -> MT

former_member188885
Active Participant
0 Kudos

Thanks a lot:)

It works now:)

Answers (2)

Answers (2)

iaki_vila
Active Contributor
0 Kudos

Hi Lavanya,

With variable substitution you would need to delete the spaces in ESR mapping. Another solution is to use OS command, after proccessing, to delete the spaces. Linux:  file rename - Remove whitespaces from filenames in Linux - Stack Overflow

Regards.

former_member184720
Active Contributor
0 Kudos

You might have to pass this value to target system as is but you want this change only for file name.

If so Instead of using the variable substitution go for dynamic configuration. Use replace all string function.

Dynamic file name and directory in Receiver File Adapter - summary of possibilities - Process Integr...