Leading zero problem!

Hi !
i have a numeric type variable i.e. 'w_xyz type n length 7'
now i want to delete the leading zero's for this variable simultaneously want to retain the length of the field unaltered i.e.
if  w_xyz = '0000987'  then i want
w_xyz = '    987'.
any help pls,
Thanks in advance.
Regards,
Parwez.

Hi,
There is a simple way to achieve that : just use shift statement.
SHIFT w_xyz LEFT DELETING LEADING '0'.
Regards,
Nicolas.

Similar Messages

  • BAPI_PO_CHANGE document number leading zero problem

    Hi experts,
    The following code clears the "Delivery Complete" flag on a list of Purchase Orders uploaded from a CSV file.
    The PO number is 9 digits long, however, in EKPO table it is stored as 10 digits (prefixed with a zero). The BAPI does not recognise the document number unless it is prefixed with a zero in the CSV file (which adds extra work for the user to create custom format in Excel to add the leading zero).
    What code is required for the BAPI to recognise the 9 digit number without the leading zero?   Perhaps the leading zero could be hard-coded into the program?
    Any advice is much appreciated.  Thanks for your time.
    REPORT  Z_MASS_REMOVE_FDI_DCI_BAPI.
    *Check if file exists
    DATA: rc TYPE sy-ucomm.
    CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = 'X:\STO.TXT'
           IMPORTING
               return   = rc.
    IF rc EQ 0.
      WRITE: / 'File does not exist'.
    ENDIF.
    TYPES: BEGIN OF ty_tab,
            DOCNO(10),
            ITEM(4),
           END OF ty_tab.
    DATA : it_tab TYPE STANDARD TABLE OF ty_tab,
           wa_tab TYPE ty_tab.
    START-OF-SELECTION.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename = 'X:\STO.TXT'
    *     FILETYPE = 'ASC
          has_field_separator = 'X'
    *     HEADER_LENGTH = 0
    *     READ_BY_LINE = 'X'
    *     IMPORTING
    *     FILELENGTH =
    *     HEADER =
          TABLES
          data_tab = it_tab
          EXCEPTIONS
          file_open_error = 1
          file_read_error = 2
          no_batch = 3
          gui_refuse_filetransfer = 4
          invalid_type = 5
          no_authority = 6
          unknown_error = 7
          bad_data_format = 8
          header_not_allowed = 9
          separator_not_allowed = 10
          header_too_long = 11
          unknown_dp_error = 12
          access_denied = 13
          dp_out_of_memory = 14
          disk_full = 15
          dp_timeout = 16
          OTHERS = 17.
    END-OF-SELECTION.
    LOOP AT it_tab INTO wa_tab.
      WRITE:/ 'DOCUMENT: ',
      wa_tab-DOCNO,
      ' ITEM: ',
      wa_tab-ITEM.
      WRITE: / '-----------------------------------------------------------------------'.
      DATA: s_header TYPE bapimepoheader,
            s_headerx TYPE bapimepoheaderx,
            s_item TYPE bapimepoitem,
            s_itemx TYPE bapimepoitemx,
            i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
            i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
            s_bapimepoheader TYPE bapimepoheader,
            s_bapimepoheaderx TYPE bapimepoheaderx,
            s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,
            s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,
            wa_message TYPE c LENGTH 100.
      s_bapimepoheaderx-po_number = wa_tab-DOCNO.
      s_bapimepoheader-po_number = wa_tab-DOCNO.
      s_bapimepoitemx-PO_ITEM = wa_tab-ITEM.
      s_bapimepoitem-PO_ITEM = wa_tab-ITEM.
    *Remove Delivery Complete Indicator (DCI)
      s_bapimepoitemx-NO_MORE_GR = 'X'.
      s_bapimepoitem-NO_MORE_GR = ' '.
      append s_bapimepoitem.
      clear s_bapimepoitem.
      append s_bapimepoitemx.
      clear s_bapimepoitemx.
      CALL FUNCTION 'BAPI_PO_CHANGE'
        EXPORTING
          purchaseorder = wa_tab-DOCNO
        TABLES
          return        = i_return
          poitem        = s_bapimepoitem
          poitemx      =  s_bapimepoitemx.
    *Message types: S Success, E Error, W Warning, I Info, A Abort
    *Supress all Warning Messages
    DELETE i_return WHERE ( TYPE EQ 'W' ).
    *Commit only if no errors have been returned
      read table i_return with key type = 'E'.
      if sy-subrc ne 0.
        COMMIT WORK AND WAIT.
      endif.
    *Display Return Messages on Screen
      LOOP AT i_return.
        WRITE: /   'RETURN MESSAGE: ',
        'ID: ',
        i_return-id,
        ' TYPE: ',
        i_return-type,
        ' NUMBER: ',
        i_return-number,
        i_return-message.
      ENDLOOP.
      WRITE: / '-----------------------------------------------------------------------'.
      refresh : s_bapimepoitem,s_bapimepoitemx.
    ENDLOOP.

    hi,
    Use the conversion exit to make it as 10 digit char CONVERSION_EXIT_ALPHA_INPUT.

  • Export to Excel - leading zeros problem

    Hello,
    I wrote an application, which exports the data from an internal table into an excel file.
    I defined a variable as char20. The variable contains the value '000256'.
    When I generate the excel file, the leading zeros are cut and so only the value 256 is stored into the cell.
    Is it possible to prevent the cut of the zeros?
    Best regards & Thanks in advance
    Here is a part of may code:
      conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8'  ).
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text   = gv_content
        IMPORTING
          buffer = gv_xtext.
    attach the first file
        conv_out->convert( exporting data = gv_xtext ).
        cl_wd_runtime_services=>attach_file_to_response(
        i_filename  = 'file1.XLS'
        i_content   = gv_xtext
        i_mime_type = 'application/msexcel'
        i_in_new_window = abap_true
        i_inplace       = abap_true ).

    you could add an apostrophe ' in front of all fields that you want exported as a text.
    this will ensure no truncating is done.
    it's excel that does the shifting, so you can't really interfere from the SAP side

  • Leading zeros problem with custom popup

    I've implemented a custom popup page following the How-To docs on the topic. The value I'm return to the calling page in the passback function most often will have leading zeros. So from the custom popup I do a call like this: javascript:passback(00363644). When my value arrives back on the calling page it's converted to 124836 (haven't yet figured out what kind of conversion is happening there).
    I realize this is not a javascript forum (and I've Googled for leading zeros in javascript to no avail - yet) but the HTML DB field type Popup LOV seems to accomplish this just fine so I was wondering how Oracle might be doing it. Anyone have any ideas?
    Earl

    Vikas,
    See
    http://tinypic.com/ibbfoy.jpg
    So, just use
    javascript:passback("00363644")and it should do what you want.You would think. But I've tried:
    wrapping it in single quotes:
    opener.document.getElementById('P6_CONTACT_ID').value = "'" + myVal + "'";
    wrapping it in single quotes:
    opener.document.getElementById('P6_CONTACT_ID').value = """ + myVal + """;
    and the other 'trick' that I've seen mentioned several places, concatenating an empty string to the value:
    opener.document.getElementById('P6_CONTACT_ID').value = "" + myVal;
    All to no avail! This is really frustrating. Supposedly, any string concatenation action will 'force' the value to retain it's original 'string-ness'.
    Working off this assumption and thinking that the conversion had already taken place by the time I assigned the value I backed up a step and assigned the value to a variable before trying to set the value, ala:
    var myVal = p_Value.toString();
    opener.document.getElementById('P6_CONTACT_ID').value = myVal;
    and still no joy.
    Following this logic one step further, do I need to get the value to a string in the original call. This will be a challenge because the link in the popup report is a is set to a URL with javascript call, like this: javascript:passback(#CONTACT_ID#);
    Further, when I float over the links with the mouse I can see the URL in the status bar of the browser as javascript:passback(00363644); So, how do I go about wrapping this in quotes in the link?
    Any help???
    Earl

  • Adobe Form Leading Zero problem

    Hi expert,
    I am working on adobe form. In the field of customer number i want excat number not with zero. but in pdf output it is displaying zero. like '0000117719' but i want 117719.
    Pl help

    Hello friend,
    you can use the following FormCalc in the field:
    var x=$.rawValue;
    $.rawValue = replace($.rawValue,"0"," ");
    $.rawValue = ltrim($.rawValue);
    $.rawValue = right(x,len($.rawValue));
    Best Regards,
    Jerry

  • Integer with leading zeros

    i have an msAccess db that i need to move over to msSQL2000
    and a numeric field of part numbers always has 5 digits: example:
    12345, 01234, 00123....
    in msAccess the field data type is "number" with a format of
    "00000" which maintains leading zeros.
    problem is that i cannot figure out to create an equivilant
    numeric field that maintains leading zeros in msSQL2000. would
    prefer not to use "char"
    thanks in advance

    ranger wrote:
    > in msAccess the field data type is "number" with a
    format of "00000" which
    > maintains leading zeros.
    no, it only displays it that way.
    > problem is that i cannot figure out to create an
    equivilant numeric field that
    > maintains leading zeros in msSQL2000. would prefer not
    to use "char"
    you can't. either you format on the fly in sql server
    (complicated) or you
    format (numberFormat(), etc.) it in cf.

  • Exporting leading zeros in error

    Hello,
    I am currently working on a problem that was uncovered in our support pack testing. we were on support pack 14 and now have upgraded to support pack 18. the users run a ALV report and would export the report to excel. the ALV report would display the line item asa 2 digit number. when they would download the report, the field would display as a 4 digit fields with three leading zeros. when you checked the excel file, the line item field would have the green triangle in the upper left corner of the cell and when you checked in green triangle, you would get " the number is stored as text". now after the upgrade, this is not happening.
    does anyone know why this was happening and if this was corrected in one of the support packs 15 thru 18?
    one of our users was using this file with the leading zeros to upload to a external database and now is having problem with the new file format
    thanks in advance for the help

    Dear Friend ,
    You can mention in the Fieldcat LZERO = 'X' for the field in fieldcatalog.
    this will solve your leading zero problem.
    Regards
    Shankar

  • Problem with Leading Zeros

    Hi Experts,
    In the start routine, I  am trying to compare  two object 0PLANT and ZSTORE which  contains the same values. But the problem is 0PLANT is of length 4 and ZSTORE is of length 8. As a result,for example,  the value 2  in  0PLANT is stored as '0002' and as ' 00000002'  in ZSTORE.
      I have written the code as following, which is not working due to the leading ZEROES. Please note that Both objects don't have ALPHA conversion as part of the info Object Definition.
    *Select PLANT /BIC/CBRCH_GRP from /BI0/PPLANT into table I_PLNT
    where PLANT = DATA_PACKAGE-/BIC/ZSTORE.*
    Though I knew that there is a FM CONVERSION_EXIT_ALPHA_OUTPUT, I am not sure whether we can use that FM for procesisng bulk amount of data.
    Request you all to propose a solution for the same.
    Thanks in advance,
    Babu Vasamsetti.

    Hi Babu ,
    Please use the code below.
    You can modify it according to your requirements :
    TYPES: BEGIN OF TY_ZTORE,
            ZTORE TYPE /BIC/OIZTORE
            PLANT TYPE /BI0/OIPLANT,
           END OF TY_ZTORE.
    DATA:       LT_ZTORE TYPE STANDARD TABLE OF TY_ZTORE,
          LS_ZTORE TYPE TY_ZTORE.
    SELECT /BIC/ZSTORE FROM
    /BIC/PZSTORE INTO TABLE LT_ZTORE
    FOR ALL ENTRIES IN DATA_PACKAGE.
    SORT LT_PLANT BY /bic/ZTORE.
    DELETE ADJACENT DUPLICATES FROM LT_DATAPACKAGE COMPARING /BIC/ZSTORE.
    LOOP AT LT_ZTORE
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT         = LT_ZTORE-/BIC/ZSTORE
       IMPORTING
         OUTPUT        = LT_ZTORE-PLANT.
    ENDLOOP.
    Select PLANT /BIC/CBRCH_GRP from /BI0/PPLANT into table I_PLNT
    where PLANT = LT_STORE-PLANT.
    -Vikram

  • Problem in XSL mapping with leading zero's

    Hi ,
    i am facing a problem in disigning a XSL mapping where one of the source field (type string ) ,and I need to remove the leading zero's to map it to target.
    we have format-numer ,but It is not working in this case ,may be because of type string.
    and the replace command is not supported .
    So can any one suggest me some way to resolve this xsl problem.
    Thanks,
    Raju.

    I write an example
    xsl file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <xsl:template match="/">
              <doc>
                   <xsl:apply-templates/>
              </doc>
         </xsl:template>
         <xsl:template match="source_field">
              <source_field>
                   <xsl:call-template name="remove_leading_zeros">
                        <xsl:with-param name="value" select="."/>
                   </xsl:call-template>
              </source_field>
         </xsl:template>
         <xsl:template name="remove_leading_zeros">
              <xsl:param name="value"/>
              <xsl:choose>
                   <xsl:when test="starts-with($value, '0')">
                        <xsl:call-template name="remove_leading_zeros">
                             <xsl:with-param name="value" select="substring($value, 2)"/>
                        </xsl:call-template>
                   </xsl:when>
                   <xsl:otherwise>
                        <xsl:value-of select="$value"/>
                   </xsl:otherwise>
              </xsl:choose>
         </xsl:template>
    </xsl:stylesheet>
    to test:
    input xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <doc>
    <source_field>000000123456</source_field>
    <source_field>0987654</source_field>
    </doc>
    output xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <doc xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <source_field>123456</source_field>
         <source_field>987654</source_field>
    </doc>
    hope can help you.
    regards
    Bin

  • Leading zeros for FM F4_GET_RESULT - wildcard problem

    Hi,
    I have the following problem:
    FM F4_GET_RESULT supports the search help in a BSP application.
    It works fine when there is no wildcards used. However when there is a wildcard it doesn't work.
    For example in case of cost centers, we use search help M_KOSTN, which based on table CSKS. There is one cost center 0002160221, which is found if I use form '000216*', however not found if I use without leading zeros.
    Actually it's the same if I use SE16 on table CSKS.
    I cannot really use ALPHA conversion here as I don't know how many leading zeros I have to add.
    Any idea how to solve this issue?
    Thanks in advance,
    Peter

    Hi peter,
    To remove leading zeros and leading blanks
    Please use FM
    CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal
    CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external
    These function modules convert the value of an external represntation of a field into an internal format or vice versa.(Meaning for some fields like MATNR, then value which you see is not the way it is stored in the database. The value that you see is the external format, and the value which is stored inside the database id the internal format. These function modules convert the values of such fields from internal to external and vice versa.
    CONVERSION_EXIT_ALPHA_INPUT This function module is used to append leading zeroes...
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                EXPORTING
                  input  = wf_version
                IMPORTING
                  output = wf_version.
    Example:
    input = 123
    output = 0000000000000...000000000000123
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .

    Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .

    Hi Chhayank,
    the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
    Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
    ~Florian

  • Leading zeros for 9AMATNR creating problem

    Hi Experts,
    In the DP Planning book, we are using product (9AMATNR) as one of the characteristics. If I open the shuffler and enter a product number (numeric), the system attaches the leading zeros to make it 40 characters. If I put a product number as alpha numeric, system does not attach the leading zeros.
    After loading the data into the planning book, if I click on 'Details all' in the filter for product, I see the products as 'product number/description' e.g. 00000000000000000000000000000000000012345/ABCDEFGH.
    The issue is, while accomodating the leading zeros here, the description is truncated and we dont see the complete product description.
    Is there a way to over come this? The intent is that the product description should not get truncated.
    Any pointer would be of great help.
    Regards
    Manotosh

    In the IMG
    Goto SAPSCM - Implementation Guide
    -> Advanced Planning and Optimisation
    --> Master Data
    ---> Product
    > Specify Output Format of Product Number
    Ensure that the checkbox "Leading Zeroes" is not ticked

  • SapScript problem with leading zeros

    Hi,
    I print field LTAP-NLENR.
    But when i use &LTAP-NLENR& leading zeros are cut.
    I need to display it with leading zeros. (ex. 0000000000010000000001)
    Please help.
    Regards,
    Greg.

    &LTAP-NLENR(K)& works fine for me with your requirment.
    I have defined a L_VAR like this:
    data: L_VAR type LTAP-NLENR.
    l_var = '0000000000010000000001'.
    In my script I use like this:
    P1   &L_VAR(K)&
    SO, try to pass that value to some other variable and see what happens.
    Regards,
    Naimesh Patel

  • 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

  • IR truncating leading zeros in my popup window report

    Hello,
    I am using IR_columnname, for one of the columns in my report which is a popup window report.
    My problem is that IR_column search filter in my popup window is truncating the leading zeros.
    I am getting the value but it is truncating the leading zeros.
    like say if the deptno is something like 020 or 0020 in the parent window.
    the IR_columnname value is taking '20' (its truncating leading zeros) with this filter its not dispalying the result in my popup window.
    can anyone help me out with this.
    thanks.

    How are you passing values to the IR filter? There could be a possibility that you source logic is truncating the leading zeros.
    Thanks,
    Manish

Maybe you are looking for