Hi Sanjay,
This is a working piece of code.
Just need to make sure that you have provided parameter names as below:
input (material), fieldLength (constant 18 in your case).
Execution type is Single Values
Use standard trim function after material before the UDF, to make sure that spaces before and after the input value are flushed out.
use constant as 18 for fieldLength parameter to the UDF.
Hope it works else revert back with the error you are getting.
Ambrish