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

How to download output of a report in an excel .

Hi All,

I am working on a report.In the report I have to give an option to download the output of the report in an excel.In selection screen a check box is there which if we click will save the output.Please suggest how to do it?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 02, 2008 at 01:29 PM

    Hi,

    Use GUI_DOWNLOAD function to download output of a report in the presentation server.

    Pass the final internal table (O.P) and the Filepath to the function.

    Reward points if useful

    Thanks,

    Kishore

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 02, 2008 at 03:56 PM

    Hi

    In Selection screen, write below code.

    PARAMETER p_fname LIKE rlgrap-filename DEFAULT 'd:\test.xls'.

    In your report coding, once you get wanted output into internal table, then use below function module and pass internal table to that function module. You will get the output into XL sheet.

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    filename = p_fname

    filetype = 'DAT'

    TABLES

    data_tab = internal table

    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.

    Reward if it is useful.

    Thanks

    Siva kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2008 at 03:58 PM

    This one is probably the best to use --you'll need to create a field catalog of your internal table

    Get your original data into a table <FS0>

    build a field catalog

    now use the following method as a template to download to EXCEL.

    Works a treat.

    Here's the code.

    method download_to_excel.

    field-symbols:

    <fs0> type standard table,

    <fs1> type standard table.

    assign g_outtab1->* to <fs0>.

    assign g_fldcat1->* to <fs1>.

    call function 'LVC_TRANSFER_TO_KKBLO'

    exporting

    it_fieldcat_lvc = <fs1>

    • is_layout_lvc = m_cl_variant->ms_layout

    is_tech_complete = ' '

    importing

    es_layout_kkblo = ls_layout

    et_fieldcat_kkblo = lt_fieldcat.

    loop at lt_fieldcat into lt_fieldcat_wa.

    clear lt_fieldcat_wa-tech_complete.

    if lt_fieldcat_wa-tabname is initial.

    lt_fieldcat_wa-tabname = '1'.

    modify lt_fieldcat from lt_fieldcat_wa.

    endif.

    l_tabname = lt_fieldcat_wa-tabname.

    endloop.

    call function 'ALV_XXL_CALL'

    exporting

    i_tabname = l_tabname

    is_layout = ls_layout

    it_fieldcat = lt_fieldcat

    i_title = sy-title

    tables

    it_outtab = <fs0>

    exceptions

    fatal_error = 1

    no_display_possible = 2

    others = 3.

    if sy-subrc <> 0.

    message id sy-msgid type 'S' number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    • ...

    endmethod.

    Cheers

    jimbo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 05:33 AM

    Thanks for all help.

    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.