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