cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with mapping( UDF)

0 Kudos

Hi,

I had a mapping requirement where i need to transfer data with double quotes

suppose data is

sap-labs

i need to send as "sap-labs".

The main problem is when ever there is '-'(it can be any where in the string) I need to modify as above, otherwise data can be sent directly.

I know how to do this requirement using Standard Functions.But, I am trying to use UDF so try to help me out with the code.

and also what i have to import for this UDF. and why i have to import them?

Thanks in advance,

Siva.

Accepted Solutions (0)

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Siva Bonthala,

Note: - quote ("), apostrophe ('), ampersand (&), less than (<), greater than (>) are special characters in XML. They should not be present in data. [Link1|http://www.w3.org/TR/REC-xml/] [Link2|]

When you writing Java code to insert these special characters, you should use escape scequence characters.

Test it for your self, in graphical mapping, use 'concat' function and type Delimiter String as ". Then check output XML, it will contain &quot ;.

If you have to replace sap-labs with "sap-labs" for many element, I recomand you to use Java Mapping instead of UDF's for every field.

Regards,

Raghu_Vamsee

Former Member
0 Kudos

Hi,

Try this.

String rslt = "";

if( var1.contains("-")) // returns true if var1 contains "-" else returns false

{

rslt = "\"" + var1 + "\"";

}

else

{

rslt = var1;

}

return rslt;

Regards,

Aravind

RKothari
Contributor
0 Kudos

Hello,

You can use indexOf(). If the string is not present, it will return -1.

Example:-

String str1 = "sap-labs";

String str2 = "-";

int result_index = str1.indexOf(str2);

if (result_index != -1)

{

result.addValue(str1);

}

-Rahul