cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in scenario : Append/Replace String in the polled file in PI

Former Member
0 Kudos

Hi All,

       I have scenario File to Web services.Where in via file channel we are polling files and then transfer it to webservices post mapping.

Issue : We have free text in the XML file. And The same needs to replaced by a URL.

E.g.: If in the text value is : /Kunal/PI  we have to replace the same with : http://www.sap.com/Kunal/PI

And post that we have to do mapping.

Need any java class code to do the same which search the value :  /Kunal/PI in the file and replace all by : http://www.sap.com/Kunal/PI

as I am not that proficient in Java : SAP PI Version : PI 7.1.

Or is there is any other way the same can be done.

As its a free text so the values are coming as paragraph/sentence so we cant use concatenate in graphical mapping as we are receiving all the free text in a single field. So we have to search for the whole free text and do the replace function as mentioned above. And post that will call mapping.

Requesting all Gurus for help in the same.

Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

    The issue is fixed. We used a java module to append the missing string in the text. We cant use replace string as the free text has some HTML tags which replace string is unable to parse. Thanks all for the help/direction.

Former Member
0 Kudos

The issue here is we don't have particular field carrying the text. The field is carrying a paragraph. So we have search the value in the string and then replace all. So concat wont work as we don't have the field tag. So we have to use some Java class before the mapping.

e.g. :

<Field> This is a file sent from business for billing purpose. We have take this image from the below location. Source : \kunal\pi. Please confirm</Field>

So part highlighted needs to replaced with http://www.sap.com/kunal/pi.


Muniyappan
Active Contributor
0 Kudos

Hi,

So concat wont work as we don't have the field tag

i did not mention concat. you have to use replaceString function.

can you please share us the input and output xml?

it can help us to get you more..

Regards,

Muniyappan.

Former Member
0 Kudos

Hi Kunal,

i agree with Muniyappan.

you can use replaceString function , if you requirement is something different then pls explain again

Cheers

Hidayat

abhradeepbasu
Participant
0 Kudos

Hi Kunal,

Write UDF as below:

Take the field as your input paramater --> String a.

Logic:

String result = "";

return result = a.replaceAll("/kunal/pi","http://www.sap.com/kunal/pi");

/AB

Muniyappan
Active Contributor
0 Kudos

Hi,

Issue : We have free text in the XML file.

i think you are getting xml file in which you are getting free text. still you can use graphical function.

use text function replaceString.

check below screen.

please let me know if i did not get your question.

Regards,

Muniyappan.