cancel
Showing results for 
Search instead for 
Did you mean: 

Leading Zeros Padding in PI

Former Member
0 Kudos

I have a incoming field account number which is 10 integers into PI . I need to add leading zeros to it if the length is less than 10 integers.

Can you please let me know which function to use? I tried format fucntion but obviously that does not work.

Thanks,

Hari

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

FormatNumber should work.

Can you explain what have you done?

Former Member
0 Kudos

This is what i have done with FORMATNUM function

HKONT ---> FORMATNUM [0000000000] -


> HKONT

The problem here is that when mapping when i do display queue the incoming HKONT looks like this [1234567 ] it has space at the end.

Thanks,

Hari

markangelo_dihiansan
Active Contributor

Hello,

You just need to add the text function trim so that the leading and trailing spaces are eliminated. The adjusted mapping will look like this:


HKONT ---> trim ---> FORMATNUM 0000000000 -------> HKONT

Hope this helps,

Mark

Answers (1)

Answers (1)

former_member854360
Active Contributor
0 Kudos

Hi Hari

you can use a simple UDF.

String output;

if(input.length()<10)

{

output="0";

for(int i=1;i<10-input.length();i++)

{

output=output+"0";

}

output=output+input;

}

return output;

Or you can use FormatNum standard function.

here in format pattern you need to put ten zeros.

Edited by: SAP_PI_D on Jun 27, 2011 11:22 PM