Skip to Content
avatar image
Former Member

Leading Zeros Padding in PI

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 27, 2011 at 09:27 PM

    FormatNumber should work.

    Can you explain what have you done?

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Jun 27, 2011 at 09:20 PM

    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

    Add comment
    10|10000 characters needed characters exceeded