on 01-24-2011 6:45 AM
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.
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 " ;.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.