on 09-22-2011 3:44 PM
Hi,
I have a requirement where I need to extract last 4 digit of an account number and pass the value to target field.
I dont want to use UDF. Is this possible without UDF?
We can extract the first 4 digit of the number using substring function in message mapping.
Pointers on this will be much appreciated.
Thanks
Ray..
if the input string always has a fixed length , then you can use the standard substring function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
look into - http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm
substring
Returns a substring O for a string I. Use the dialog for the function properties to specify the position of the substring.
Example: substring(u201CHellou201D, 0,1) = u201CHu201D, means that the substring from Startindex 0 to Endindex 1 (not including position 1) is shown.
As above provide your start and end index for the input string.
Why dont use a simple UDF to achieve this. Just single line of code only...
Doing UDF is elegant way and even if your length input varies in business, you dont need to change the coding too.
Type: Argument Name: var1 Java Type: String
public String lastFourCharacters(String var1, Container container) throws StreamTransformationException{
return var1.substring(var1.length-4, var1.length);
}
Connect source field --> lastFourCharacters --> target Field
This will work for any dynamic input string from the source.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.