on 04-12-2010 4:07 PM
Hi,
How to delete leading zeros for material like 0000000128736 if so I am expecting 128736 only.
We need to consider if I get material number is like RPG2389 .
Thanks,
Vinay.
Hi,
If you will be getting alphanumeric codes, it would be best to use a UDF with a regex-expression.
UDF Type:
ContextType
imports:
java.util.regex; (if you are using PI 7.1 you must remove the semicolon)
arguments:
input1
Here's the code (courtesy of Sun Developer Network):
Pattern p = Pattern.compile("[^a-zA-Z]");
Matcher m = p.matcher(input1[0]);
StringBuffer sb = new StringBuffer();
boolean output = m.find();
while(output) {
m.appendReplacement(sb, "");
output = m.find();
}
m.appendTail(sb);
result.addValue(input1[1]);
Now to solve the leading zeroes, just add formatNumber: 0 after the UDF and it will work.
Hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinay,
use formatNumber standard function after your Material Number field then just place "#".
Hope it helps!
Cheers,
R-jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Vinay,
Use the below code, hope it helps! Get one parameter as input
BigDecimal bd;
try
{
bd = new BigDecimal(input);
return bd.toString();
}
catch(Exception e)
{
return input;
}
Thanks!
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 |
---|---|
77 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
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.