Removing leading zeros and leading blank spaces from an input field

Hi All,
I have an input field which is alphanumeric and i need to remove the leading zeros and blank spaces in it , but intermediate spaces should be kept .
so i used the UDF
        String output = input.replaceFirst("^0+","");
        return output;
but this code does not remove the leading blank spaces . Can anybody help in modifying this code so that even the leading blank spaces along with leading zeros  can be removed .
Regards ,
Loveena .

lets say input is a
then
int len = a.length();
for(int i;i< length;i++)
if(a.substring(0,1).equals(" ") || a.substring(0,1).equals("0"))
a = a.substring(1,len);
return a;
hope you got the logic so that you can enhance it better

Similar Messages

  • How to remove leading zeros and leading blanks from numc

    Hi experts,
             i wanted to show personal number into my smartform..The field name is PERNR(8) which is of type N. But, in my smartform I get output as (000234)..if I use &pernr(Z)& leading zeros r removed but then the output is (   234)..Now, I wanted to remove this leading space also...
    please tell me the solution for this...
    thanks

    Hi Ujjwala,
    You can use SHIFT.
    DATA: V_CHAR(10) VALUE '00000'.
    SHIFT V_CHAR LEFT DELETING LEADING '0'.
    Regards,
    Ramesh
    *award the points if answer was helpful

  • To remove leading zeroes and take directly from IDOC(Segment field) to file

    Hi SapAll.
    i have got a simple requirement in a idoc to file Interface.
    here in a sender Idoc there will be one segment with one field,the requirement is to remove leading zeroes and take directly the data from this field and map to one of the field in  reciever  file structure.
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    it would be preferable if any body can give me the solution without user defined functions.
    regards.
    Varma.

    from your first post:
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    use the same formatting that you used in 3.0 .... try with just a # in the FormatNum function.
    Regards,
    Abhishek.

  • New line break and extra blank space characters disappear after submit form?

    Hello,
    I have a PDF form with a Submit button that is dynamically created in my code to send the form data to the server in HTML format.
    After the form data is received on the server side, all strings with new line break and extra blank spaces are gone.
    For example, if I enter string in a text field as shown below on the form:
    Hello   ,  
    this is  
        just a
    test
    After the form data is sent to the server, this string would become:
    Hello , this is just a test
    New line breaks are gone. Also, if there is more than 1 blank space character between 2 characters, the extra blank space characters would be removed as well.
    It does not only happen to multi-line text field, even with single-line text field. If I have a string like this in a single-line text field:
    Hello         this is just              a         test
    After the form data is sent to the server, it would become:
    Hello this is just a test
    The form is created in OpenOffice then converted to PDF. The Submit button is created in my program using iText.  I have no idea it is iText that trims my string or PDF itself does it.
    Can anyone give me any possible explanation? Thanks.

    That is not what I get. Since it's URL-encoded, spaces are represented by the "+" character and carriage returns are represented by the "%0d%0a" (cr/lf) sequence.
    Are you looking at the actual data that getting sent to the server or the output from the server after it processes it?

  • How to delete blank space from value of Infoobject in the transfer rule

    does anyboady know how to write a routine in the transfer rule in order to delete ending blank spaces from value of Infoobject 'ORDTEXT'. E.g. value: 'ABM    '?  After routine, the result should be 'ABM'.
    Thanks for any input.

    Deleting 'ending blank spaces' from a character type field (ie info-object or text) in SAP is not meaningful. For all usage, a char type field of length 8 having value  'ABM     '  is same as 'ABM'.
    Ok, HTML is changing the display in the above, so let me restate it
    For all usage, a char type field of length 8 having value  'ABM_____'  is same as 'ABM', take the underscore character (_) in the first string as a placeholder for space character.
    Edited by: Ajay Das on Jul 29, 2009 12:07 PM

  • I want to remove the header and footer when printing from my mac, i can do this in the Page Setup on my PC but not on the Mac. I can do it each time I print but then it resets. How do I make a universal change?

    I want to remove the header and footer when printing from my mac, I can do this in the Page Setup on my PC but not on the Mac. I can do it each time I print but then it resets. How do I make a universal change?
    == This happened ==
    Every time Firefox opened

    Go to the "File" menu, then "Print." The window that appears will have three drop-down menus at the top.
    The first is labeled "Printer",
    The second is "Presets".
    The third is unlabeled but has "Copies & Pages" selected by default.
    Click on that third menu and select "Firefox" near the bottom of the list.

  • Remove blank spaces in a text field?

    How can I remove blank spaces in a text field? Some text fields have a lot of blank fields that need to be removed so that I can report only on the text.
    CRXI
    Edited by: Burton Roger on Feb 10, 2009 5:48 PM

    Ex:
    "Hi,
    I have a need for monthly service desk reporting.
    Please provide data on single sheet.
    Thank you"
    I would like to shrink it down to -
    Hi, I have a need for monthly service desk reporting. Please provide data on single sheet. Thank you"

  • I wish to remove "Show sidebar" and "Show Top Sites" from the Favorites Bar in Safari 7.0. How may I do so?

    I wish to remove "Show sidebar" and "Show Top Sites" from the Favorites Bar in Safari 7.0. How may I do so?

    I aggree It's rather annoying that you can't remove these features when like me you never use them, however by far the most annoying part of this is that when you go into 'Customize Toolbar' you can actually add yet a second 'Show Top Sites' feature to the toolbar !! Even those people who actually want to use this feature don't require two of them. For crying-out-loud come on Apple, this has to be a joke right?!?

  • Get Value From an input field

    Hi All,
    I am a newbie to ABAP Webdynpro.I would liketo know how should I get the value from an input field at runtime?
    Thanks,Mukta

    By reading the context attribute which bound to inputfield, you can get the value.
    Say you have a node called 'MAIN_NODE' and has the attribute 'INPUT_VALUE', which is bound to the Inputfield.
      DATA LO_ND_MAIN_NODE TYPE REF TO IF_WD_CONTEXT_NODE.
      DATA LO_EL_MAIN_NODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.
      DATA LS_MAIN_NODE TYPE WD_THIS->ELEMENT_MAIN_NODE.
      DATA LV_INP_VALUE LIKE LS_MAIN_NODE-INP_VALUE.
    * navigate from <CONTEXT> to <MAIN_NODE> via lead selection
      LO_ND_MAIN_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'MAIN_NODE' ).
    * get element via lead selection
      LO_EL_MAIN_NODE = LO_ND_MAIN_NODE->GET_ELEMENT(  ).
    * get single attribute
      LO_EL_MAIN_NODE->GET_ATTRIBUTE(
        EXPORTING
          NAME =  `INPUT_VALUE`
        IMPORTING
          VALUE = LV_INP_VALUE ).  "LV_INP_VALUE will have the value of inputfield
    Raja T
    Message was edited by:
            Raja Thangamani

  • Compound date (dd.MM.yyyy HH:mm) from two input fields

    Hi,
    I need to compound a date field in format dd.MM.yyyy HH:mm from two input fields(date and time field). I was trying a lot but could not get it to work. So right now I'm trying to start it simple but still have a couple of problems.
    1.) To start easy I wanted to fill a hardcoded date into my field.
    setAttribute(MYDATE, "01.01.2005 12:10");
    brings (java.lang.IllegalArgumentException) Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
    2.) setAttributeInternal(MYDATE, "01.01.2005 12:10");
    brings JBO-27018: AttrSetValException Cause: The type of attribute value provided as an argument to the set() method for this attribute is not an instance of the Java type that this attribute expects.
    3.) The thing that I reall need is something like:
    DateFormat sim = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    java.util.Date datum = new java.util.Date();
    try
    datum = sim.parse("01.01.2005 12:30");
    } catch (ParseException e)
    setAttributeInternal(MYDATE, datum);
    but right now this also ends with the JBO-27018
    I also did try different types (timestamp and date) in my entity object and different format masks. Not working at all. All the threads I found are pointing to articles from Steve, which are not available anymore (the links don't work). So any help is appreciated.
    Regards, Peter

    Thankyou for the hint. I get it to work with
    public void whatever
    DateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    java.util.Date javaDate = new java.util.Date();
    try
    javaDate = simple.parse("01.01.2005 12:30");
    } catch (ParseException e)
    java.sql.Timestamp sqlDate = new java.sql.Timestamp(javaDate.getTime());
    oracle.jbo.domain.Date nowDate = new oracle.jbo.domain.Date(sqlDate);
    setAttributeInternal(MYDATE, nowDate);
    but is there an easier and more 'beautiful' way to do this? Like using a date formatter on oracle.jbo.domain.Date instead using the SimpleDateFormat? btw. did I mention that I'm a Forms and PL/SQL programmer ;-)
    Regards, Peter

  • Capture value from the input field

    Hello All,
            I'm new to BSP.
    I have a small querry.
    I have a input field.
    beside this a push button.
    if i enter a value in the input field and press the push button, i need to capture the value from the input field and pass it to a variable contained in a class.
    i'm attaching the layout code here.
    but i'm not knowing what to write in the event(on input processing)
    <u><b>Layout code &#61664;</b></u>
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title        = "Page to take the value from the screen and pass to the class "
                  marginBottom = "100"
                  marginLeft   = "250"
                  marginRight  = "100"
                  marginTop    = "100"
                  scrolling    = " AUTO" >
        <htmlb:form>
          <htmlb:tray id        = "tray1"
                      hasMargin = "TRUE"
                      title     = "Value Capture"
                      width     = "350" >
            <htmlb:textView text      = "Enter a value"
                            design    = "emphasized"
                            textColor = "negative" >
            </htmlb:textView>
            <br>
            <htmlb:inputField alignment = "left"
                              id        = "gv_var"
                              required  = "true"
                              type      = "STRING"
                              design    = "standard" />
            <htmlb:button design  = "emphasized"
                          id      = "button"
                          text    = "SUBMIT"
                          onClick = "btn_click" />
            </br>
          </htmlb:tray>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    eventhandler&#61664;on input processing code
    DATA: event TYPE REF TO if_htmlb_data.
    event = CL_HTMLB_MANAGER=>get_event_ex( request ).
    IF event->EVENT_NAME = 'button' AND event->EVENT_TYPE = 'click'.
        ENDIF.

    HI BSPian,
        htmlb:inputField value = "<%= v_value %>"
                         id = "gv_var"
                         required = "true"
                         size = "10"
                         type = "STRING"
                         maxlength = "10"
                         design = "standard" />
    Here u mean to say that v_value must be one more field type string. is it so ?
    But i want to see the value in the same input field
    id ="gv_var". i.e if i enter the value "BSPian" in the input field and press "submit" the internal processing will be done as told by u and after that ,on the screen i want to keep that value till i end that session.
    i passed a variable v_value in the inputfield value but it's not working ..
    regards,
    deepu.

  • Leading Zeroes are lost when convert from string to int

    What I'm trying to do is simple yet the solution has seemed difficult to find.
    I have a system that requires 4 digit numbers as "requisitionNo". The system uses JSPs and accepts the 4 digit number that the user inputs (fyi - duplicate handling is already managed). The input number (rNumber) is of STRING type and in the action (using struts) is converted to an int:
    int requisitionNo = Integer.parseInt(rNumber);At that very line the issue is that when the user inputs a number with leading zeros such as: "0001" the 3 leading zeros are chopped off in the INT conversion. The application validation kicks in and says: "A 4 digit number is required" which is by design. The work around has been that the user has been putting in number that start with 9's or something like that, but this isn't how the system was intended to be used.
    How do I keep the leading zeroes from being lost instead of saving a number "1" to the database how do I keep it saving "0001" to the database? Would I just change everything to STRING on down to the database? or is there another number type that I can be using that will not chop off the leading zeroes? Please provide short code references or examples to be more helpful.

    Yeah, I have to agree here that leading zeroes make no sense. I figured that out when I started to look into this problem. The only requirement that exists is that the user wants it to be a 4 digit number due to some other requirement they have themselves.
    So what I'm gathering from what I've read in the responses thus far is that I should change the validation a bit to look at the STRING for the 4 required digits (which are really 4 characters; maybe I should add CLIENT side numeric validation; currently its doing server side numeric/integer validation; or maybe change up the server side validation instead???) and if they are ALL GOOD then let the application save the int type as it wants to. IE: Let it save "0001" as just "1" and when I come back to DISPLAY this saved number to the user I should append the string of "000" in front of the 1 for display purposes only? Am I understanding everyone correctly?

  • How to Remove Custom Tracking and Leading

    Hi, I am trying to edit a long document in InDesign which has already had a lot of custom tracking and leading applied to it in order to correct the "widows and orphans" in it. I want to remove all those custom changes in order to edit the text, and then reapply them as I reset the text in InDesign afterwards. Can someone tell me what is the easiest and quickest way of identifying and removing those custom changes (mainly tracking and leading) in InDesign?

    I want to remove all those custom changes in order to edit the text, and then reapply them as I reset the text in InDesign afterwards. Can someone tell me what is the easiest and quickest way of identifying and removing those custom changes (mainly tracking and leading) in InDesign?
    Well, assuming you want to reapply custom tracking & kerning manually, then
    Find any character  - ^? in the FInd window
    Leave the "Change to" field blank and specify Kerning of Metrics and Tracking of 0 in the "Change Format" area

  • Incoming calls get stripped of leading zeros and I don't know why...

    Hi,
    our UC560 setup is now running for quite some time. But there is still this one issue that is bugging for some time now. 
    We have two ISDN DID trunks for Incoming / Outgoing calls. 
    After my very basic setup I noticed that all caller IDs get their leading zero stripped. In Germany we use the "0" as first digit of the area-code and "00" as the international code.
    I thought a quick fix would be to just add a Call-Back Rule within CCA to add a leading 0. This works for national calls as the transmitted caller-id always includes the area-code even for local calls.
    However If I receive an international call (what happens quite often recently) I'm not getting the expected "00" in front of the number but also only a single "0".
    I took a look at all translation-rules that are configured, but I couldn't find any rule that just deletes all leading zeros from the incoming number :( What's happening there?
    voice translation-rule 4
    rule 1 /301/ /55555529/
    rule 2 /302/ /55555529/
    rule 13 /^2\(..\)$/ /5555552\1/
    rule 14 /^1\(..\)$/ /5555551\1/
    rule 15 /^.*$/ /+49895555550/
    voice translation-rule 5
    rule 15 /^...$/ /123456/
    voice translation-rule 7
    rule 1 /555555201/ /201/
    rule 2 /555555202/ /202/
    rule 3 /555555203/ /203/
    rule 4 /555555204/ /204/
    rule 5 /555555205/ /205/
    rule 6 /555555206/ /206/
    rule 7 /555555207/ /207/
    rule 8 /555555208/ /208/
    rule 9 /555555209/ /209/
    voice translation-rule 8
    rule 1 /555555210/ /210/
    rule 2 /555555211/ /211/
    rule 3 /555555212/ /212/
    rule 4 /555555213/ /213/
    rule 5 /555555214/ /214/
    rule 6 /555555215/ /215/
    rule 7 /555555216/ /216/
    rule 8 /555555217/ /217/
    rule 9 /555555218/ /218/
    rule 10 /555555219/ /219/
    voice translation-rule 9
    rule 1 /555555220/ /220/
    rule 2 /555555221/ /221/
    rule 3 /555555222/ /222/
    rule 4 /555555223/ /223/
    rule 5 /555555224/ /224/
    rule 6 /555555225/ /225/
    rule 7 /555555226/ /226/
    rule 8 /555555227/ /227/
    rule 9 /555555228/ /228/
    rule 10 /555555229/ /229/
    voice translation-rule 10
    rule 1 /55555529/ /511/
    voice translation-rule 12
    rule 1 /55555504/ /112/
    voice translation-rule 13
    rule 1 /555555260/ /996/
    voice translation-rule 14
    rule 1 /55555501/ /444/
    voice translation-rule 15
    rule 1 /55555502/ /111/
    voice translation-rule 18
    rule 1 /555555200/ /444/
    voice translation-rule 19
    rule 1 /555555100/ /444/
    voice translation-rule 20
    rule 1 /55555500/ /444/
    voice translation-rule 21
    rule 1 /5555550/ /444/
    voice translation-rule 23
    rule 1 /555555110/ /110/
    rule 2 /555555111/ /111/
    rule 3 /555555112/ /112/
    rule 4 /555555113/ /113/
    rule 5 /555555114/ /114/
    rule 6 /555555115/ /115/
    rule 7 /555555116/ /116/
    rule 8 /555555117/ /117/
    rule 9 /555555118/ /118/
    rule 10 /555555119/ /119/
    voice translation-rule 24
    rule 1 /555555120/ /120/
    rule 2 /555555121/ /121/
    rule 3 /555555122/ /122/
    rule 4 /555555123/ /123/
    rule 5 /555555124/ /124/
    rule 6 /555555125/ /125/
    rule 7 /555555126/ /126/
    rule 8 /555555127/ /127/
    rule 9 /555555128/ /128/
    rule 10 /555555129/ /129/
    voice translation-rule 25
    rule 1 /555555130/ /130/
    rule 2 /555555131/ /131/
    rule 3 /555555132/ /132/
    rule 4 /555555133/ /133/
    rule 5 /555555134/ /134/
    rule 6 /555555135/ /135/
    rule 7 /555555136/ /136/
    rule 8 /555555137/ /137/
    rule 9 /555555138/ /138/
    rule 10 /555555139/ /139/
    voice translation-rule 26
    rule 1 /555555140/ /140/
    rule 2 /555555141/ /141/
    rule 3 /555555142/ /142/
    rule 4 /555555143/ /143/
    rule 5 /555555144/ /144/
    rule 6 /555555145/ /145/
    rule 7 /555555146/ /146/
    rule 8 /555555147/ /147/
    rule 9 /555555148/ /148/
    rule 10 /555555149/ /149/
    voice translation-rule 27
    rule 1 /555555150/ /150/
    rule 2 /555555151/ /151/
    rule 3 /555555152/ /152/
    rule 4 /555555153/ /153/
    rule 5 /555555154/ /154/
    rule 6 /555555155/ /155/
    rule 7 /555555156/ /156/
    rule 8 /555555157/ /157/
    rule 9 /555555158/ /158/
    rule 10 /555555159/ /159/
    voice translation-rule 28
    rule 1 /555555160/ /160/
    rule 2 /555555161/ /161/
    rule 3 /555555162/ /162/
    rule 4 /555555163/ /163/
    rule 5 /555555164/ /164/
    rule 6 /555555165/ /165/
    rule 7 /555555166/ /166/
    rule 8 /555555167/ /167/
    rule 9 /555555168/ /168/
    rule 10 /555555169/ /169/
    voice translation-rule 29
    rule 1 /555555170/ /170/
    rule 2 /555555171/ /171/
    rule 3 /555555172/ /172/
    rule 4 /555555173/ /173/
    rule 5 /555555174/ /174/
    rule 6 /555555175/ /175/
    rule 7 /555555176/ /176/
    rule 8 /555555177/ /177/
    rule 9 /555555178/ /178/
    rule 10 /555555179/ /179/
    voice translation-rule 30
    rule 1 /555555180/ /180/
    rule 2 /555555181/ /181/
    rule 3 /555555182/ /182/
    rule 4 /555555183/ /183/
    rule 5 /555555184/ /184/
    rule 6 /555555185/ /185/
    rule 7 /555555186/ /186/
    rule 8 /555555187/ /187/
    rule 9 /555555188/ /188/
    rule 10 /555555189/ /189/
    voice translation-rule 31
    rule 1 /555555190/ /190/
    rule 2 /555555191/ /191/
    rule 3 /555555192/ /192/
    rule 4 /555555193/ /193/
    rule 5 /555555194/ /194/
    rule 6 /555555195/ /195/
    rule 7 /555555196/ /196/
    rule 8 /555555197/ /197/
    rule 9 /555555198/ /198/
    rule 10 /555555199/ /199/
    voice translation-rule 1000
    rule 1 /.*/ //
    voice translation-rule 1112
    rule 1 /^8/ //
    voice translation-rule 2001
    voice translation-rule 2002
    rule 1 /^6/ //
    rule 2 /^A/ //
    voice translation-rule 2222
    regards,
    Fabian

    I already figured it out myself - that was easy, if you know where to look...
    voice translation-rule 3265
    rule 1 /\(^.*$\)/ /0\1/ type national national
    rule 2 /\(^.*$\)/ /00\1/ type international international

  • How to remove the extra or blank space from RTF Template

    Hi All,
    Try to remove the extra space from  xml template.
    Here I have attached the .xml file with .rdf, here the issue is when you load the data we will get 2 page output but when I am trying to add any column or extra space in the last page of this template the output getting 4 pages with lot of blank space. Could you please guide me to solve this issue.
    Could you please let me know how to do the attachement in this forum as I am new to this community.
    Regards,
    Sushant

    Can you drop in a mail with RTF, xml data to [email protected], I will help you on the issue.

Maybe you are looking for

  • How to make audio playback auto stop

    Hello! I am creating a widget for iBook that will be a cooking instruction step-by-step slides for the user to follow. I used the 'Gallery' object to create the slides so each step is a cell in the gallery, and the user can swipe left/right for the n

  • User Role with All MM Transaction codes

    Hi SAP Gurus, I need to create a User role with all MM transactions.  Can anyone please let me know whether Standard User role is available which has authorisations for all MM transaction codes ?  If yes, what is the User role name.  If not, what is

  • Userprefs don't depend on primary group?

    I have users (student1, student2, etc) setup in two groups each, (their grade: ie, "Grade3", and "Students")   For this problem, it doesn't matter what primary group I set for them.  They are asked upon logon, to choose "grade3" or "students" as thei

  • 7.1 audio mixing in Premiere?

    Our client has a large amiptheater with a 10,000 lumen HD projector and 7.1 surround sound setup.  They would like for us to produce a Blu-ray with 7.1 audio.  We have delivered a 5.1 surround Blu-ray to them, but I'm not sure if Premiere Pro is able

  • IMovie included in osx 10.9.1

    Hi i upgraded my imac late 2012 to OSX 10.9.1. My imac doesn 't show imovie and ipage on the tool bar. Are these 2 software should include in OSX for free ? Please advise. Thank you.