on 04-26-2013 10:33 PM
Dear All,
I have a mapping where I am using an udf for substring in PI 7.3.
I am using below udf code for substring
-----------------
String variable1="";
if (variable1!=null)
output1 = variable1.substring(6, variable1.length());
return output1;
---------------
if the same udf is used for the other field it is not working...
-------------------
String output1="";
if (output!=null)
output1 = output.substring(12, output.length());
return output1;
---------------
Also I tried creating function libraries also but no luck..
could any one suggest me...
Thanks and Regards,
Naveen.
Hi naveen,
You mean you need a generic udf to use for two of the fields you have mentioned. Is tat your requirement? In tat case pass the numbers 6 and 12 as constants and use the below generic udf.
public String findSubstring(String input, int Count, Container container) throws StreamTransformationException
{
String output="";
if(input!= null)
output = input.substring(count,input.length());
else
output="";
return output;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You may want to refer to these links:
http://stackoverflow.com/questions/2601978/how-to-check-if-my-string-is-equal-to-null
http://stackoverflow.com/questions/767372/java-string-equals-versus
http://stackoverflow.com/questions/8484668/java-does-not-equal-not-working
Also if the input say inp1 is String, try as:
if (!inp1.equals("null"))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is pretty simple requirement. Please share your code.
@Anupam: I think it's typo error. You check not null twice in the line 5.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Naveen,
Made little changes to your code. Please try the code given below
public static String returnStr(String output)
{
String output1="";
int l;
if (output!=null && !output.equals("") )
{
l=output.length();
if(l>=12)
{
output1 = output.substring(12,l);
}
}
return output1;
}
Regards
Anupam
Message was edited by: Anupam Ghosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Naveen,
Please check the first UDF, here variable1 is an argument string, please try to change the first code line: String variable1=""; to String output1="";
-----------------
String output1="";
if (variable1!=null)
output1 = variable1.substring(6, variable1.length());
return output1;
-----------------
Best Regards,
Luis.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.
Can you provide the values for that?
I guees the problem is with the length is less 12.
Regards
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.