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

DOWN LOAD DATA INTO EXCEL FILE

HELLO,

I'V USED FUNCTION GUI_DOWNLOAD TO DOWNLOAD MY INTERNAL TABLE DATA IN EXCEL FILE.

WHEN I RUN PROG. IT GAVE OUTPUT BY ADDING ALL FIELDS IN SINGLE COL.

I WANT EACH INTERNAL FILED DATA IN SEPERATE COL OF EXCEL SHEET.

MUKESH

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 10:53 AM

    set the write_field_separator IN gui_download parameter as 'X'.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 10:54 AM

    in GUI_DOWNLOAD , try updating the parameter

    WRITE_FIELD_SEPARATOR = 'X'.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 10:54 AM

    Please use the following FM

    CALL FUNCTION <b>'SAP_CONVERT_TO_XLS_FORMAT'</b>

    EXPORTING

    • I_FIELD_SEPERATOR =

    • I_LINE_HEADER =

    i_filename =

    • I_APPL_KEEP = ' '

    tables

    i_tab_sap_data =

    • CHANGING

    • I_TAB_CONVERTED_DATA =

    • EXCEPTIONS

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 11:07 AM

    Hi Mukesh,

    Check the code below.

    <b>CODE 1</b>

    ********************************************************************

    • TESTED - MS EXCEL 97

    • NOT RECOMMENDED FOR LENGTHY OUTPUT AND LARGE DATA TABLE BROWSING

    ********************************************************************

    TABLES: USR03,DD02L.

    DATA: ZX030L LIKE X030L.

    DATA BEGIN OF ZDFIES OCCURS 0.

    INCLUDE STRUCTURE DFIES.

    DATA END OF ZDFIES.

    DATA: BEGIN OF FLDITAB OCCURS 0,

    FLDNAME(11) TYPE C,

    END OF FLDITAB.

    DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.

    DATA TNAME LIKE DD02L-TABNAME.

    SELECT * FROM USR03 INTO TABLE ITABUSR03.

    TNAME = 'USR03'.

    PERFORM GETFIELEDS.

    PERFORM SHOW123.

    ********************************************

    FORM GETFIELEDS.

    CALL FUNCTION 'GET_FIELDTAB'

    EXPORTING

    LANGU = SY-LANGU

    ONLY = SPACE

    TABNAME = TNAME

    WITHTEXT = 'X'

    IMPORTING

    HEADER = ZX030L

    TABLES

    FIELDTAB = ZDFIES

    EXCEPTIONS

    INTERNAL_ERROR = 01

    NO_TEXTS_FOUND = 02

    TABLE_HAS_NO_FIELDS = 03

    TABLE_NOT_ACTIV = 04.

    CASE SY-SUBRC.

    WHEN 0.

    LOOP AT ZDFIES.

    FLDITAB-FLDNAME = ZDFIES-FIELDNAME.

    APPEND FLDITAB.

    ENDLOOP.

    WHEN OTHERS.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    with SY-SUBRC.

    ENDCASE.

    ENDFORM.

    ***********************************

    FORM SHOW123.

    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

    EXPORTING

    FILE_NAME = 'C:\USR03.XLS'

    DATA_SHEET_NAME = 'USER LIST'

    TABLES

    DATA_TAB = ITABUSR03

    FIELDNAMES = FLDITAB

    EXCEPTIONS

    FILE_NOT_EXIST = 1

    FILENAME_EXPECTED = 2

    COMMUNICATION_ERROR = 3

    OLE_OBJECT_METHOD_ERROR = 4

    OLE_OBJECT_PROPERTY_ERROR = 5

    INVALID_FILENAME = 6

    INVALID_PIVOT_FIELDS = 7

    DOWNLOAD_PROBLEM = 8

    OTHERS = 9.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM.

    <b>CODE 2:</b>

    A simple option:

    a) form download_file .

    call function 'WS_EXCEL'

    importing

    filename = excel_name

    tables

    data = itab.

    b) call function 'WS_DOWNLOAD'

    exporting

    filename = o_file

    filetype = 'DAT'

    tables

    data_tab = i_tab

    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

    no_authority = 10

    others = 11.

    if sy-subrc = 0.

    message 'File is downloaded successfully' type 'I'.

    endif.

    Reward points if this helps.

    Manish

    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.