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

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 0's

    I have to download data from internal table to Excel sheet.
    In the internal table i have a field xxx- that is type numc10
    I have a value for this field-000001234
    Now when i export this to excel sheet, leading zeroes are removed and the output is-1234
    How can i make sure that the output in excel is displayed as 0000001234.
    This is very importnant for our project.
    Thanks in advance.

    Hi Narendra,
    See the exact code for leading zero's in XL File.
    REPORT ZTEST3 line-size 400.
    Place holder to keep leading zero's
    DATA : V_CHAR(1) TYPE C VALUE ''''.
    Internal table for MAKT Table
    data : begin of i_makt occurs 0,
           matnr like makt-matnr,
           maktx like makt-maktx,
           end of i_makt.
    Internal table for XL File
    See Material number is 18 char but i am declaring here 20 char length
    data : begin of i_file occurs 0,
           matnr(20) type c,
           maktx like makt-maktx,
           end of i_file.
    start-of-selection.
    select matnr maktx from makt into table i_makt.
    loop at i_makt.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = i_makt-matnr
    IMPORTING
       OUTPUT        = i_makt-matnr
    CONCATENATE V_CHAR  i_makt-matnr  INTO i_file-matnr.
    i_file-maktx = i_makt-maktx.
    append i_file.
    clear i_file.
    endloop.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
        FILENAME                      =
        'C:\Documents and Settings\smaramreddy\Desktop\fff.xls'
       FILETYPE                      = 'ASC'
      MODE                          = ' '
      WK1_N_FORMAT                  = ' '
      WK1_N_SIZE                    = ' '
      WK1_T_FORMAT                  = ' '
      WK1_T_SIZE                    = ' '
      COL_SELECT                    = ' '
      COL_SELECTMASK                = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      TABLES
        DATA_TAB                      = i_file
      FIELDNAMES                    =
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_WRITE_ERROR              = 2
       INVALID_FILESIZE              = 3
       INVALID_TYPE                  = 4
       NO_BATCH                      = 5
       UNKNOWN_ERROR                 = 6
       INVALID_TABLE_WIDTH           = 7
       GUI_REFUSE_FILETRANSFER       = 8
       CUSTOMER_ERROR                = 9
       OTHERS                        = 10
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Please close thread.
    Reward Points if it is helpful
    Thanks
    Seshu

  • Can't export filename with leading Zeros -i.e. File-001

    Windows sorts filenames based on the leading digit. So the file after File-1 is File-10, not File-2.
    I can enter a sequence starting at 001, but LR ignores it. I don't want to start numbering at 100, but so far that is the only workaround I can think of.

    This is certainly possible. In the export dialog, click on the template popup in the file naming section. Select Edit. Now in Sequence and date you'll find a popup that will do leading zeros. As you can see you can name in millions of different ways only limited by your imagination and practical limits.

  • 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

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

  • WAD Export to Excel Button Output problem

    hi
    we are facing issue in WAD ,here we have a button (Export to Excel).
    when we use it, out put for one field is limited to 60 char only but that field text having more than 60 char's.
    while excuting WebTemplate its getting all char's but in Excell its getting 60 char's.
    Regards'
    Ramakrishna.

    try to run this on somebody elses computer
    2nd download software http watch run a trace on when you ran the report in internet explorer and wsee the results. you will need basis assistance on this.
    you can also run the query in rsrt using HTML and export to excel see if that works.

  • Export to excel character set problem

    Hello,
    I'm having troubles exporting a query to excel in ApEx,
    signs like é ü are displayed incorrect. I have been searching for a while now but i can't find out what is wrong. The DAD of the DB is UTF8 and ApEx is also UTF8. Could anyone give me hint what could be wrong?
    Here is an example:
    WÜRTH is displayed WÃœRTH
    When I trow in a convert from UTF8 to WE8ISO8859P15
    WÜRTH is displayed as W�TH
    FROM 'US7ASCII', 'WE8ISO8859P1'
    WÜRTH is displayed as W??RTH
    I use the following procedure:
    PROCEDURE p_export_lots(p_public_sale_id IN public_sales.public_sale_id%TYPE,
    p_language_cd IN item_descriptions.language_cd%TYPE)
    IS
    CURSOR c_excel
    IS
    Select itm.item_id, to_char(long_description) long_description
    from items itm, item_descriptions des
    where itm.item_id = des.item_id
    and language_cd = p_language_cd
    and dossier_id In ( SELECT dossier_id
    FROM dossiers
    WHERE public_sale_id = p_public_sale_id)
    ORDER BY to_number(lotnr_from);
    v_trans VARCHAR2(400);
    BEGIN
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="export.csv"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Print out a portion of a row,
    -- separated by commas and ended by a CR
    FOR rec_excel IN c_excel LOOP
    v_trans := rec_excel.long_description;
    htp.p(' '||';'||rec_excel.item_id||';'||v_trans||';'); -- a new line in excel
    END LOOP;
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    END p_export_lots;
    Thanks in advance

    hmmm the DAD should be "AL32UTF8" not "UTF8" ...
    as long as you use the htp.p procedure all your output is being converted to
    AL32UTF8 (as the DAD setting states).
    Why don't you use the APEX-provided export-to-excel function. IKf you navigate
    to the application settings and there to the globaization settings you can enable
    the "automatic CSV encoding" - Setting this to "yes" should do the trick for you ...

  • Export to Excel Formating Option Problem

    Hi all!
    I create a Crystal Reports.when i export to Excel File in a winform app,there has the 'Create page breaks for each page' option,but in asp.net web page.there is only two option,and not include the 'Create page breaks for each page' .I excpet the Excel File was page breaked.
    has any ideas?
    Thanks!
    Ray

    You can use the ExcelFormatOptions to specify what you want the export to look like.
    Look for it here:
    [http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm]
    You can also set up the reports export options that you want to always be used by opening the report in Crystal and going to File|Export|Report Export Options.
    I am not sure about the 2nd question.  You will want to create a new thread for that and someone else may know the answer.  Can you do it when you export it from Crystal Reports? If not, then you won't be able to do it from your application.

  • Webdynpro abap ALV export to excel with images problem

    Hello experts,
    I'm having problems with standard excel export functionality in webdynpro abap ALV.
    In my table i have images taken from content server (employee photos) linked with URL to a table_cell Image, when i export the table to excel using standard function the images is showed as a broken picture with the following text:
    "The linked image cannot displayed. The file may have been moved, or deleted. Verify that the link points to the correct file and location."
    I'm running on sap basis 7.02 SP13 and implemented the notes 1975765 and 1985288 but not resolved this issue.
    Do you have any ideas?
    Thank you.

    Hi Jorge,
    Are you able to download the ICONs from alv table? try to use some icon source '~Icon/Add' and check out if you can download it to excel successfully.
    FYR:
    Regards,
    Rama

  • ALV data export to Excel using &VEXCEL  problem due to GUI Version

    If i download ALV report using &VEXCEL it works with GUI release 460 but when i am trying same with GUI release 710 it gives message View cannot be switched: Product is not installed or integration is not active. Please provide the solution so that same will work with GUI release 710.
    Thanks and Regards,
    Aniket Dayama

    Hi,
    I resently had the same problem:
    View could not be changed to: <(>&<)>VEXCEL.
    It turned out that the custumor had an old version of Windows NT.
    But it wil be wise to install new versions of both Excell, SAP-GUI and your pc control system.
    Dearest Tom.

  • Export sequence with leading zeros

    Is there a way to persuade LR to export a sequence beginning with name-01.jpg instead of name-1.jpg so the images sort properly?

    Have you tried doing this?
    You are not restricted to the supplied example filename setups. You can use the "Filename Template Editor" to construct one to your own specifications using the presented options (these "tokens" are replaced with the relevant details of each image exported) plus anything else (standard text, dashes, spaces etc) that you care to put into the template.
    RP

  • 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

  • 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

  • Leading zeros are dropped when exporting as csv

    I have a report that when I export as csv, leading zeros in text columns are dropped in excel. The text columns appear fine in the report, however, when I export the leading zero is gone in excel. For example, in the report my text column could have a value of 0101, when it is exported to excel it has a value of 101. The code behind the link to export to csv is f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:FLOW_EXCEL_OUTPUT_R#REGION_ID#
    Is there a way to keep the leading zero in excel?
    Regards
    Mark

    Thanks for your reply. In my query I wrapped the column with double quotes as you suggest, and added the same column for display:
    select '"'||column1||'"' execl_col, column1 disp_col from table where ....
    Using htmldb_application.g_excel_format as a conditional display I can control what is displayed on the screen and export to csv the double quoted text field. I have that part working fine. Using my previous data example, I am now seeing in excel 0101"".
    Did I wrap the field incorrectly with double quotes? How can I exclude the
    double quotes in the export to csv?
    Regards
    Mark

Maybe you are looking for

  • HT204053 apple id is working fine on computer but when using it to sign in for aps on iphone, it says 'incorrect id or password'

    apple id is working fine on computer but when using it to sign in for aps on iphone, it says 'incorrect id or password'

  • ABUMN asset transfer

    Hey Guys, When doing an inter company asset transfer we are facing an issue as the current year depreciation for tax books remains on both the old and new asset. Before doing an asset transfer I could change the key to 0000 but in my copy controls I

  • Problems with sdo_aggr_union

    I want to merge several polygons. One polygon has a whole in it (doughnut). When i merge this polygon wilth several others all i get is the hole as a polygon plus the other polygons. In other words the outer ring of the polygon has gone missing. Has

  • Question-Mark For CSH doesn't appear

    Hi. I'm trying to run a context-sensitive help system for a web-based applet. When I run CSH using an application interface, the cursor changes to a question-mark and I'm good to go. But when I'm running it from the applet, the cursor doesn't change

  • 5.0.2 still MEMORY LEAKS with Java on multiple tabs/windows

    same problem with last update. Memory Leaks (upto 2.5 GB) when Java applets load in multiple windows/tab. Someone also have this problem? My other post prior of last update: http://discussions.apple.com/message.jspa?messageID=12204453#12204453 Messag