on 02-16-2012 2:41 AM
Hi experts,
Can someone please help me in converting the Alphanumeric to a number? i just have to delete the alphabets in the string and retain the numbers,
kindly help me.
Hello,
A simple find/replace using Regex would handle your requirement
Source -> removeContext -> UDF -> Target
UDF code is as follows:
Arguments: input
Execution Type: Context Type
for(int a=0;a<input.length;a++){
result.addValue(input[a].replaceAll("(\\D)",""));
}
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
When i run this UDF,i am gettin an error..can you please help me with this..
Function getNumeric, Line 1:
cannot find symbol
symbol : variable length
location: class java.lang.String
for(int a=0;a<input.length;a++){
^
Function getNumeric, Line 2:
array required, but java.lang.String found
result.addValue(input[a].replaceAll("(
D)",""));
^
Function getNumeric, Line 2:
cannot find symbol
symbol : variable result
location: class com.sap.xi.tf._MM_Test
result.addValue(input[a].replaceAll("(
D)",""));
Hi mark,
Thanks for your quick reply.
when i change execution type to "All values of context" i am getting another Resultlist also..but in code we are not passing the values to resultList right..
I have provide the following details.
Execution type: All values of context
category: user defined
Argument: Input--string
Result result ResultList
for(int a=0;a<input.length;a++)
{
result.addValue(input[a].replaceAll("(
D)",""));
}
Hello,
when i change execution type to "All values of context" i am getting another Resultlist also..but in code we are not passing the values to resultList right..
The ResultList is normal. The return type is void, so you have to use the ResultList via result.
Argument: Input--string
Result result ResultList
Java is case-sensitive, so if you will use Input, better change the code to
for(int a=0;a<Input.length;a++)
{
result.addValue(Input[a].replaceAll("(D)",""));
}
Hope this helps,
Mark
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.