Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9212

Re: UDF for leading zero's in message mapping

$
0
0

Hi Drumi, Sanjay,

 

Here is the UDF which will suffice your requirement fully:

Parameters: input (material), fieldLength (18 in your case)

 

int len = Integer.parseInt(fieldLength);

 

int inputLength = input.length();

 

try {

Integer.parseInt(input);

// If it is an integer, add 0 (len - inputLength) times

for (int i=0; i< len-inputLength;i++)

    input = "0" + input;

return input;

} catch (NumberFormatException numForEx) {

// return as it is, if alphanumeric

return input;

}

 

This will take care of alpha-numeric case as well

 

Hope it helps!

Ambrish


Viewing all articles
Browse latest Browse all 9212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>