on 06-04-2015 12:02 PM
Dear All,
Can you please tell me how to get the last 04 digits of a source field to map to destination field.
Source Field length is dynamic.
I guess that UDF is needed for this.
Hi Fernando,
PFA sample udf, which first finds the length of the string, and extract the last four characters and pass to the output.
I just added some additional logic if the length is less than or equal to 4 then it will pass the input as it is to the output. Based on your requirement, you can keep or remove this part.
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public String last4digit(String in, Container container) throws StreamTransformationException{
if(in.length()>4)
{
in=in.substring(in.length()-4,in.length());
}
return in;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fernando,
You can develop a dynamic substring UDF like this one:
public String dynamicSubstring(String stringToSub, int begin, int end, Container container) throws StreamTransformationException{
return stringToSub.substring(begin,end);
}
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.