Removing leading zeros from a string value

Hi All,
i have a Requirement like , i need remove leading zeros from a string value,
like , 00Raj00Shekar==>Raj00shekar,
how can i do this ?
if it is only with the custom functions ,where can add the fuction in Jdeveloper and SOA Middle ware?
Thanks in Advance,
Raj

Hi Raj,
you can use below function to get the desired output in xsl.
<xsl:value-of select='translate(oraext:left-trim(translate(<inpString>,"0"," "))," ","0")'/>
HTH,
Regards,
Vikas Manchanda

Similar Messages

  • 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

  • How to remove leading zeros from a string

    Hi,
    I have a situation here where i need to remove the leading  zeros from the incoming data.
    i.e if 0009 then it should be taken as 9
       if 0230  it should be taken as 230
    Regards,
    Ashish

    Hi ,
    Write UDF to parse data .
                    String dataVal="0230";
              int parseVal = Integer.parseInt(dataVal);
              System.out.println("parseVal is "+parseVal);
    result.addValue(parseVal); or return parseVal;
    Nanda

  • Conversion routine to remove leading zeros from nonnumeric values.

    Hi,
    Can anybody tell me any conversion routine while can remove leading zeros from a character value.
    Eg : 
    input : asdfe
            output : 0000asdfe and vice versa
    I tried with Alpha conversion routine but that is useful only with numeric values.
    Please help.
    Regards,
    Deepti Jain.

    Hi,
    See the following program, and the same logic you can apply in Transfer Rules/Transformations. Take ABAPer help.
    REPORT  ZALPHA_INPUT.
    DATA: ZI(18) TYPE C,
          ZO(12) TYPE C.
    DATA: ZS(12) TYPE C,
          ZR(18) TYPE C.
          ZI = '000000099999889925'.
          ZS = '099999889925'.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT         = ZI
       IMPORTING
         OUTPUT        = ZO.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT         = ZS
       IMPORTING
         OUTPUT        =  ZR  .
    Write:/   ZI.
    Write:/   ZO.
    Write:/   ZS.
    Write:/   ZR.
    Thanks
    Reddy

  • Remove leading Zeros from the mapped context node(Table)

    HI,
    I have he following requirement:
    In the Leave approval application , in the Approver worklist we have the coloumn to display the resuqester's Perner.
    The perner starts with leading zeros. We have to remove these leading zeros.
    I have refer the following threads:
    Removing leading zeros in a column
    How to remove leading zeroes of string
    and wiki document:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/java/remove%252bleading%252band%252btrailing%252bzeros%252bfrom%252ba%252bstring
    but I am not able to create the calculated attribute in the Mapped Node( NWDS is not allowing indicating it is not allowed for mapped nodes.)
    Any pointer how I can remove leading Zeros from existing column?
    If I create the calculated attribute outside the mapped node then it is taking only the first value of the mapped node.
    Please note we do not want to modify the RFC.
    _vishal

    Hi,
    Thanks for inputs,
    Now I created a test application where the original structure is as follows in the View Controller:
    1) Context -> Z_Portal_Test_Input (mapped Node/folder) -> IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)
    note: this attribute Eid has the values (01, 02,03,04,05)
    2)Context -> Z_Portal_Test_Input (mapped Node/folder) -> Output(mapped Node/folder) ->IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)
    Now as per your suggestion I created another node like this
    Context -> Z_Portal_Test_Input (mapped Node/folder) ->testnode(value node) ->testValue(value attribute)
    testnode cardinality is 1..1 and singlton = false
    In the Layout
    The tablecell editor  of one coloumn is mapped to text     Z_Portal_Test_Input.testnode.testvalue
    It is expected that this will show the values like(1,2,3,4,5) but it is showing value(1,1,1,1,1)
    The code of get method is:
      public java.lang.String getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement element)
        //@@begin getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement)
          String  msg =wdContext.nodeZ_Portal_Test_Input().nodeOutput().nodeIt_Itab().currentIt_ItabElement().getEid();
            return removeLeadingZeroes(msg);
        //@@end
    the functon removeLeadingZeroes(msg) is implemented as per the wiki link.
    What wrong I am doing/ missing....
    _vishal

  • How to remove leading zeros from variable

    hi,
       how to remove leading zeros from variable like it_vbap-matnr.
    value in it_vbap-matnr is 000000000000000358
    i want to remove leading zeros so that it become 358
    regards
    deepak

    You can use Function Module <b>'CONVERSION_EXIT_MATN1_OUTPUT'</b>
    This Function Module will eliminate leading Zeros.
    For each MATNR Value read form DB Table,u can eliminate Leading zeros and then modify ur Internal table.
    I think u will not get leading Zeros into utr Internal table when u read from VBAP.
    Bcoz MATNR in VBAP itself have Conversion routine.
    If u r getting leading zeros,U can use following Logic.
    tables:
      vbap.
    data:
       t_vbap like standard table of vbap.
    select matnr
    from vbap
    into corresponding fields of table t_vbap.
    loop at t_vbap into vbap.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
          EXPORTING
            INPUT         =  vbap-matnr
          IMPORTING
            OUTPUT        =  vbap-matnr
      modify t_vbap from vbap transporting matnr.
    endloop.
    Hope this will work.....

  • Removing Leading zeros from query output.

    Hello Experts,
    Is it possible to remove leading zeros from the query output for a particular column?
    I have a characteristics 'Reference Document' which has values like '000001386'. The users just need '1386' to be displayed and have asked us to remove the leading zeros.
    Is there something that can be done for this at a query level? I can't modify the underlying InfoProvider because this requirement is just for one set of users, the other users need the document nmber in the original format.
    Thanks
    Arvind

    Hi,
    you can use ALPHA conversion option in the definition of that particular characteristic.
    Try this code  in a routine.,in query designer;
    data a(9) value '000001386'.
    SHIFT a LEFT DELETING LEADING '0'.
    write:/ a.
    Output will be : 1386
    Or use this method also
    data a(9) value '000001386'.
    Call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
    Exporting
    input = a
    Importing
    output = a.
    write a.
    output:
    1386
    Regards
    CSM Reddy

  • How to remove leading zero from Material Number

    Hello Everyone,
    I need to figure it out how to remove leading zero from material number. Cureently extractor is sending material number as 100663. But when comes into BI i am getting as "000000000000100663" and similariy in report it is appearing as "000000000000100663". Now my client wants me to exclude preceeding zero for a material in all the reports.
    Is there any setting in query desinger to handle this issure or in the backend.
    Need your inputs.
    Thanks,
    Lasya.

    Hi
    you can use the function Module
    CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
    to test this go to SE37  --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
    >display -
    > F8
    in the input give 000000456
    and execute
    the out put will be 456
    for getting Zeros you can use
    CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
    Santosh
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM

  • 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...

  • Remove Leading zeros from column

    How can I remove leading zeros from a column?
    The data looks like *00-04-071*
    The output should display 4071

    user10876532 wrote:
    How can I remove leading zeros from a column?
    The data looks like *00-04-071*
    The output should display 4071try
    select to_number(replace('00-04-071','-','')) from dual

  • I want to remove Trailing zeros from a charecter value

    Hello ,
              i want to remove trailing zeros for a prticular value.Following is my code :
    DATA: V_FLOAT TYPE F VALUE '4.8240000000000000E+03',
               V_CHAR(25) ,
               P10_4(10) TYPE P DECIMALS 4.
    CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
    EXPORTING
    FLOAT_IMP = V_FLOAT
    FORMAT_IMP = P10_4
    ROUND_IMP = ' '
    IMPORTING
    CHAR_EXP = V_CHAR.
    SHIFT V_CHAR RIGHT DELETING TRAILING '0'.
    WRITE : V_CHAR ."NO-ZERO.
    <u><b>Output:</b></u>
    if we pass the value '1.3000000000000000E+01' it should be 13.0
    ex2: '1.3400000000000000E+01' it should be 13.4
    ex3:'4.8240000000000000E+03' it should be 4824
    is there any way to get the solution without functional module. If so Please tell me with code.

    hi
    u can do it in number of ways.
    Use TCODE SU3
    Select default tab and select radio button 123467.89 in decimal notation and save it.
    or u can try :
    if you want to do this through ABAP program.
    1. to delete trailing spaces.
    SHIFT <V_VARIABLE> RIGHT DELETING TRAILING '0'.
    to delete leading zeroes,
    SHIFT <VARIABLE_NAME> LEFT DELETING LEADING '0'.
    only for one abap program, u can use set country command
    for all programs :
    sap menu>system->go to user profil->own data>default --> and choose ur format.
    hope this helps u.
    Regards,
    Prasanth
    Reward all hepful replies

  • BAPI to remove leading zeros from the serial number

    Hi All ,
    plz can anybody suggest me the alternative BAPI for 'BAPI_SERVNOT_MODIFY_DATA ',whose function is to delete the leading zeros,from the serial number.
    Thanks.

    Perhaps instead of using a BAPI you can code it like this.
    DATA:serial(10) TYPE n VALUE '0000340078',
    pos TYPE i VALUE 1.
    START-OF-SELECTION.
      WHILE pos <= 10 AND serial+pos(1) = 0.
        pos = pos + 1.
      ENDWHILE.
      REPLACE ALL OCCURRENCES OF '0' IN serial(pos) WITH space.
      WRITE serial.

  • Remove leading zeros from string

    I am working on a report and I am having a little issue with the output.
    I have several dollar amount fields that I need to format with only the decimal place. The amount fields are coming in as strings between 10-16 characters.
    I could not find a way to use the currency formatter so I used substrings to break it apart and put it back together in the format I need. However I am now running into an issue with leading zeros. I can't used ReplaceAll as there is a possibility of having a 0 in the amount field.
    Here is what I have done for the substrings:
    int intLength = strField.length();
    intDollar = intLength - 2;          
    strDollar = strField.substring(1, intDollar);
    strCent = strField.substring(intDollar, intLength);
    System.out.println(strDollar + "." + strCent);The original string: 0000000037049469
    My output now: 00000000370494.69
    Desired output: 37049469
    Any suggestions on how to remove the leading zeros?
    Edited by: xxwhocaresxx on Jun 10, 2009 12:11 PM

    804350 wrote:
    Just wanted to comment that I solved the issue differently by casting the string value to an integer and back. Don't know if it's bad solution performancewiseNever, ever, ever, ever, ever, ever, ever worry about performance. At least not until you're much further along the road; and even then not until you've proved that it's inadequate.
    but it's quite compact and readable and did the job of eliminating leading zeros.I suspect you'll also find that it has the great advantage of providing you with a dollar (or cent) value that you can use elsewhere in your program the way it was intended.
    example:
    String noZeros = String.valueOf(Integer.parseInt(stringWithZeros));Or possibly even more usefully:
    int cents = Integer.parseInt(stringWithZeros);
    String noZeros = String.valueOf(cents);I'd also suggest looking up the NumberFormat and DecimalFormat classes, and PrintStream.printf(); all very useful for what you're trying to do.
    Winston

  • Remove leading zeros from html template

    Hello,
    I have modified HTML template SAPLBBP_SOCO_UI_ITS to add the ordered product to the Sourcing Cockpit screen.  This data has leading zeros in the database; how do I prevent them from showing up on the screen?
    My Business HTML skills are novice; so any help is appreciated!
    Thanks in advance.

    Hi Joyce,
    Thanks for your last answer that allowed me resolving same kind of issue.
    My issue was to prevent 0 from being displayed in 3 character string for percentage. example :
    001 -> 1
    020-> 20
    There was no other way as "write" or "shift" statements working on abap side never transferred correctly on html display side
    For code example here is mine :
    `v_val = GT_SCREEN_ITM-ZZPERCENTAGE[j].value`
    `if ((strsub (v_val, 1, 1 ) == "0") && (strsub (v_val, 2, 1 ) == "0"))`
    `v_val = strsub (GT_SCREEN_ITM-ZZPERCENTAGE[j].value, 3, 1)`
    `elseif (strsub (v_val, 1, 1 ) == "0")`
    `v_val = strsub (GT_SCREEN_ITM-ZZPERCENTAGE[j].value, 2, 2)`
    `end`
    `v_val`
    for more details here is the url of saphelp :
    http://help.sap.com/saphelp_45b/helpdata/en/7e/031fa404dd11d2801d00c04fadbf76/frameset.htm
    Regards,
    Laurent.

  • How to remove leading zeros from the screen?

    Hello friends,
    I am working on dialog programming.
    I have a field with is NUMC 13. so when value is populated, It removes the leading zeros.
    How can I display the my value with leading zeros on the screen painter?

    Call SE51, layout, double-click on field, attributes, tab Program, check Leading zeros.
    Regards,
    Raymond

Maybe you are looking for

  • Photo Transfer from PC to Apple TV

    How do I transfer photos from my PC (windows vista) to Apple TV. Apple TV only seems to recognize photos in Photo Stream and I can not find a way to put existing photos into Photo Stream (only new ones taken after photo stream was set-up).

  • HT3176 How do you use the submit command?

    HOw do I use the Apple TV remote to submit after typing?

  • Can't disable Web Address Auto-complete in Safari nor Firefox

    Hi there, I am trying to disable the web address auto-complete in order to access my Intranet Server. I tried configuration inside Web Browser (firefox) but doesn't work. Seems to be system configuration since is the same with Safari. If I enter the

  • Live Encoder as a windows service

    Can Live server be ran as a windows service?

  • CompareTo method to compare files

    I have to compare each line from two files and say whether the lines are different or not. I don't exactly understand how to use the compareTo method in this type of situation. I'd appreciate any help. import java.util.*; import java.io.*; import jav