on 10-28-2010 2:53 PM
Hi Gurus,
I have q requirement to get a certain value from a single source field
/IN/SB/ABC123/ --> requirement is to get the value between /IN/SB/ and the last / e.g. ABC123
the problem is this value is not fixed to 6characters only, can be any number of characters,
so if i use substring here I will encounter out of bounds exception
Can i do this using graphical mapping only?
/IN/SB/ and the last / will always be constant (present in the field)
if initial start string is fixed, you can use below in the UDF:
return inputStr.substring(7, inputStr.lastIndexOf("/"));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
solved with UDF having variable begin and end index based on field length of input field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is possible using standard graphical functions only.
You have to use the "replaceString" function twice.
Check the below mapping:
SourceField -
>
Constant [/IN/SB/] -
> replaceString -
>
Constant [] -
> Constant [/] -
> replaceString -
> Target
Constant [] -
>
-Supriya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
followup question:
if the UDF execution type is not Single Values, what do i need to add to the code?
Please refer to above
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the code:
String value = "";
AbstractTrace trace = container.getTrace();
StringTokenizer tempStringTokenizer = new StringTokenizer(input[0], "\n");
while (tempStringTokenizer.hasMoreTokens())
{
value = tempStringTokenizer.nextToken();
trace.addInfo (" TRACE ADDED" );
result.addValue(value);
}
//take udf as queue and mention one input parameter - name as 'input'
//give the source field as input to this udf
//after this udf use splitByValue node function...
You can use StringTokenizer to achieve this (UDF).
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use this UDF:
String delimiter ="/" ;
String[] temp = var1[0].split(delimiter);
result.addValue(temp[2]);
Note: This UDF will fetch the value after 3 "/" (slash delimiter).
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using startsWith is OK. But in place of substring write a UDF.
Edit : On second thoughts why not do the whole thing in a simple UDF. Java understands the method "startsWith"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
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.