Format strings, need leading zeros

I have a data input where serial data is converted to a numerical value, then multiplied by a conversion factor, and the result then converted back into a string for outputting to a data file.
I have not been able to get small numbers, such as "497" to get converted into a string "0497". Have tried the %04d format string, which gives me an output of 4970000 - not quite what I need.
Am using the FormatIntoString.vi, which has a "format string" input, but values which should work like "%04d" do not give me the leading zeros.
Ideas? Thx!

The format string works on the numeric input of the function. The string input is for adding a string prefix to the output and is not a required input. In your example, if you wire the string to a Scan From String function and wire the output of that to the numeric input of the Format Into String, everything will work just fine. I've attached a corrected VI.
Attachments:
TestFormat-Fixed.vi ‏14 KB

Similar Messages

  • Multi-value parameters and strings with leading zeros

    I have invoice number as a multi-value parameter. Invoice is a string,10 (VBRP.VBELN) .
    Invoice number is my group. If I enter invoices 100 and 200 as parms, then I only get data for invoice #100 (the lowest value entered). But if I enter 100, 0000000100, 200, 0000000200 as parms, then I get data for both invoices. Is there a way to get around having to enter the invoice number in both formats. BTW, if I only enter 0000000100 and 0000000200 then I get no data.
    Selection criteria is (VBRP.VBELN) = ?invoiceno --- parms are defined as allow muliple values and allow discrete values.

    Oops, that's not gonna work with multi-value parameters.  How about:
    if IsNumeric((VBRP.VBELN)) then
      ToText(Val((VBRP.VBELN)), "0") in {?invoiceno}
    else
      (VBRP.VBELN) in {?invoiceno}
    end if
    BTW, the reason why your original formula didn't work was because the "=" should have been "in".  The above is needed only if the (VBRP.VBELN) field might contain leading zeroes.
    HTH,
    Carl

  • Format numbers with leading zeros

    Hi,
    Im returning the time as a string from a function like so
    return minutes + ":" + seconds + ":" + millisec;
    But I need each part to always display with two digits and
    show leading zeros.
    Can anyone tell me how
    Thanks

    Thanks NedWebs
    I have done this
    var minstring = minutes.toString();
    var secstring = seconds.toString();
    var millistring = millisec.toString();
    if( minutes < 10 )
    minstring = "0" + minstring;
    if( seconds < 10 )
    secstring = "0" + secstring;
    if( millisec < 10 )
    millistring = "0" + secstring;
    if( millisec < 100 )
    millistring = "0" + secstring;
    return minstring + ":" + secstring + ":" + millistring;
    Thought there must be a better way.
    But it works!

  • Need leading Zeros in the excel sheet which is sent from ABAP

    Hi ,
    I am downloading data from SAP to excel sheet using the WS_DOWNLOAD Function Module. The numeric data in not having leading zeros.  if it is 0010 it is displaying 10 in the excel sheet . i need the leading zeros in the excel sheet. without manulally changing it to Text in the excel sheet .
       Is there any way to do it .
    Thanks,
    Chetan

    Hi Chetan,
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          filename                = w_file_path
          filetype                = 'DBF'                       "declare the File type as DBF then leading zeros will appear
          write_field_separator   = 'X'
          confirm_overwrite       = 'X'
        TABLES
          data_tab                = Itab.
    Regards,
    Prabhudas

  • Need leading zeros to fill the front of a 10 character parameter being passed-HELP!

    I have a prompt 10 character parameter that some people forget to insert the zero at the beginning of the number. ex.(they type "594468010", suppose to be "0594468010").  How can I fill in the leading zeros for them after they type in the prompt box?  My prompt comes from a command.  Here is a sample of the where clause:  WHERE DB.ID_NUMBER = '{?I_IDNO}'
    I tried to use LPAD('{?I_IDNO}',10,0), it works with plsql, but not when I run the crystal report.
    Does anyone have any ideas?  thanks for your help in advance!

    a) you can always use your database specific cast / convert function to convert the text field into a number for the purpose of record selection. then change the prompt type to numeric. crystal commands are database specific so you'd want to check your database help on what specific syntax to use for the cast / convert in the command.
    b) the other choice to leave the command & prompt type alone & use an edit mask on the command prompt...this would then force the end user to enter the leading zeroes as the edit mask would force a certain length on the entry. so in the crystal field explorer edit the prompt and put in an edit mask of 000000000 for example if you wish to force the end user to enter 9 numeric characters.

  • Conditionnal Formating Data  with leading zeros

    Hi,
    I have a report which is displaying the name of CD's lile this:
    C2009-1
    C2008-257
    C2008-3456
    C2008-12984
    In the database, there is a column
    Type: C
    Year: 2008
    CDNum: 1
    How, when I'm displaying the report, it always return a 5 digits number, with zero before to have this output:
    C2009-00001
    C2008-00257
    C2008-03456
    C2008-12984
    thanks,
    Roseline
    Edited by: Roseline on Oct 1, 2009 8:58 PM
    Edited by: Roseline on 6 oct. 2009 08:50

    Thanks for your help.
    My boss ask me to show 4 digits if the year = 2008 or 2007 or 2006, etc
    and 5 digit if the year = 2009
    C2009-1
    C2008-257
    C2009-3456
    C2008-12984
    In the database, there is a column
    Type: C
    Year: 2008
    CDNum: 1
    SELECT type || year || '-' || LPAD(cdnum, 5, '0') *IF YEAR < 2009*
    FROM your_table
    or
    SELECT type || year || '-' || LPAD(cdnum, 5, '0') *IF YEAR = 2009*
    FROM your_tableSo basiccly, I need to insert an IF in my SQL statement, can I do that??
    thanks,
    ROseline
    Edited by: Roseline on 6 oct. 2009 08:45
    Edited by: Roseline on 6 oct. 2009 08:49

  • Leading zero getting truncated in .CSV format GUI_DOWNLOAD

    Hello experts,
    I am trying to download the data using GUI_DOWNLOAD in .CSV format but the leading zeros are getting truncated. For instance Company code 0001 is displayed as 1 in the CSV File. But when I open the same file in notepad I am seeing 0001. Is this a known issue or this is how .CSV format should be?
    I have gone through some threads in SDN but they are not helpful.
    Your expert advise is much appreaciated.
    Thanks
    Abdul Hakim

    That is how excel displays values like 0001. It interprets them as a number and removes leading zeros.
    If you don't want this happen and you want excel to treat them like text, you need to append a quote at the beginning of the token like '0001
    You can use concatenate like below to append a single leading quote
    field = '0001'.
    CONCATENATE ''''  field INTO field.

  • Help keeping leading zero String- Long

    Hello
    I wonder lets say I have a String "09090" how do I convert this String to a Long and keeping leading zero so the Long is 09090?
    /D_S

    Numeric types like Long (or long) are numbers, not strings, so they have no formatting notions like leading zeroes. If you want to maintain the string "09090" keep the string around, even if you have to parse it as well. By the way, you forgot to describe what your goal is, what you are trying to do and what it has to do with leading zeroes.
    One more: Why does this print false?
    System.out.println(07070 == 7070);Hint: this generates a compile-time error:
    System.out.println(09090 == 9090);

  • How can I format a cell in Numbers to have leading zeros in a number?

    I imported a spreadsheet from Excel (Office 2014, Win 7) through iCloud and some numbers were formatted to have leading zeros (012358) in the original Excel file but the leading zero format was lost in Numbers.  Is there a way to format cells to have a number displayed with the leading zero in Numbers?  The leading zero is part of an identification and is important to the numbers (0027 is not the same as 27 in these records).
    thanks,
    Bob

    James has the formating part, but if you already did the import you can use the following formula to replace the zeros that were leading if you know it is a four digit reference number....
    =right("000" & A2,4)
    copy those values into your text formatted column from James' answer and you got it.
    Jason

  • Generic counter with leading zeros

    Good evening everybody,
    I was searching the code of a generic counter with leading zeros, but I did not found anything over the Internet. Therefore, I code it all by myself.
    I give you the code, it will maybe helps someone.
    Only needed leading zeros are generated, which means the following sequences :
    0 - 1 - 2 - ... - 7 for a max of 7,or
    00 - 01 - 02 - ... - 23 - 24 - ... - 89 for a max of 89, or
    000 - 001 - 002 - ... - 432 for a max of 432.
    public class LeadingZerosCounter {
      public String[] counters = null;
      public LeadingZerosCounter(int maximum) {
        this.counters = new String[maximum];
      public String[] init() {
        int maxLeadingZeros = 1;
        int index0 = this.counters.length;
        while ((index0 /= 10) >= 10) {
          maxLeadingZeros += 1;
        int counter = 0;
        for (int index1 = 0; index1 < maxLeadingZeros + 1; index1++) {
          while (counter < java.lang.Math.pow(10, index1 + 1)) {
            String stringCounter = new String("");
            for(int index2 = 0; index2 < (maxLeadingZeros - index1); index2++) {
              stringCounter = stringCounter.concat("0");
            stringCounter = stringCounter.concat(new Integer(counter).toString());
            this.counters[counter] = stringCounter;
            System.out.println(this.counters[counter]);
            if (++counter == this.counters.length) {
              return(this.counters);
            else {
              // no action
        return(this.counters);
      public static void main(String[] args) {
        new LeadingZerosCounter(100).init();
    NOTE : the two return are mandatory.
    Try maximum raised to a power of 10 and maximum raised to a power of 10 + constant in [1; 9] to understand.
    If you find any solution to make it faster, please let me know.
    Have a nice day,
    Christophe

    I like Jos' idea better than mine (go figure - he's a better Javanista)....
    public class Counter {   
        private String pattern;
        private int count;
        private int max;
        public Counter(int max) throws IllegalArgumentException {
            if (max < 0) {
              throw new IllegalArgumentException("Max (" + max + ") must be a positive number");
            this.max = max;
            int len = String.valueOf(max).length();
            this.pattern = "%1$0" + len + "d";
        public boolean hasNext() {
            return count <= max;
        public String next() {
            String result = String.format(pattern, count);
            count++;
            return result;
        public static void main(String[] args) {
            // for demo purposes only;
            // replace with command-line arg parsing, if desired...
            String prefix = "picture_";
            String suffix = ".jpg";
            Counter c = new Counter(99);
            while (c.hasNext()) {
                System.out.println(prefix + c.next() + suffix);
            try {
                new Counter(-1);
            } catch (IllegalArgumentException e) {
                System.out.println("test: " + e.getMessage());
    }

  • Leading zeros in dynamic text fields

    I have a dynamic text field that indicates the degree of
    rotation of a knob. I need the display to have three digits showing
    at all times. This means I need leading zeros from 0 to 99. ie,
    000, 001, 002, etc.
    Is there a way to do this numerically or do I have to change
    the numbers to strings and concatenate??
    Thanks,

    Yes, for the most part only strings can start with leading
    zeros.
    You might run into some troubles because Flash treats a
    leading zero as a sign that a number is octal, base-8.
    So if you were planning on using Number() to cast your values
    into numbers, don't! Instead use parseInt(someString,10).

  • F8as2-displaying leading zeros in a dynamic text field

    F8as2-
    Background:
    Currently I have to use two different text fields to display 10000 due to the different font sizes.
    The 10 is a larger font and the 000 is a smaller font.  When I assign '0 'to the dynamic text fields of the smaller font I get just that a '0' not a '000' which is what I want.
    Question:
    Is there an easy way to display leading zeros in a dynamic text field?  Or can a dynamic text field have different character positions displayed in different font sizes?  or both?
    Thanks for the help.

    F8as2-
    Thanks for the reply kglad.
    Are for saying the best way to display numerically calculated numbers that need leading zeros and or different font sizes is to convert them to a string for display purposes with textFormatting??

  • Leading zeros revisited Numbers '08

    I'v seen the discussions about a similar topic in this online community.  I do have one curiousity/complaint.  If the only way to put leading zeros is to hit the apostrophe or format the cell as text then will the number behave as a number in formulas or will you have to always convert that content to a number using a function?  Seems like such an elementary "feature" to put in why did Apple leave out the ability to leave something as a number but display the leading zeros?

    Numbers will usually interpret digits formatted as text to be numerical values in expressions. This only holds true if there are no extraneous alpha characters. I don't recall whether Numbers 08 (Ver. 1) had the "Numeral System" cell format option, but in Numbers 09 this completely solves the problem for those who need leading zeros. You would be wise to upgrade.
    Jerry

  • How to remove Leading zeros from MATNR "at Database Level"

    Hi,
    When we create a material in MM01 , we can either create material as Internal Material No. or External Material No. (By Explicitly entering a material No.)
    Our requirement is that: When we create an Internal Material , there should NOT be any Leading Zeros in MATNR.
    and for External Material No.  , Leading Zeros Should be there.  (In Database)
    1) Now , we can create the No. Range for material in such a way that it will allow only AlphaNumeric entries for Internal Material , and Only Numeric Entries for External Material No.
    This should slove the Purpose.
    But According to the Client's requirement , Material No can be Numeric OR Alphanumeric for Internal As well as External Material No.
    2) We can Add or Remove leading zeros from MATNR at application level.  i.e.  we can find some BADI / Enhancement where we will Use the Conversion FM (CONVERSION_EXIT_MATN1_OUTPUT or  CONVERSION_EXIT_ALPHA_OUTPUT) and remove Leading Zeros from MATNR. But these changes will NOT reflect at Database Level , Because in MATNR Domain , there is a conversion Routine  , That will Add Leading Zeros in MATNR While saving in the Database.
    3) While Displaying the Material In SE11 , we can also set the "Display Format" as With leading Zeros OR Without Leading Zeros.
    But we dont want to Just "Display" material with OR Without Leading Zeros.  we want to actually create materials in that way.
    What can we do , so that at Database Level our changes are Reflected.
    Thanks and Regards,
    Anand Gore
    Edited by: anandgore on May 18, 2011 3:47 PM

    That will Add Leading Zeros in MATNR While saving in the Database.
    That is because you have it configured that way.  You can configure the storage as you desire.  The default is the behavior you are describing.  You, or your functional analyst, need to review the documentation on the MM config settings for material master number storage.
    Never use CONVERSION_EXIT_ALPHA_OUTPUT for material conversion.  Also keep in mind that the MATN1 functions have their own BADI for extended formatting...

  • Leading zeros with 24-hour clock?

    I have my system preferences set to 24-hour clock.
    How do I get the times to display with leading zeros?
    For example, 06:45 instead of 6:45?

    As I said before, you need to explore. I was able to add it in less than 30 seconds.
    Let me try to explain. It is easy to do, but more difficult to explain.
    Go to Sys Prefs/Int'l/Formats pane. Choose Custom in the Times area. Choose Medium in the Show drop down menu. (Medium seems to be the one used by OS X for the menu bar clock.) Here you can arrange the order of the different components as you like. Notice they have little arrows indicating drop down menus. Most of the optional formats offer a leading zero.
    Even though you have formatted it in the Int'l pane, you must choose for some of your formating to show in the Date & Time/Clock pane.
    Good Luck.

Maybe you are looking for