cancel
Showing results for 
Search instead for 
Did you mean: 

How can i add leading 0 in mapping

Former Member
0 Kudos

Friends,

Please let me know how can i add leading number Zero in mapping

For Example:

Source : 123

Target : 0123 (NEED TO GET).

ANY HELP ON THIS.

Thanks in advance,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You can use the function "FormatNum" to add leading zeros.

Thanks

Rajesh

former_member472138
Active Contributor
0 Kudos

Hi

As other threads mentioned used FormatNum and double click and put Zeros. Like if the lenght is 10 then put 10 zeros. Here one thing you should analyse is, if your input value has a string value it will fail in FormatNum becuase it expects only the numeric value.

So if you dont know whether your input has numeric or alphanumeric then go to UDF. So create a udf with name AddZeros and as Value with one argument as input.

Imports: java.*;

Then add this code:

int len=input.length();

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

{

input="0"+input;

}

return input;

Here I am assuming the total length is 10. If yours is 20 then put 20 instead of 10 in the second line of the code.

Rgds

Pothana

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can go ahead with the standard function " Formatnum", else you need to write a UDF to add a leading zero.

Thanks