Skip to Content
author's profile photo Former Member
Former Member

Excel File Format Problem while downloading in ALV Grid

Hi All,

My program gives an ALV Grid Output which contains the file download button , when I choose spread sheet as the file format , the actual data starts only from 4th line and the lines above it contain date, heading etc and the rest are blank. Is it possible that I can download only the records in the grid output with the column names and not the unnecessary log?

Also the format is not proper excel format, this same file will be used for upload into another program using the Function Module 'TEXT_CONVERT_XLS_TO_SAP'. When I load the file saved in the above format, this Function Module always fails.

Please let me know any solution for this problem

Thanks in Advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:23 AM

    Installing SAP GUI Patch Level 8.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ,

      Problem should be identified as Garbage values in Excel. There is a SAP note avaliable for this .

      Which will be implemented when you will install SAP GUI patch level 8 on your machine.

      This will surely resolve your issue.

      Thanks

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:40 AM

    Hi Dagny ,

    Use XML Transformations to download ALV data to Excel and use FM

    'ALSM_EXCEL_TO_INTERNAL_TABLE' to upload data from Excel to SAP.

    Regards,

    Suneel G

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:46 AM

    The data which comes in the beginning is not junk data, even if we downloda from SE16, those lines appear, the lines for example are :

    31.03.2009 Dynamic List Display 1

    The first line is the above line, followed by two blank lines, then comes the column names, then again a blank line ( I do not want this blank line too ), then comes the actual data.

    Hope this is clear. Are you talking about this data only ? Will it can be avoided by installing the patch you have mentioned?

    Please let me know .

    Thanks in Advance.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 08:03 AM

    Hi,

    For using this function module: 'TEXT_CONVERT_XLS_TO_SAP'

    You have to declare:

    
    
    TYPE-POOLS truxs.
    
    DATA: it_raw TYPE truxs_t_text_data.
    *      internal table declared to be passed in the
    *      function module used to convert data from xls to sap
    
    *&---------------------------------------------------------------------*
    *&Function module called to upload xls data into an internal table
    *&---------------------------------------------------------------------*
    
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = 'X'
          i_line_header        = 'X'
          i_tab_raw_data       = it_raw
          i_filename           = p_file                 "file path browsed
        TABLES
          i_tab_converted_data = it_upload[]            "int table populated
        EXCEPTIONS                                             with data
          conversion_failed    = 1                      
          OTHERS               = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    
    
    

    Hope it helps

    Regards

    Mansi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2009 at 06:02 AM

    Hi

    try this code----


    &----


    *& Form DOWNLOAD_EXCEL_TEMPLATE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM download_excel_template .

    TYPES: BEGIN OF lt_data,

    field1(20),

    field2(30),

    field3(20),

    field4(20),

    field5(20),

    field6(30),

    field7(15),

    field8(10),

    field9(10),

    field10(20),

    field11(20),

    field12(10),

    field13(20),

    field14(20),

    END OF lt_data.

    DATA: lv_file TYPE rlgrap-filename,

    li_data TYPE STANDARD TABLE OF lt_data,

    wa_data TYPE lt_data,

    lv_pathcheck type c,

    lv_file1 type string.

    wa_data-field1 = ''.

    APPEND wa_data TO li_data.

    REFRESH gi_header.

    wa_header-name = 'Company Code'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Main Asset Number'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Asset Sub Number'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Document Date'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Posting Date'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Asset Value Date'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Item Text'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Reference'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Allocation'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Amount Posted'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Percentage Rate'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Quantity'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Prior-Yr Quantity'.

    APPEND wa_header TO gi_header.

    wa_header-name = 'Curr-Yr Quantity'.

    APPEND wa_header TO gi_header.

    lv_file = gv_file.

    lv_file1 = gv_file.

    CALL METHOD cl_gui_frontend_services=>directory_exist

    EXPORTING

    directory = lv_file1

    RECEIVING

    result = lv_pathcheck

    EXCEPTIONS

    cntl_error = 1

    error_no_gui = 2

    wrong_parameter = 3

    not_supported_by_gui = 4

    OTHERS = 5.

    FIND '.xls' IN lv_file IGNORING CASE.

    IF sy-subrc = 0.

    REPLACE '.XLS' IN lv_file WITH ' ' IGNORING CASE.

    ENDIF.

    FIND '.TXT' IN lv_file IGNORING CASE.

    IF sy-subrc = 0.

    REPLACE '.TXT' IN lv_file WITH ' ' IGNORING CASE.

    ENDIF.

    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'

    EXPORTING

    file_name = lv_file

    data_sheet_name = 'DATA'

    TABLES

    data_tab = li_data

    fieldnames = gi_header

    EXCEPTIONS

    file_not_exist = 1

    filename_expected = 2

    communication_error = 3

    ole_object_method_error = 4

    ole_object_property_error = 5

    invalid_pivot_fields = 6

    download_problem = 7

    OTHERS = 8.

    IF sy-subrc <> 0.

    MESSAGE ID gv_msgid TYPE 'E' NUMBER 002.

    ENDIF.

    ENDFORM. " DOWNLOAD_EXCEL_TEMPLATE

    regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2009 at 06:46 AM

    You may directly download your internal table into excel with the FM:

    SAP_CONVERT_TO_XLS_FORMAT

    Then your FM 'TEXT_CONVERT_XLS_TO_SAP' should work fine.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.