on 03-12-2008 4:15 PM
Hi all,
How do I remove the leading zeros from the name? The data is coming from R/3, should I chage at the R/3 side or can I write a UDF. Do help me with the UDF.
<name>0003100667</name>
<pageNumber>1</pageNumber>
<batchSize>50</batchSize>
Thanks,
Srini
Srini,
Use Round Arithmetic function, if you expect the <name> element always contains only numbers.
If you expect something like
<name>000012A32 </name> , then u need UDF.
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Srinivas,
Is there any pattern to this or you have to find if its a zero and then cut it..can use substring function if its always 3 zeroes
Let me know if you need the code.
Regards
Ravi Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Davuluri,
Create a user defined funciton zerosuppress and take the cache as value and take one argument input. Then put the code below:
//write your code here
String output = input.replaceFirst("^0+","");
return output;
It will remove all your leading zeros.
then map: name --> udf --> output
Ex:
0003100667--> udf --> 3100667
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If yor R3 people are ready to make the change,, better to do it there. If not you can write a UDF. You have use a for loop and traverse the sting char by char and check for zero. By the time u encounter first non zero char, copy all the chars to new string and retun this new one.
VJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
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.