Padding a string with spaces

How do you pad a string w spaces using "Format into a string" w/o typing /s/s/s/s/s for say 5 spaces ?
Solved!
Go to Solution.
Attachments:
printed output.PNG ‏6 KB
wire diagram.PNG ‏11 KB

Hi Clint,
this way:
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome

Similar Messages

  • How to pad a string with space or other character

    length 14 string '00000000000155' turn to length 25 string '00000000000155         ' ,use space to pad string trail.
    using following function:
    CONCATENATE '00000000000155' '         ' into lv_string
    but result is the lv_string ='00000000000155',the spaces were not added the string trail.
    how to achieve this purpose padding string.
    pls help me.
    thank you.

    Hi ,
    Not sure what exactly you require, But in my understanding you need to add one more spave after the doknr no. Please refer this code which could be more useful.
    data: lv_objkt like aeoi-OBJKT,
          lv_doknr like draw-doknr,
          lv_dokar like draw-dokar,
          lv_doktl like draw-doktl,
          lv_dokvr like draw-dokvr,
          lv_slen type i.
    lv_dokar = 'DRW'.
    lv_doknr = '00000000000155'.
    lv_doktl = '000'.
    lv_dokvr = '-'.
    CONCATENATE lv_dokar lv_doknr INTO lv_objkt.
    lv_slen = STRLEN( lv_objkt ).
    lv_slen = lv_slen + 1.
    lv_objkt+lv_slen(3) = lv_doktl.
    CONCATENATE lv_objkt lv_dokvr INTO lv_objkt.
    WRITE: lv_objkt.

  • Padding String with spaces -tried known methods but code not working!

    I am trying to figure out an easy way to pad a string with spaces at the end. The way that definitely works is a for loop where string = string + " "; until string is the length that I need. However, for several dozen strings this is a lot of unnecessary overhead. I've done some research and tried a few different things - yet none of them seem to actually pad the string.
    import org.apache.commons.lang.StringUtils;
    public class Test
         public static void main(String[] args)
              String one = "1234";
                    //print string at current lenght
              System.out.println(one+"*");
                    //try padding using String.format (in padRight method below)
              one = padRight(one,(8-one.length()));
              System.out.println(one+"*");
                    one="1234";
                    //try padding using StringUtils
              String tmp = StringUtils.rightPad(one, (8-one.length()));
              System.out.println(tmp+"*");
         private static String padRight(String s, int n)
              return String.format("%1$-" + n + "s", s);
    }I've researched and these are the two most common methods people are suggesting. I am using java 1.5 so the String.format should work.. however, when I run it (I use JBuilder) the output is always "1234*".... after I try to pad it the output should be "1234 *" (with 4 spaces between the 4 and *) . Any suggestions is greatly appreciated! Thanks in advance.

    Wow, I completely botched that... uncle_alice, thank you for clearing that up for me.
    pbrockway2 - thank you, I actually did peruse the Formatter documentation - I would never post without researching something first... but I must have read it with one eye shut because walked away with the impression that I needed to submit the difference. I obviously misunderstood the documentation.
    Thanks!

  • Use REGEXP_INSTR to find a text string with space(s) in it

    I am trying to use REGEXP_INSTR to find a text string with space(s) in it.
    (This is in a Function.)
    Let's say ParmIn_Look_For has a value of 'black dog'. I want to see if
    ParmIn_Search_This_String has 'black dog' anywhere in it. But it gives an error
    Syntax error on command line.
    If ParmIn_Look_For is just 'black' or 'dog' it works fine.
    Is there some way to put single quotes/double quotes around ParmIn_Look_For so this will
    look for 'black dog' ??
    Also: If I want to use the option of ignoring white space, is the last parm
    'ix' 'i,x' or what ?
    SELECT
    REGEXP_INSTR(ParmIn_Search_This_String,
    '('||ParmIn_Look_For||')+', 1, 1, 0, 'i')
    INTO Position_Found_In_String
    FROM DUAL;
    Thanks, Wayne

    Maybe something like this ?
    test@ORA10G>
    test@ORA10G> with t as (
      2    select 1 as num, 'this sentence has a black dog in it' as str from dual union all
      3    select 2, 'this sentence does not' from dual union all
      4    select 3, 'yet another dog that is black' from dual union all
      5    select 4, 'yet another black dog' from dual union all
      6    select 5, 'black dogs everywhere...' from dual union all
      7    select 6, 'black dog running after me...' from dual union all
      8    select 7, 'i saw a black dog' from dual)
      9  --
    10  select num, str
    11  from t
    12  where regexp_like(str,'black dog');
           NUM STR
             1 this sentence has a black dog in it
             4 yet another black dog
             5 black dogs everywhere...
             6 black dog running after me...
             7 i saw a black dog
    5 rows selected.
    test@ORA10G>
    test@ORA10G>pratz
    Also, 'x' ignores whitespace characters. Link to doc:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942
    Message was edited by:
    pratz

  • Pad a string with zeros ?

    Hello ABAP Experts,
    How to pad a string with zeros.. is there a direct method i can use.
    eg:
    string length is 8
    string is custnumb
    value is 588
    but i would like to see 00000588
    please suggest.

    You can simply move it to a TYPE n field also.
    data: n(8) type n.
    data: custnumb(8) type c value '588'.
    n = custnumb.
    custnumb = n.
    Regards,
    Rich Heilman

  • How to concatenate a string with spaces

    Dear experts,
    I would like to concatenate a string with three spaces, for example,
    CONCATENATE 'X' SPACE SPACE SPACE 'Y' INTO LV_RESULT.
    However, the result I got from executing the above statement is not 'X   Y' as I want, but rather 'XY'.
    I did try
    CONCATENATE 'X' '***' 'Y' INTO LV_RESULT.
    REPLACE '***' with '   ' INTO LV_RESULT.
    still doesn't work.
    How can I write ABAP code to archive such a result?
    Any idea would be appreciated.
    Vitthavat A.

    dear  Oliver Hütköper and koolspy,
    I tried your solutions, and it works.
    so i awarded points to you.
    anyway, while trying the 'respecting blanks', i got an error:
    "".", "IN BYTE MODE", "SEPARATED BY ..." or "IN CHARACTER MODE" expected"
    not sure what it means. but it's ok. the problem has been solved.
    thanks again.

  • Breadcrumbs containing string with spaces - generating the anchor

    so I have a website that contains a 'breadcrumbs' line that allows users to click on it, and take them back to the parent page
    eg. "jewellery"
    I simply suffix this string with ".cfm" to generate the anchor / filename
    what's the best way to deal with strings containing spaces?
    eg. "birthday cards"
    As good practice I want to use a more compatiable filename that doesn't include spaces
    eg. "birthday_cards.cfm"
    is the REPLACE command ok to use ? or is preferrable to add an additonal field to the table, called "filename" and store the exact filename in there ?

    option 1
    use quotes like href="http:\\....."
    option 2
    convert spaces to %2B

  • How do I set the number pad to work with spaces?

    It has worked with other OSs but with Mavericks 10.9.5 (and from what I here, Yosemite) you can not use the number pad to change spaces. I know I can use the numbers across the top or the arrows, I just find it quicker and ergonomic to use the number pad. As many spaces I use this is very inconvenient to be reaching across the keyboard. Is there a way to fix this. I went to the preferences but could not find anything there to change. Maybe Apple could fix this in there next update.

    Apple doesn’t routinely monitor the discussions. These are mostly user to user discussions.
    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback

  • Can I Pass String with Spaces in it To exec()

    Hello All,
    I am passing a Command in Runtime.exec() method, which is a String and contains a folder name(Folder---Name) which is having Spaces in it. For eg. c:/Folder/Folder(Spaces in between)Name/Data.java
    My Problem is when i pass it to exec() it automatically gets converted to a Folder name with only one space
    E.g c:/Folder/Folder(One Space in between)Name/Data.java,
    Because of which my command is not able to find the Folder specifed.
    I want the Original Path(c:/Folder/Folder(Spaces in between)Name/Data.java) to be passed and executed through
    exec() so that the command runs successfully..........
    Any help will be highly appreciable..
    Thanks
    Er.Atul

    When I make a simple array of String a, Try to run simple command like "change Directory"....
    *try {*+
    String[] a = {"cd atul", "cd poc"};+
    Runtime runtime = Runtime.getRuntime();+
    Process procedure = runtime.exec(a);+
    +*} catch (IOException ex) {*+
    Logger.getLogger(Testing.class.getName()).log(Level.SEVERE, null, ex);+
    It Gives me this type of Exception............
    Feb 20, 2009 5:13:36 PM Testing <init>
    SEVERE: null
    java.io.IOException: Cannot run program "cd atul": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
    at java.lang.Runtime.exec(Runtime.java:593)
    at java.lang.Runtime.exec(Runtime.java:466)
    at Testing.<init>(Testing.java:26)
    at Testing.main(Testing.java:36)
    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
    *... 4 more*

  • Formatting an NSURL with spaces

    I've got an input string which most certainly will contain spaces or other "bad" characters, which I want to use in a mailto: url such as
    mailto:[email protected]?body=some string with spaces
    I've been searching but I can't seem any sort of method to properly format the string for an NSURL without breaking it.
    Thanks.

    Scan through the "mailto:" URL docs at http://www.ietf.org/rfc/rfc2368.txt
    There are several characters that need to be encode just like the space. It's simply the % character followed by the two digit hex code of the character.

  • Format a number, pad with spaces

    I want a simple way to format a number into a String, but have it padded with spaces. My code started like this:
    DecimalFormat myFormatter = new DecimalFormat("###.00");
    String output = myFormatter.format(12.5);
    The output is '12.50' when I want ' 12.50' (leading space). There's got to be an easy way to do this!
    Thanks for your help

    What you probably wanted to do was print some numbers in a column (of JTextArea's, for example) so that the decimal points line up.
    I wasted some more time and came up with the following:  String formattedNumber = numberPad(number, "###.00E0");
      static String numberPad(double number, String format) {
        int desiredDecimalPosition = format.indexOf('.');
        DecimalFormat numFormat = new DecimalFormat(format);
        String formattedNum = numFormat.format(Math.abs(number));
        formattedNum = formattedNum.replace('E', 'e');
        int exponentPosition = formattedNum.indexOf('e');
        if (exponentPosition < 0)
          exponentPosition = formattedNum.length();
        formattedNum = formattedNum.replaceFirst("e0", "");
        int decimalPosition = formattedNum.indexOf('.');
        formattedNum = (number > 0 ? " " : "-") + formattedNum;;
        if (decimalPosition < 0)
          decimalPosition = exponentPosition;
        int padding = desiredDecimalPosition - decimalPosition;
        if (padding > 0)
          formattedNum = "        ".substring(8 - padding) + formattedNum;
        return formattedNum;
      }Now it turns out that- despite the fact that I've told DecimalFormat to format precisely 2 digits to the right of the decimal, it sometimes randomly gives me 3, and (less often) 1!
    All this trouble just to try save 16kB of Henrik Bengtsson's sprintf in my jar file...

  • Padding a field out with spaces to s set length

    Post Author: danish
    CA Forum: Formula
    Hi,
    I'm new at using Crystal Reports.
    I am trying to pad a string out to a set length of 50. The initial string is of variable size depending on the data in the field.
    Can anyone tell me how I can do this using a while do loop.
    ie while field length < 50 add a space to field until field length = 50.

    Post Author: danish
    CA Forum: Formula
    Thanks for that. Managed to work out how to do with while do but this will be helpful for future.

  • How to replace a character in a string with blank space.

    Hi,
    How to replace a character in a string with blank space.
    Note:
    I have to change string  CL_DS_1===========CM01 to CL_DS_1               CM01.
    i.e) I have to replace '=' with ' '.
    I have already tried with <b>REPLACE ALL OCCURRENCES OF '=' IN temp_fill_string WITH ' '</b>
    Its not working.

    Hi,
    Try with this..
    call method textedit- >replace_all
      exporting
        case_sensitive_mode = case_sensitive_mode
        replace_string = replace_string
        search_string = search_string
        whole_word_mode = whole_word_mode
      changing
        counter = counter
      exceptions
        error_cntl_call_method = 1
        invalid_parameter = 2.
    <b>Parameters</b>      <b> Description</b>    <b> Possible values</b>
    case_sensitive_mode    Upper-/lowercase       false Do not observe (default value)
                                                                       true  Observe
    replace_string                Text to replace the 
                                         occurrences of
                                         SEARCH_STRING
    search_string                 Text to be replaced
    whole_word_mode          Only replace whole words   false Find whole words and                                                                               
    parts of words (default                                                                               
    value)
                                                                               true  Only find whole words
    counter                         Return value specifying how
                                        many times the search string
                                        was replaced
    Regards,
      Jayaram...

  • String with Trailing Space in a 4.7 / Basis 620 system

    Hi
    My customer is using SAP 4.7(Enterprise Management Version) / SAP BASIS Release 6.20 (Kernel 640).
    We have a requirement to print a product label using a 2D Datamatrix barcode following HIBC standards.  We are using a custom development object (Z function module) that builds the barcode string (variable length string) using a Mod43 calculated check digit as the last character of the string.  One of the valid check digits is a "space" character as the last character of this barcode string.
    Everything in our solution is working fine, except for the situation of the "space" check digit character at the end.  We are running into an ABAP syntax limitation when we are trying to concatenate the calculated check digit onto the barcode string.
    For example, we have a barcode value "+M53210250 " (within the quotes).  This string ends with a SPACE character at the end.  We are calculating the barcode value (some fixed elements + SAP material number, batch, etc.), then calculating the check digit, and concatenating the check digit onto the end of the initial barcode string value.
    I have tried this in a higher version system and am able to make it work by using the statement CONCATENATE RESPECTING BLANKS.  This syntax is not available with WebAS 620 however.
    Here are the attempts we have made:
    *Get HIBC 2D Barcode String
      CONCATENATE E_HIBC_2D_BC L_CHECK_DIGIT INTO E_HIBC_2D_BC.
    IF L_CHECK_DIGIT = SPACE.
    The following attempts does not work
    CONCATENATE with SPACE at end
    Concatenate HIBC SPACE and a dummy variable like 'TEST' into HIBC builds a space in between the dummy and HIBC
    and then when i split it the space is lost again.
    Insert SPACE in the beginning bulding a new variable with 0(1) space followed by HIBC and then SHIFT CIRCULAR BY 1 place
    It will work only if moved to a variable of length which is exactly HIBC + 1 char in length then by default the last char is SPACE.
    Use a replacement variable which is not a HIBC Check Digit like # & ! ? ^ or other for SPACE
    ECC 5.0 and HIGHER
    *CONCATENATE {dobj1 dobj2 ...}|{LINES OF itab}
               INTO result
               [IN {BYTE|CHARACTER} MODE]
               [SEPARATED BY sep]
               [RESPECTING BLANKS].
    *4.7 Version *
    *CONCATENATE f1 ... fn INTO g.
    *1. ... SEPARATED BY h
    *2. ... IN BYTE MODE
    *3. ... IN CHARACTER MODE
    Having the customer upgrade to ECC 5.0 is not feasible to solve this.
    If anyone has any alternative ideas on how to manage this variable length string and respect the trailing space, I would appreciate it.
    I have searched the forums but the only solutions that are close deal with outputting to a file during a download or FTP, or else mention the newer syntax of CONCATENTATE with the option RESPECTING BLANKS, but that is not available in this release.

    If you could predict how long the string is (assuming you might determine whether the last element length is shorter than the db length), you could try to insert your check digit based upon fieldname+your_calculated_length(1) = checkdigit.
    for example if batch is 3 cahr and you have '50' in the data, you could calculate as lv_len = strlen( the value ) .
    lv_len = lv_len + 1.
    move checkdigit to barcodefield+lv_len(1).
    Perhaps something like this would allow you to work around.  At any rate, if you can figure out if there's supposed to be one or ?? blanks on the end, specifying the position by +offset(columns) should do the trick, instead of the concatenate.

  • Runtime.exec with spaces not working EVEN using String[]!!

    Hi everyone,
    I need to start the rmi registry from some code,and i need to pass it the classpath of two jars when initialising it. My problem is that the paths I set aren't taken when they contain a space.
    Here's the code:
    <code>
    String rmiRegistryCommandLine[] = new String[] {
    + System.getProperty("java.home")
    + "\\bin\\rmiregistry.exe\"",
    "-J-Djava.class.path=\""+System.getProperty("user.dir")+"\\MyJar.jar\"",
    "1099"};
                                            Runtime.getRuntime().exec(rmiRegistryCommandLine);
    </code>
    I know that Runtime.exec(String) tokenizes the input, which is why I'm not using it, but Runtime.exec(String[]) isn't supposed to tokenize the input. System.getProperty("user.dir") can contain a space, so I put quotes around that, but I need the -J-Djava.class.path in the same string. I tried breaking it up into two more separate strings but it didn't even run for normal non-space paths then. I am sure that if the whole -J-Dblah....upto MyJar.jar was in quotes then it would work, but I need the classpath in quotes separately as it could contain a space.
    Can anyone help me get this working?

    Ya, that's fine but the command line I want to pass is:
    d:\j2sdk1.4.0\bin\rmiregistry.exe -J-Djava.class.path=d:\my dir with spaces\MyJar.jar;d:\my more dir with spaces\MyJar2.jar 1099
    If I say
    arg[0]="d:\\j2sdk1.4.0\\bin\rmiregistry.exe";, that's finebut arg[1] is the problem
    if I say
    arg[1]="-J-Djava.class.path=d:\\my dir with spaces\MyJar.jar; d:\\my more dir with spaces\\MyJar2.jar";, then it definitely won't work on 9X machines and probably not on NT.
    if I break up arg[1] into:
    arg[1]="-J-Djava.class.path=";
    arg[2]="d:\\my dir with spaces\\MyJar.jar";
    arg[3]=";";
    arg[4]="d:\\my more dir with spaces\\MyJar2.jar";I'll need to put quotes around the two individual two class paths or else it won't work.
    I find though that if I put the classpath as follows
    d:\"my dir with spaces"\MyJar.jar then it seems to work.
    I think a regular expression function to search for any directory with spacees and then put quotes around it and reinsert it into the path would be the solution.

Maybe you are looking for

  • After upgrading to itunes 7.3.1.3 I can't run the backup to dics anymore.

    After upgradeing to itunes 7.3.1.3.1 I can not run the backup any more. Also the CD burning runs very slow. The DVD burner run ok with other software. After it checks for file to be backed up it kept ejecting the blank DVD and asking for a blank disc

  • Automatic goods return after Goods Issue

    Hi, I have the following scenario: The client sells finnished materials using pump-over process. The material is attached to the pump-over packaging in a sales/prod BOM. The pump-over packaging is followed with a Batch number. When posting the goods

  • Relese Purchase Order ....??

    Hi experts, I did Relese procedure for Purchase order . its working through ME29N  for relese PO. there was a 2 leves to relese PO   100 euro  -   1000 2nd  leves for relese                      1000euro  -   10000 after relesing first level system h

  • My Posts still has layout trouble

    Posted below is the source of a line that came out of alignment. I am using (lt) to indicated less than, and (gt) to indicate greater than symbols: (lt)tr(gt) (lt)td width="1%"(gt)5.(lt)/td(gt) (lt)td width="1%"(gt) (lt)img src="http://a772.g.akamai.

  • Reset Password Daily for icloud on pc

    I have no problems on my iphone.  Almost daily with my pc I am told I need to reset my password when signing into my icloud mail.  I have no problems when I go to manage my apple id.  But when I try to sign into icloud I get: "Your apple id has been