cancel
Showing results for 
Search instead for 
Did you mean: 

Help req with the UDF

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

For now I just need the numbers.

Thanks,

Raj

justin_santhanam
Active Contributor
0 Kudos

Srini,

Then go for Round function, it will do the need.

raj.

Former Member
0 Kudos

Thanks guys for the suggestions.

Answers (3)

Answers (3)

ravi_raman2
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

VijayKonam
Active Contributor
0 Kudos

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