on 01-17-2012 10:28 PM
Dear SAP PI Guru,
I am using a substring function to get the 3st last char of the string but the mapping fails. I can only have the first 3st if the input how can I handle this? do we have to write a UDF for this?please help
Thank in advance.
ombessa
Hi Ombessa,
Here is the UDF which matches your requirement. I think its not possible to get last three charcters using standard text functions available in graphical mapping.
public static String lastThreeChars(String s)
{
try
{
s=s.substring(s.length()-3);
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
For input "Hello" you get output "llo".
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can handle both in standard function or udf. But doing udf is simple in this case.
Create a UDF function with name like lastThreeCharacter and variable type String input
return input.substring(input.length()-3, input.length());
The above function return last three characters of the input value.
Use source field --> lastThreeCharacter --> Target field
Hope that helps. Very simple.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
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.