Removing Leading And trailing Zeros

Hi Guys ,
Can You help me out in UDF for removing leading and Trailing zeros
Ex :  0123.234000000
And it must satisfy below conditions .
1 ) If value as Null we need 0.0 in target
2) if the value is 0.0 we need 0.0 in target
Thanks in Advance

One more option:
Input will be "str" of type string.
Execution type: single value.
mapping:
Input -> mapwithdefault(0.0)->UDF->output
if( !str.equals("0.0"))
char[] chars = str.toCharArray();
for (int index=0; index < str.length();index++)
if (chars[index] != '0')
str =str.substring(index);
break;
int length,index1 ;
char[] chars1 = str.toCharArray();
length = str.length();
index1 = length -1;
for (int in1=index1-1; in1>0;in1--)
if (chars1[in1] != '0')
str=str.substring(0,in1+1);
break;
return str;
else
return "0.0";
http://wiki.sdn.sap.com/wiki/display/Java/RemoveLeadingandTrailingZerosfroma+String

Similar Messages

  • Removing leading and trailing delimiters from a String

    I need to remove leading and trailing delimiters from a String like if my string is 111,112, then it should get changed to 111,112.Any idea how to do this??

    for my suggestion:String s = "111,112,";
    int begin = 0;
    while (!Character.isLetterOrDigit(s.charAt(begin)))
         begin++;
    int end = s.length() - 1;
    while (!Character.isLetterOrDigit(s.charAt(end)))
         end--;
    String news = s.substring(begin, end + 1);Of course, you'll have to clean it up a bit.

  • Apex: Removing leading and trailing blanks

    Hi,
    when observing end users working with my little apex application I noticed the input of leading and trailing blanks in a report search field. What do you recommend for removing this undesired input?
    I tried an ltrim(rtrim(:p1_searchfield)) in the report SQL query - the result is fine.
    But I have not found a way to keep the higlighting of the search word in the result set. There is a "highlight" property in the report field attributes dialog. But it looks like there is no way to enter any trim funtion over there. So the highlighting of matches does not work if there is a leading or trailing blank.
    Any ideas?
    Thanks & Cu
    Walter

    Walter,
    I would use an "after submit" computation on :p1_searchfield
    trim(:p1_filter)This way you won't have to change your select statement and the highlight term.
    ~Dietmar.

  • REGEXP_REPLACE removing leading and trailing quotes.

    Hello guys,
    I have an issue with my regular expression and I'm hoping that someone can help me with it?
    Imagine the following sample_data:
    {code}
    WITH sample_data AS
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]' as e FROM dual UNION ALL
    SELECT '[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]' as e FROM dual
    SELECT e, REGEXP_REPLACE(e, '(^'')?(.*)(''$)', '\2')
      FROM sample_data;
    {code}
    I would like to remove all leading and trailing quotes from the address email. I did the previous regexp but it does not returns the correct result. I don't know why, but for some reasons, when my email does not ends with a quote, the leading quote is not removed.
    Can anyone help me with this?
    Thanks,

    Cant you just trim it?
    WITH sample_data AS
    SELECT '''[email protected]'''      as e FROM dual UNION ALL
    SELECT '''[email protected]'        as e FROM dual UNION ALL
    SELECT '[email protected]'''        as e FROM dual UNION ALL
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '[email protected]'''   as e FROM dual UNION ALL
    SELECT '''[email protected]'   as e FROM dual
    SELECT e, rtrim(ltrim(e, ''''), '''') new_e
      FROM sample_data;

  • Remove leading and trailing puncation

    What's the best way to remove leading/trailing puncation from a word? Trim is good for leading and trailing whitespace but can I do anything for leading and trailing punctuation. I need punctuation that's in the middle of a word.

    one way would be to create an array of characters that include all the common punctuation marks. Then, using an iterative loop, compare each char in the file with each char from the array. If a match is found, then the file char is punctuation.

  • Unix Flat File: Remove header and trailer and put in another file.

    Hi,
    I have Source Flat File placed on Unix Box with header and trailer.
    I want to remove Header and Trailer and put in some other file and Data in another file.
    I tried following command in unix its working.But not getting Header and Trailer in another file.
    sed '1d;$d' input_source.txt > output_data.txt
    also How will i use OS command for it in ODI.
    Guide me.
    Thanks
    Ashwini

    Hi Ashwini,
    You can run OS commands in a package using an ODI Tool: OdiOSCommand.
    It is also possible to execute OS commands in an ODI procedure using the Operating System or Jython technologies.
    There should be some articles about this on metalink (http://metalink.oracle.com).
    Thanks,
    Julien

  • Hex to binary removes leading or trailing 0's

    hi,
    i'm trying to get a hex to binary conversion.  i am using a hex string to number conversion with the setting at binary, but it is deleting my leading zeros.
    for example if i put in a 7 hex, i get 111 instead of 0111.  or if i put in a 0 hex, i get 0 intead of 0000.  i understand it is equally the same thing but the interface i am communicating with is expecting all digits.
    thanks,
    Attachments:
    hex2bin.vi ‏7 KB

    Hi lfoitek,
    choose binary display, set the number of bits to show and select "fill with zeros at left"!
    Message Edited by GerdW on 02-08-2008 04:50 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    hex2bin.vi ‏7 KB

  • Leading and trailing 0's in Address Book???

    I get a string of 0's after phone numbers in my address book.  I transferred my addres book from a Treo 650 to my AT&T Centro. It seems that there are random 0's in the data and I can's seem to get rid of them.
    Does anyone else have this issue???
    Tom
    Post relates to: Centro (AT&T)

    I just tried the trial of DbFixIt and it detected NO errors in Contacts and only fouund errors in my calendar.
    Other suggestions???
    Would really like to get rid of these zeros!
    Thanks,
    Tom
    Post relates to: Centro (AT&T)
    Post relates to: Centro (AT&T)

  • Removing Commas and after zeros

    Hi Experts,<br />
    <br />
    If user enters the values like 56.879.809,00 for me it should take 56.879.809 if user enters the value as 56.879.809,00 use error message.I want to delete the data including comma as well as zeros ",00" in value.This is in Module pool program designing.How to build the logic for this help me for this solution.<br />
    <br />
    <span style="color:red">Moderator Message: Please continue with the previous post Validating the particular value for a particular currency.</span>
    Edited by: Suhas Saha on Sep 29, 2011 1:02 PM

    assign ur value to a variable (lv_gross1)
                    lenght = strlen( lv_gross1 ).
                    search lv_gross1 for ','.
                    if sy-subrc eq 0.
                      if sy-fdpos > 0.
                        move lv_gross1+0(sy-fdpos) to lv_gross.
                      endif.
                    endif.
    it will remove ,00 from ur number.
    Thanks,
    Giridhar

  • Simple transformation dropping trailing zero.

    Hi experts.
    I am having a problem with my transformation file, and I was hoping someone could help me.
    I have created a simple transformation file, with a variable using the type of "DMBTR" which Does have 2 decimal points.
    IF I have data - the two decimal points print.
    EG if the amount is 100.57..    I get the 100.57 to print which is what I need and expect.
    BUT.
    IF the amount is 100.50    I am getting 100.5    Is is dropping the final zero amount, and therefore is failing in the validation.
    HOW can I FORCE the two decimal points to print?
    I have even tried it where I declare it as a variable of type "I" with 2 decimal points, and it still does not work.
    I can not figure out how to use the Number format   option with a Value-ref print line.
    If someone could help me with that.. I could try that to see if it worked.
    thank you.
    eg: of the way the data is declared:
      <tt:type name="GRTOT14" type="I" length="13" decimals="2"/>
    OR
      <tt:type name="GRTOT16" type="ddic:DMBTR"/>
      <tt:type name="GRTOT17" type="ddic:DMBTR"/>
    eg: of the way I am using it where I am getting only one decimal place if the 2nd decimal place is ZERO
                 <tot_grnt_sbsdy_amt tt:value-ref=".GRTOT14"/>
                   <tot_insu_prcd_amt tt:value-ref=".GRTOT16"/>
                  <tot_opay_rcap_amt tt:value-ref=".GRTOT17"/>
    PLEASE HELP.
    thank you.

    From what I understand about XML (could be more), the canonical representation of decimal values does not allow a fixed number of decimal places.
    SAP documentation:
    http://help.sap.com/saphelp_nw04/helpdata/en/52/491a40251e2402e10000000a1550b0/frameset.htm
    from there, this XML documentation is referenced:
    http://www.w3.org/TR/xmlschema-2/#decimal
    important bit:
    Leading and trailing zeroes are prohibited subject to the following: there must be at least one digit to the right and to the left of the decimal point which may be a zero.
    You already discarded my workaround: using a character or string type field and fill it to your liking prior to serialisation.
    Thomas

  • How to prohibit leading and traling whitespace in XML Schema

    I want to prohibit the use of leading and trailing whitespace in an element but besides that all other content is allowed.
    For examble <   word? > should give a validation error.
    I do not want to use
    <whiteSpace value="collapse"/>
    Because it doesn't give a validation error.
    Is it possible to make a pattern og in some other way solve my problem?
    Thanks in advance, Martin

    Here is an example schema snippet (not a complete schema!) that does what you want I think, using a regular expresssion pattern, allowing one or more non-white-space characters followed by an optional sequence of any character followed by one or more non-white-space characters:
    Code Snippet
            <xs:element name="foo" maxOccurs="unbounded">
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:pattern value="\S+(.*\S+)*"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
    Here are some example elements with valid contents:
    Code Snippet
      <foo>a</foo>
      <foo>a b</foo>
      <foo>a b c d e f g</foo>
    And here some elements with invalid contents that validation would catch:
    Code Snippet
      <foo> a</foo>
      <foo>a </foo>

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

  • Function mudule to remove leading zeros of curreny and decimal type field

    Hi Expers,
    can any body suggest me the function mudule to remove leading zeros of curreny and decimal type  fields.
    plz do reply as early as possible.
    Thanks .....
    sunil.

    Hi,
    Use this FM CNIF_CONVERT_CURRENCY2EXT
    Import parameters               Value
    I_CURRENCY                      USD
    I_AMOUNT                        00000001233
    I_DECIMALS                      2
    Export parameters               Value
    E_AMOUNT                                           1.233,0000
    Regards
    Shiva

  • Add and remove leading zeroes

    Hi all,
           Iam having a requirement where in a enduser enters the vendor number and after pressing enter key it should display the vendor num along with vendor name concatenated in the same field. But the end user is provided the facility that he may not enter the exact vendor number ( I mean if vendor number is for example 0000055,  the enduser may enter simply 55). The system should convert it with leading zeroes internally. And in display it should display removing leading zeroes.
    like     input:  55              output : 55 Vendor_Name
    my approach
    iam using conversion_exit_alpha_input    for adding leading zeroes       before select query ( to fetch the vendor name for vendor number the user supplies)
    before displaying the output after concatenation,
    iam using  conversion_exit_alpha_output.
    after execution,
    it is asking the exact vendor number .  But in the output, it is giving the vendor number along with vendor name by removing leading zeroes ( as expected).
    how to make the system accept the number without leading zeroes. please suggest me.
    tthanking you in advance
    regards
    Bikash

    Hi Bikash,
    Since you have to display the Vendor number concatenated along with the Vendor Name, why do you need to use the Alpha Exit Function Module. As you have the Vendor number without the zeros in the input field, you can store it in a temporary variable and then once the Vendor name is available you can concatenate it along with the number in the same field.
    If you need a code snippet, you can provide the Technical details of the fields of input. We can use the implicit ABAP    type casting feature to get the Vendor Number without any leading zeros.
    Hope this helps.
    Thanks,
    Samantak.

  • 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

Maybe you are looking for

  • Dual DVI video card

    Have a P7-1280t - i5-2320 QUAD 3.0GHZ 6GB Would like to have a dual DVI setup since I have two monitors.  I had a Nvidia Qaudro card laying around...tried it but it's looking for that additional power source for the card and the powersupply doesn't h

  • Header text not displayed in quotation

    Dear all , I am using standard form for quotation printing but the text i enter in quotation header it is not getting displayed in the standard layout of the quotaion . is there any settings i need to do . pls advise Ramar

  • Oracle equivalent of a variable in MS SQL Server

    Hi, I need the equivalent sql statement in oracle... Sounds real simple, but I cant seem to the the Oracle syntax (MS SQL syntax) declare @id integer set @id = (select min(tranid) from tbltransaction) select * from tbltransaction where tranid = @id A

  • How to differentaite between material created on & material changed ??

    Hi all,         How to differentiate between material created and material changed??? is there any flag or indicator present to differetiate between two....please guide me. Thanks, Ashu

  • "NOT IN" REPLACE WITH "MINUS"

    I have 2 questions for this SQL Statement for tuning? select from a where id*_+ not in (select a_id from b)_+ 1- How do i change this query with A MINUS OPERATOR 2- Shall i use USE_NL() Hint or another hint for this query? Do you have an idea? BR,