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

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

Similar Messages

  • Adding leading zeroes (PADDING in SQL Server)

    Hi to everyone,
    Is there a function to add leading zeros to int converted to varchar?
    I have 5, need to get varchar(5) = 00005..
    I hate to do like left('00000',5-len(Int))+cast(Int as varchar)
    I know in Oracle there is PAD, what about SQL Server?
    Thanks

    There is nothing like PAD in SQLServer 2008, but SQLServer 2012 has  FORMAT ([fieldname], '00000').
    For SQLServer 2008, I've found that something like this works...
     Right('00000'+ convert(varchar,[fieldname]),5)

  • Leading zeros in SAP Script

    hi,
      how can i put leading zeros (functionality of FM CONVERSION_EXIT_ALPHA_INPUT) in SAP Script??
    b'coz of not having leading zeros in PO number,i m facing problems in fetching the PO header text(text id = F01) using INCLUDE syntax.
    Message was edited by: kaushal malavia
    Message was edited by: kaushal malavia

    sreenivas,
       here goes my script coding..
    /:     DEFINE &W_EBELN& = &EKKO-EBELN&
    /:     PERFORM ZERO_PADDING_PO IN PROGRAM ZSXXSR103S
    /:     USING &EKKO-EBELN&
    /:     CHANGING &W_EBELN&
    /:     ENDPERFORM
    and here goes my routine coding.
    *&      Form  ZERO_PADDING_PO
    FORM ZERO_PADDING_PO TABLES TAB_IN STRUCTURE ITCSY
                          TAB_OUT STRUCTURE ITCSY.
      DATA : W_EBELN LIKE EKKO-EBELN.
      CLEAR W_EBELN.
      REFRESH TAB_OUT.
      PERFORM GET_VALUE TABLES TAB_IN USING 'W_EBELN' W_EBELN.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = W_EBELN
        IMPORTING
          OUTPUT = W_EBELN.
      CLEAR TAB_OUT.
      TAB_OUT-NAME  = 'W_EBELN'.
      TAB_OUT-VALUE = W_EBELN.
      APPEND TAB_OUT.
    ENDFORM.                               " GET_VALUE
    *&      Form  GET_VALUE
         -->I_TAB_IN
         -->I_NAME
         -->O_VALUE
    FORM GET_VALUE TABLES   I_TAB_IN STRUCTURE ITCSY
                   USING    I_NAME
                            O_VALUE .
      CLEAR O_VALUE.
      READ TABLE I_TAB_IN WITH KEY NAME = I_NAME.
      O_VALUE = I_TAB_IN-VALUE.
    ENDFORM.                               " GET_VALUE
    can u point out error in code ?? in debuging i can see the value of W_EBELN is geting leading zero padded but when it comes back to SAPSCRIPT it gets changed to original value of without leaing zeros.

  • Pad leading zeros in a string.Format function

    How could use the string.Format function and in the format text pad a leading zero? 
    Pseudo code is:
    string parm = “5”;
    string format = “Some number formatted as 3 dig: Format({0}, 000)”;
    string output = string.Format(format, parm);
    Where the output would look like this:
    “Some number formatted as 3 dig: 005”
    Thanks.

    Thanks everyone. Unfortuantly there's a constraint where the padding operation needs to be embedded in the format string. This entire operatin is being put together dynamically where the format strings are being pulled from a library of format strings stored
    in a database. at runtime we don't know how which format will be used and how many parameters will be passed in. we have logic to handle the unknown number of paramters as there is metadata which helps us with that.
    the need for leading zeros needs to be part of the overall format defined in the format string.  for example, a real format string stored in the database looks like this:
    "LINE_NO = '{0}',  AND GEO_LOCATION = 'T{1}, {2},  R{3}, {4}, , Sec. {5}'"
    and its output from the string.Function is:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 5'"
    the last parameter (param 5) had a value of 5.  In another case the output requirement might need to look like this:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 05'"
    note the "05" at the end...
    the logic of using the leading zero needs to be embedded in the overall format string text.
    Thank you.

  • Padding a julian date with leading zeros ?

    Hi,
    I have gernerated a julian date, which I am appending to another two digit number to create a five digit serial number.
    Is there a simple way to pad the first 99 days with leading zeros ( i.e. 001, 002....025...099) so that I maintain a five digit serial number ?
    I am using   Get Date In Time/Seconds > Number To Decimal String > Unbundle >Number to Decimal String.
    Thank you in advance for any advice,
    Alan

    Here's the simplest way to do it (with he 2 digit number), I believe:
    Message Edited by Matthew Kelton on 02-21-2008 12:43 AM
    Attachments:
    Julian1.png ‏3 KB
    Julian2.png ‏2 KB

  • Padding a value with leading zeros

    Hi
    I am trying to create a filename (String) using a sequence int. I need this int to be 6 digits, with leading zeros
    i.e. if my seqence number is 23 my filename (String) should be:
    FILE000023
    Obviously I can do this by creating my own method that iterates through the number, but I was wondering if there was a simple method to change an int to a String and pad it out with leading zeros.
    Thanks
    Neil.

    import java.text.*;
    public class DecimalFormatTesting {
         public static void main( String[] args ) {
              DecimalFormat format = new DecimalFormat("###.###");
              format.setMinimumIntegerDigits( 6 );
              String integ = format.format( 123 );
              System.out.println("str: " + integ);
         } // end of main()
    }hope this helps
    partha

  • Padding leading zeros to char field

    Hi Gurus,
    user enter number in the field which is char 10, and if they enter any value which is lesser than 10 then i have to pad leading zeros to cusno.
    i am using following logic but its displaying error saying unable interpret 'v'.
    any hep in this regard really appreciated.
    data : cusno type char10 value 'PADA'.
    Data : l type i.
    data : v type c value '0'.
    l = STRLEN( cusno ).
    while l < 10.
    concatenate v into cusno.
    endwhile.

        Add Leading Zeroes
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = cusno
            IMPORTING
              output = cusno.
    This will add leading zeroes to cusno if its length is less than 10.

  • Padding with leading zeroes

    Hi All,
    I am using XSLT mapping.I want to get the field in the receiver side with the leading zeros.Source field: XSD:decimal and length is 10.If input is 12345, i have to get 0000012345.
    Can anybody please solve the problem and guide me if u know .

    Hi,
    you can use format-number function in this case...
    <xsl:template match="/">
    <number>
    <xsl:value-of select="format-number('5465','0000000000')"/>
    </number>
    </xsl:template>
    in this function first parameter is value which u want to format and second parameter is the format(in your case lenghth of ur string)
    Regards,
    Abhijeet

  • Leading zeroes substring query in SQL Server

    Can Someone please help me in padding leading zeroes for the months in End date
    Example: actual data is like    6222007
    ,11301998 in end date column the following query works fine for 11301998 and converts it as 19981130 which was correct.
    But 6222007
    fails because month has no leading zero and it converts it as 0076222 which is wrong.
    How can i make it as 20070622 with the following code
    select (case when replace (ltrim(rtrim(ltrim([end date]))), '|', '') in ('99999999','00000000') then NULL 
        else substring ([END DATE],5,4)+SUBSTRING([END DATE],1,2)+SUBSTRING([END DATE],3,2) end) as ConvEnd_date
    from AdventureWorks.dbo.[AccountTable]

    Something like:
    declare @i int = 6222007
    select @i%10000 year_number, @i/1000000 month_number, (@i/10000)%100 day_number
    select DATEFROMPARTS(@i%10000,@i/1000000,(@i/10000)%100)
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Leading zeros in item strings

    We've recently done a system upgrade to 11.5.10.2. One of the problems we've found since the upgrade is that the Segment 2 from the item description strings has lost its leading zeros. Our string is in the format xxx-0000-0-xxx with segment 1 being the family, 2 being an item number within the family, 3 being the item level, and 4 being a manufacturer id. We previously didn't have any problem with missing leading zeros.
    What was previously ERT-0101-1-ABC is now showing as ERT-101-1-ABC. If this were purely for display purposes it wouldn't be too important, but it's affected some of our interfaces and reports. Even wiithin the standard inventory/mrp/order management screens, the item format changes depending on the individual form.
    It looks as if different screens/functions treat items in different ways - sometimes treating the string as a whole, other times apparently working each segment separately and then displaying a concatenated, lead zero less string. In the System Item segments value set for segment 2, I can see that Right-justify and Zero-fill Numbers is switched on. Is it this option that's failing?
    We've already implemented some fixes by padding the segment out as we produce the XML files we need for export, but before we get our support contractors to build fixes in all over the place I thought I should ask if there's a more singular fix for this.
    I can see some rather old issues logged in Oracle Support, but not a recent one related to this upgrade and zeros going missing.
    Any help gratefully received. :)

    Yes, the format validation for it is number. I'm reasonably certain it always used to be number, though.
    Should their be any detriment elsewhere if I had it changed to Char?
    The field (in our test system) is protected against update - how can I remove the protection to test this?
    Thanks for your help so far :)

  • How to get leading zeroes in exponent of e-format

    In order to mimic an ancient file specification, am trying to write DBL numbers in e-format where the exponent is padded to two digits with leading zeroes.
    For example:  -1.15091E-03
    Is there a simple format code that does this or do I need to write something from scratch?
    LabVIEW Champion . Do more with less code and in less time .

    I am writing to a file.
    (Currently, I use the following workaround: format as %12.5e, then scan the substring after the "E", format it as %+03d, and recombine with the mantissa)
    LabVIEW Champion . Do more with less code and in less time .

  • Remove leading zeros from a string

    Hi,
    I have a string with some numeric value.
    e.g.
    String a = 54890001
    I want to make it 10 digits long by padding zeros at the begining
    Now a = 0054890001 ( this is for display purpose ) I know how to do it.
    Now How can strip these leading zeros from this number to get back the actual number. The user sees this 10 digit number and he can change it to something like 0067490001. Now I want to strip these leading zeros.
    and i shd get 67490001.
    In other words, how to strip leading zeros from a string ?
    Thanks for help
    Vinod

    I would try two things: First, just try a straightforward parsing of your String using the Integer.parseInt() method. This is only my first suggestion because the number could be interpreted as octals; only testing will really tell. Second, try a method like this:
    public static String removeLeadingZeros(String str) {
        if (str == null) {
            return null;
        char[] chars = str.toCharArray();
        int index = 0;
        for (; index < str.length; index++) {
            if (chars[index] != '0') {
                break;
        return (index == 0) ? str : str.substring(index);
    }Shaun

  • Leading zeros from Adobe form web service data connection

    I created a web service for BAPI_PRODORD_GET_DETAIL and used it as a data connection in an Adobe form. When executing the connection using request parameters of:
    Number = [Production Order #]
    OrderObjects.Operations = 'X'
    no production orders are found.
    I debugged and discovered the BAPI only found production orders when the Number importing parameter contained padded leading zeros. After searching the forums, I suspect (1) I have the wrong field type and / or pattern for the production order number input field or (2) SAP Note 1050826 may apply.
    Does anyone have suggestions on which field types and patterns to use? I have tried each of Text, Numeric, and Decimal. When using Numeric, I set the data format to Float instead of Integer. I tried data patterns such as: num , the data displays with leading zeros but does not pass to the BAPI with them.
    I was also thinking a Formcalc or Javascript may be the solution.
    Livecycle version: 8.1.2
    Component SAP_APPL: 603 (for SAP note relevancy)
    Thank you,
    --- Scott

    Hello,
    maybe it would be the fastest approach here to work with the value as a string and check the length of the "string" and if needed add some leading zeros. You may try some validations, so the value entered by the user is denied if not in the respective format.
    For a smooth start with scripting start here:
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Regards, Otto

  • Display numbers formatted with leading zeros or spaces.

    There are some cases where you might need to display numbers with leading zeros or leading spaces, or trailing zeros.  I experimented with several methods and came up with some examples.  This is a Console application, but the results can just
    as well be output to a listbox in a Windows form.
    Sub Main()
    Dim snum As String, inum As Integer = 56
    snum = inum.ToString()
    Console.WriteLine(snum & vbTab & " ToString()")
    snum = inum.ToString("D4") 'adds leading zeros
    Console.WriteLine(snum & vbTab & " ToString(""D4"")")
    snum = inum.ToString("F4") '4 decimal places with trailing zeros
    Console.WriteLine(snum & vbTab & " ToString(""F4"")")
    Console.WriteLine()
    snum = String.Format("{0,4}", inum) 'leading spaces
    Console.WriteLine(snum & vbTab & " Format{0,4}")
    snum = String.Format("{0:D4}", inum) 'leading zeros
    Console.WriteLine(snum & vbTab & " Format{0:D4}")
    snum = String.Format("{0:F4}", inum) '4 decimal places with trailing zeros
    Console.WriteLine(snum & vbTab & " Format{0:F4}")
    Console.WriteLine()
    snum = inum.ToString().PadLeft(4, "0"c) 'leading zeros
    Console.WriteLine(snum & vbTab & " PadLeft(4, ""0""c)")
    snum = inum.ToString().PadLeft(4, " "c) 'leading spaces
    Console.WriteLine(snum & vbTab & " PadLeft(4, "" ""c)")
    Console.ReadLine() Console.Clear()
            For x As Integer = 1 To 20
                snum = x.ToString("D4")
                Console.WriteLine(snum)
            Next x
            Console.ReadLine()
    End Sub
    Solitaire

    I would add that many of these methods also work with numeric types that are not integers.
    Note that the "D4" format string doesn't work for non-integral types (such as Double and Decimal), and the "F4" format string doesn't pad with trailing zeros, it rounds to 4 decimal places (which can lose information). PadLeft works with
    the entire string, it isn't aware of the decimal point.

  • Serial Numbers with Leading Zeros

    We have leading Zeros in our serial numbers, is thier customizing or any user exits which would allow us to store and use these as they are .
    Ex - SN= 02547 it stores in SAP as 2547 to the user and I think in the DB its right justified and padded with zeros.
    Please advise.

    Hi
    I think you can get this functionality done using function module: CONVERSION_EXIT_ALPHA_INPUT.
    Check with ABAPer.
    regards
    Srinivas

Maybe you are looking for

  • HT4436 how do i add an email to my iCloud account

    How do I add an email address to my iCloud account

  • A way to limit overdrive in vocals?

    There are moments when I sung to close to the microphone and the volume suddenly increases dramatically, is there a way to keep the volume between a certain low and a certain high so theres no drastic increases in volume?

  • FAQ - Frequently Asked Questions in Win Client

    Hello, everybody! Somebody knows if can I use the funcionalitie FAQ's in a Win Client 4.0? If I can, it's possible to send me any docs about it? ([email protected]) Thanks anyway.

  • Audigy 2 ZS: Cannot save setti

    Hi, my problem is: after each start of my PC, I have to open - Equalizer - EAX-Console - Speaker-settings (here I have to recalibrate the 5. speakers, so that my rear speakers will work.) I made profiles, they are saved, but they aren't acti've after

  • CAN'T NETWORK eMac and G4 Mirrored Tower

    Hello, I have a 700mz G4 eMac and a 1.5g G4 Tower, and am trying to network them. I have a Linksys Ethernet Cable/DSL Router BEFSR41 (not wireless). Once I restart the computers using the M.R.S. order, they can then both get on line. Once they are on