To trim leading zeroes

Hi,
I need to trim the leading zeroes from my field.
Eg: I am taking the field length as 6, but if my value is only of 4 digits then its coming as 004216.
I need this value to be 4216 only.
I cant change the field length to 4 as there may be values that may be more then 4 upto 6 digits.
Kindly help.
Thanks,
Manish

Hi,
You Can use the function module.
  CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'
  CHANGING
    C_FIELD       = IT_LIPS-MATNR.
using above FM you can pass the material number, then execute above FM get deleting with leading zeros.
Tanks surendar

Similar Messages

  • Procedure or function to trim leading zeros

    Hi!
    I need to create a procedure or function that can trim the leading zeros of a value (character string).
    I.e.
    Original: 0000012345,67
    Output: 12345,67
    Thanks for any ideas/examples!
    Edited by: user545194 on 21.06.2010 07:33

    user515689 wrote:
    What about the opposite of this? Needing to pad zeroes on values?
    i..e make 867 00867?
    How can that be done?
    Any tips?
    Thanks.If the value is a number, then use to_char and specify a format mask...
    SQL> select to_char(867,'fm09999') from dual;
    TO_CHA
    00867

  • Remove leading zeros coming from Active Directory

    Greetings all.  Our sapusername is stored in Active Directory with leading zeros.  Is there a way to remove these zeros in the portal so SSO will work?  I have had my AD team manually remove the zeros in front of my sapusername, so I'm sure that's the issue.
    Alternately, is there a setting in R3 that would allow leading zeros?

    Hi,
    I've seen the problem before and I think you only have two choices (haven't looked into if R3 can accept leading zeros)
    1. Since you are allready retrieving sapusernames from an R3 change that mapping to remove leading zeros and possibly put it in a new attribute.
    2. Create a JAAS login module which retrieves found username from the HeaderVariableLoginModule and trims leading zeros before putting the username back to shared state. This new LoginModule must be placed before the CreateTicketLoginModule.
    Note it is not very trivial to create a JAAS login module but an excellent guide can be found here http://help.sap.com/saphelp_nw2004s/helpdata/en/46/3ce9402f3f8031e10000000a1550b0/frameset.htm

  • APD - How to remove leading zero's in a String?

    Hello All,
    I have been stumped by this challenge for a few hours now, so would appreciate your suggestions.
    I am using APD to produce a CSV file where the source is a query. The output requires 0MATERIAL and this is delivered by the source query. The issue is that the CSV file must not retain any leading zero's that may exist in the 0MATERIAL value.
    e.g.
    example #      original material code     desired output
    =========     ======================     ==============
    a            000000000000015931      15931
    b            000000000001001037      1001037
    c            000000000008945420      8945420
    d            000000000080889200      80889200
    e            0000000000L0293500      L0293500
    Initialy, I believed I could simply output the value of 0MATERIAL to an integer field. This would remove all leading zero's but not all 0MATERIAL codes are purely numeric in value (see example (e));
    Someone had a similar requirement w/ SQL Server and solved it by replacing all zero's with a space, trimming leading spaces, then replacing remaining spaces back to zero's! [url]http://www.sql-server-helper.com/functions/trim-leading-zeros.aspx[url]
    So the logic is something like this:
    1. Replace each 0 with a space: REPLACE('0','',[0MATERIAL])
    2. Use the L_TRIM string function to trim leading spaces: L_TRIM(<result from Step #1>)
    3. Replace all spaces back to 0: REPLACE('','0',<result from Step #2>)
    Formula Builder looks like this:
    L_TRIM(REPLACE_ALL('0','',0MATERIAL))
    I attempted this using the
    REPLACE()
    function (available in the APD Formula builder) to replace all zero's with an empty string. This too created a problem because as in examples (a) through to (e), the function replaces all zero's in the string not just the leading ones! e.g.
    REPLACE('0', '',000000000001001037)
    gives 1137 ! 
    The problem here is that when you specify a space in the
    REPLACE()
    function by saying
    it thinks you meant no spaces at all! Therefore I am no longer able to execute step 3! 
    I'm stumped now and would appreciate the communities help on this.
    Thanks,

    Thanks Akshay,
    I took 0MATERIAL as the source field
    I specified ZMATLWOLDZERO as the target field (type same as 0MATERIAL).
    In the code section i wrote this:
      DATA: ls_source TYPE y_source_fields,
            ls_target TYPE y_target_fields.
      loop at it_source into ls_source.
        move-corresponding ls_source to ls_target.
        call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            output = ls_target-ZMATLWOLDZERO
          IMPORTING
            input  = ls_source-material.
        append ls_target to et_target.
      endloop.
    compiles fine but on test execution, the code termnates saying that "Incorrect parameter with CALL FUNCTION"
    Forgive me this is a first attempt I have tried but I fear my logic is incorrect in the code somewhere...

  • Leading zeros trimmed!

    I am extracting data from a text file and putting it in an SQL Server 2000 database. When I insert fields with leading zeros into the database, the zeros are trimmed away. All my data are string type and I use VARCHAR in the database for those fields.
    When I insert literal strings with leading zeros, the zeros do appear in the database.
    Any help is much appreciated.
    Akz

    This is the code I use to update my SQL Server database. As you can see, 5 strings are declared and initialized; some have leading zeros.
    4451972 129293 040504 015011 000319
    When I open the databse , the leading zeros are missing.
    The database record for the record I just inserted looks like the following:
    4451972 129293 40504 15011 319
    What happens to the leading zeros?
    This is the code:
         String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CRD_DB";
         Connection con;
         Statement stmt;
         String caller="4451972", called="129293", date="040514", startTime="015011",
    duration="000319";
         try {               
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
         } catch(java.lang.ClassNotFoundException e) {
         System.err.print("ClassNotFoundException: ");
         System.err.println(e.getMessage());
         try{
         con = DriverManager.getConnection(url,"pola", "pola" );
         stmt = con.createStatement();
         stmt.executeUpdate("INSERT INTO CRDTableNew values("+caller +"," + called+","+date
    +","+startTime+","+duration+")");
         stmt.close();
         con.close();
         catch(SQLException ex){
         System.err.println("SQLExc.:" + ex.getMessage());
         }

  • Removing (only) leading zeros in a string

    Hello experts.
    I need to remove the leading zeros from the material name in Crystal Report for Enterprise. I stared with function Replace and Trim and it's fine in case I specify the number of zeros to be removed.
    In reality number can be 00001103 or 00455601 and there is no way to know how many leading zeros. If I choose not to specify the number of replacements, all zeros will be removed with result 113 and 445561 which is not desirable one. I should get 1103 and 455601.
    What syntax would remove only leading zeros?
    Thank you,
    Victoria

    hi Victoria,
    you could do something like
    if isnumeric({your field}) then
         totext(tonumber({yourfield}),0)
    cheers,
    jamie

  • Cuts off leading zeros in a report column when "Download to Excel" function

    Hello
    When a text column contains leading zeros for example "000250" the download to Excel stores the string as "250" in the spreadsheet. I am using a column which is a string.(varchar)
    Can somebody suggest me , how to go ahead with it
    Thanks
    Edited by: user647228 on Sep 11, 2008 1:40 PM
    Edited by: user647228 on Sep 11, 2008 1:42 PM

    (To Vins) Actually, concatenating a space doesn't do it. When the file is downloaded into Excel, the leading space is ignored and it the leading zeroes are still trimmed.
    To user647228: A non-space character needs to be concatenated. Regarding what character to append, I would give the following consideration: If the users are content with seeing an added character to the "number," you can append say an underscore "_" and Excel will download the number properly. It's fairly unobtrusive and can be "visually ignored."
    If the end user insists on gettin rid of the extra character once the file is downloaded, I would append a character that is rarely, if not never, used in the report. (This ensures or mitigates replacing other instances of the character.) Then you can do a Replace All in Excel to replace the extra character with a single apostrophe. The single apostrophe will be interpreted by Excel to mean "text" and the appearance will change to exactly what is desired.
    Note: Replacing the extraneous character with a space for example, will result in the leading zeroes being again lopped off by Excel...

  • How to remove leading Zeroes in all fields in Payload

    Hi,
    How can I remove the leading Zeroes in every Filed I have in whole Payload Structure.there are around 10000 fields that have to be removed the leading Zeroes.any good idea please.
       <POSNR>000010</POSNR>
      <MATNR>000002465640</MATNR>
      <ARKTX>000012 KG D107</ARKTX>
      <MATKL>00030010000</MATKL>
      <WERKS>0000ORGC</WERKS>
      <LGORT>0000GC55</LGORT>
      <CHARG>000TEST</CHARG>
    like this mutliple segments and multiple Fields.so  I can take as whole payload with multiple fields should not have leading Zeroes.I can handle if they are 10 0r 20 fileds,but not like whole pay load/1000 fields right.
    thank you,
    Prem

    Hi
      You can have an additional XSLT mapping, to your existing one..
    use copy-of & apply-templates to copy the whole tree & make changes recursively.
    below is a sample code , the marked line is where you need to try your logic of trimming Zeros. (this code does upper case)
    add this below code in your interface mapping object, as XSLT mapping, which does the job (only try putting your logic)
    <xsl:stylesheet
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      version="2.0">
                <xsl:output  method="xml"
                            indent="yes"
                            omit-xml-declaration="yes"/>
                <xsl:template  match="*">
                      <xsl:copy>
                            <xsl:copy-of  select="@*"/>
                            <xsl:apply-templates/>
                      </xsl:copy>
                </xsl:template>
                <xsl:template  match="text()">
                      <xsl:value-of  select="upper-case(.)"/>
                </xsl:template>
          </xsl:stylesheet>
    hope this fixes your issue
    Regards
    Vishnu

  • 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

  • Truncating Leading Zeroes

    Hi,
    What is the best method to truncate the leading zeroes of an alphanumeric data item? Is there an expression editor function that could do this?
    I have come up with a logic involving 3 - 4 actions that could do this for a specific data item. The problem is I have got about 5 different data items in the same transaction that need leading zeroes truncated. Whats the best thing to do here?
    Do I need to build a custom action or expression editor function?
    Regards,
    V M.

    Well, there are equivilants in every database. I think Oracle has something like LTRIM(value, '0')
    If your application doesn't use any databases and you are on 12.0 + you could estabish a connection to the neweaver db.
    You could also look into and xsl solution using the XSL Transformation action.
    I often do this to create/format lists for query filters or similar tasks.
    For some background this issue often comes up when pulling data from standard SAP interfaces. In sap Order and Material numbers are typically trimmed automagically by the gui. But when pulling those data elements from sap you get the full monty. This is ok because you often need the full untrimmed value to use with other interfaces, but users still expect the values to be trimmed when displayed. There are a lot of solutions to this issue in regards to the front end (xsl, Javascript, SQL in cases where the data is stored/cached in a local database ) but it would be convienent to have this level of formatting built into the link editor. Maybe even something that accepts a regular expression?
    Regards,
    Christian

  • Triming Leading Zeroes

    Hi,
    We have a query which uses a variant to accept a value for a field by the name of Internal Order. In our Cube the data for this field is stored with leading Zeroes e.g. '0002000'.
    When the user enters the value for this variant without the leading zeroes e.g. 2000 instead of 0002000 then the query does not return any output. But if the leading zeroes are entered then the query returns the results.
    How do we trim the leading zeroes while checking from the field in the cube.
    One more thing the query does not return any error while executing if leading zeroes are not entered.
    Thanks & Regards
    Raj

    I would recommend using ALPHA conversion also.  Why delete something if you don't have to, it's dangerous.  Plus, in your transfer rules, you can just check a box.
    If you need to code it, you can use function module   'CONVERSION_EXIT_ALPHA_INPUT'.
    Brian

  • Procedure truncating leading zeros

    Hello,
    I'm setting up sequences for my sample database, in my design I have my ID columns in this format Staff: S110001, Parents: P110001 etc.
    When I try to implement this in a sequence like:
    create sequence Pnt_seq1 start with 0001;
    insert into parents
    (parent_id, f_name, m_init, l_name, house_n, street, city, postcode)
    values
    (('P' || to_char(sysdate, 'yy')|| Pnt_seq1.nextval), 'Jim', 'I', 'Brown', 34, 'Barker St', 'Wrexham', 'LL11 8UH');
    It trims or truncates the leading zeros giving me P111 instead of P110001. Is there a way around this or am I better off changing my domain definitions/schema to start at P111001 or something?
    Thanks a lot
    Mike

    A sequence is always numeric, so leading zeros have no place
    Nothing is trimmed.
    If you want leading zeros in the code you posted use
    to_char(Pnt_seq1.nextval,'fm0009')
    Sybrand Bakker
    Senior Oracle DBA

  • Adding leading zeros in abap objects.

    Can anyone explain me
    1. How to add leading zeros to a field in abap objects.
    For eg:
    data: dmb(6) type c value '123456',
    actually the output value of c should have leading zeros added to it for length 16.
    i.e '0000000000123456' . If the length of dmb is less than 16 then leading zeros should be added to that value to make it 16 as length.
    Please tell me how to do it in ABAP Objects.

    Hi Camila
    Try to use the statement
    DATA: ALPHABET(15) VALUE '     ABCDEFGHIJ',
          M1(4)        VALUE 'ABCD',
          M2(6)        VALUE 'BJJCA '.
    SHIFT ALPHABET LEFT DELETING LEADING M1.
    The field
    ALPHABET
    remains unchanged.
    SHIFT ALPHABET LEFT DELETING LEADING SPACE.
    The field ALPHABET now has the following contents:
    'ABCDEFGHIJ     '.
    SHIFT ALPHABET RIGHT DELETING TRAILING M2.
    <b>ALPHABET</b> now has the following contents:
    '      ABCDEFGHI'.
    <u><b>IN CHARACTER MODE</b></u>
    <b>Effect</b>
    This is the default setting (see above), and the addition is therefore optional.
    <b>Note
    Performance:</b>
    For performance reasons, you should avoid using SHIFT in WHILE loops.
    The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ...
    LEFT DELETING LEADING
    ... variant is around 3.5 msn, for ...
    RIGHT DELETING TRAILING
    ... around 4.5 msn.
    Reward all helpfull answers
    Regards
    Pavan

  • How do I use the print function to output a numeric variable with a fixed amount of leading zeroes

    I need to create an output from a T-SQL query that picks a numeric variable and uses the print function to output with leading zeroes if it is less than three characters long when converted to string.  For example if the variable is 12 the output should
    be 012 and if the variable is 3 the output should be 003.
    Presently the syntax I am using is PRINT STR(@CLUSTER,3) .  But if @CLUSTER which is numeric is less than three characters I get spaces in front.
    Please help!

    >> I need to create an output from a T-SQL query .. <<
    NO! NO! In RDBMS, we have a presentation layer that handles displays. We do not ever do it in the database. This is fundamental. But more than that, the purpose of PRINT is for debugging in T-SQL and never for output.
    You are still writing 1960's COBOL or BASIC, but you want to to it in SQL.  You probably picked the wrong data type (a numeric that should be a string) and are trying to repair your design error.  
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • IR - Column with leading Zeros issue

    Hello,
    I've got an IR report which includes as "default report settings" 1 column with leading 0s. In order to export to Excel that column as text rather than as a numeric I followed a workaround proposed before in this forum (excel copy drops leading zeros
    In essence this workaround is to create an identifical column but in "excel text format" and display the columns depending on the request value: INSTR(NVL(:REQUEST,'YABBADABBADO'),'CSV') <> 0 for example.
    This works just fine for the default report.
    The problem arise when a user creates his own customise report that includes the mentioned column and saves it as a named report. Here, when the results are exported to excel the "excel" column does not appear.
    In fact, just hiding one of the displayed columns produces the same undesired result.
    I would appreciate any comments or suggestions.
    Many thanks
    Edited by: Javier Gil on Jul 20, 2010 7:52 AM

    I have found a better method. In your IR query:
    SELECT LPAD(v.vendor, 7, ' ') vendor,
    /*Just LPAD to a length of the column defined in the database table or to 7, whichever is greater. */
    FROM v, r
    WHERE v.VENDOR = r.VENDOR
    AND date_rcv <= to_date(:P150_CUTOFF,'yyyy/mm/dd')
    AND inv_nbr = ' '
    AND to_stores <> 'T'
    AND (V.VENDOR = RPAD(:P150_VENDOR,10,' ') OR :P150_VENDOR = 'ALL')
    When you download to Excel by Download/XLS (Request=XLS), it preserves the leading zeros.
    In the case of dates, you should LPAD 10 minimum in this format.
    LPAD(to_char(date_rcv,'MM/DD/YY'), 10, ' ') date_rcv,
    I haven’t tried it yet but I think in the case of ‘MM/DD/YYYY’, you should LPAD 12 minimum in this format.
    LPAD(to_char(date_rcv,'MM/DD/YYYY'), 12, ' ') date_rcv,
    Drawbacks of this method:
    Since the string has leading white spaces, you cannot use the filter for the ‘=’ comparison operator. Even filtering using leading white spaces will not return anything. You must use the LIKE and NOT LIKE operator instead.
    Advantages of this method over the original one I posted yesterday:
    1)     You do not have to create another column for download, just one column will suffice.
    2)     Even though the query has leading white spaces, they will not display in the IR region.
    Edited by: richardlee on Aug 5, 2010 11:10 AM
    Edited by: richardlee on Aug 5, 2010 11:16 AM

Maybe you are looking for

  • Fixed length file as mail attachment

    Hi , I am using function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send a binary file as an attachment to a mail. Each record in the file should be of fixed length 200. The "contents_bin"  table parameter of function module has line of length 255. Th

  • C# VisualWebpart get Images from a specific Image Library.

    Hello, I'm working on a VisualWebpart Project in VS2013. Are there any possibilities, where I can get the Images from a Image Library? Like this: //pseudocodeSPLibrary imagesLib = new SPLibrary("mySite\Library") var imageList = imagesLib.GetContent("

  • Looking for a pixilated looking font

    I am looking for a pixilated font like http://www.fontshop.com/fonts/singles/club21/preset_f_ot/ Anyone have an idea? Thanks

  • Immerse Style Issue

    I am curious if anyone else has had this issue with any of the themes in SharePoint. I would really like to either expand what appears to be the "ms-comm-forumContainer" so it will look right or prevent text from being able to pop out of the containe

  • Nokia 6500c New Firmware released

    Latest available software for Nokia 6500 classic: Version: 09.45 Nokia C7-00 V 024.001 Nokia E52-1 V 081.003 Nokia 6700 classic V 13.10