cancel
Showing results for 
Search instead for 
Did you mean: 

PI Replace Character in Variable Substitution

suwandi_cahyadi
Contributor
0 Kudos

Dear Experts,

I want to change a character in variable substitution.

Let's say that I have a variable substitution named var1.  The value of var1 will always have the slash '/' character.

This var1 will be used as part of the filename, such as  filename_%var1%.xml

Now the problem is that slash '/' character is illegal in filename. I want to replace the slash '/' character with dot '.' character. So if var1 has the value '2/2/2' it will become '2.2.2'.  

Is this possbile? Is there any workaround?

Changing the value in the message mapping is not an option as the receiver system wants to keep the format.

Thank you,

Suwandi C.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

Hi Suwandi - You can go with Dynamic file name option

Whatever the mapping you are doing for var1 pass it as an input for UDF..

String outfilename = new String("");
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
outfilename = "filename" + (var1mapping)+ ".xml";
conf1.put(key1,outfilename);
return variablePart;

Answers (2)

Answers (2)

former_member187587
Contributor
0 Kudos


Muniyappan
Active Contributor
0 Kudos

Hi,

As mentioned by hareesh you can go for dynamic Configuration.

under UDF you can replace '/' character with dot(.). so that receiver output will not be affected.

you can then avoid variable substition.

Regards,

Muniyappan.