cancel
Showing results for 
Search instead for 
Did you mean: 

add leading zero's function

Former Member
0 Kudos

Hey,

can anyone tell me what is the java function for add leading zero's in xi mapping.

TX

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Zevik,

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.

Regards,

---Satish

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

>> input---> formatNumber[0000000000]--


>output

it is function in Arthematic (format number). there i am giving 10 '0' s. if it is less than 10 digits it will automatically add zero's on left side.

if input is 12345 output will be 0000012345

Thanks.

Madhav

former_member581827
Participant
0 Kudos

Hi,

you can define certain number of digit so that it will take that length and if source lenth is less that the defined digit it will fill with zero's that is the function of " Format Num" standard function.

so you can use Format Num standard function.

Regards,

Chandra.

Former Member
0 Kudos

Hi,

you could use the standard Arithmetic function FormatNum.

Regards

Patrick

former_member200962
Active Contributor
0 Kudos

u need a UDF in message mapping...check this thread :

OR u can use the formatNumber function available in message mapping then no need of UDF:)

Regards,

Abhishek.

Edited by: abhishek salvi on Apr 27, 2009 8:22 PM