Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

downloading a a report into excel

Former Member
0 Kudos

Hi all,

We need to enable a report ouput to download into Excel.

Could you tell me is there any material/notes/sample documents available for this feature.

Any help is greatly appreciated.

Thnx very much.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Deva,

You can do that in different ways.

1) By calling GUI_DOWNLOAD function module.

2) using ALV reports-user can download directly from the list if he wants to

3) You can display the list first and give one option for the user to download. In that write logic for downloding your file in XL format.

12 REPLIES 12

Former Member
0 Kudos

use GUI_DOWNLOAD function module & pass your final internal table to that & give file name & file type as DAT

give a parameter for filepath on the selection screen.

call the function module GUI_DOWNLOAD

& PASS, filename = your parameter name

filetype = 'ASC'

has_field_separator = 'X'

and tables

= your final internal table(which you are displaying on the output)

regards

Srikanth

Message was edited by: Srikanth Kidambi

0 Kudos

Check out the sample, you can fire this function module automatically(as it is in this program) or fire it when the user clicks on a button from the application toolbar.



report zrich_0001.


data: imara type table of mara with header line.

start-of-selection.

  select * into table imara up to 100 rows
            from mara.


  call function 'WS_EXCEL'
       exporting
            filename = 'TEST.XLS'
       tables
            data     = imara.

Regards,

Rich Heilman

0 Kudos

So that you are Unicode compliant, use the class object instead of the function module (GUI_DOWNLOAD).

DATA: BEGIN OF lt_data_tab OCCURS 0,

line(72),

END OF lt_data_tab,

l_filename TYPE string.

CONCATENATE path '\' i_name '.XLS' INTO l_filename.

READ REPORT i_name INTO lt_data_tab.

IF lines( lt_data_tab ) = 0.

MESSAGE e001(uc) WITH TEXT-TK0.

ENDIF.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = l_filename

CHANGING

data_tab = lt_data_tab[]

EXCEPTIONS

OTHERS = 0.

IF sy-subrc <> 0.

MESSAGE e001(uc) WITH TEXT-K01.

ENDIF.

Former Member
0 Kudos

Is this an ALV report? Then that is a standard functionality. Otherwise, in case of a conventional report, you need to add a button using PF-status and do the coding for user-command.(also you can go by menu system-save-local file)

Former Member
0 Kudos

Hi

you can use the FM XXL_SIMPLE_API

se the sample program XXLSTEST

Regards,

Naveen

0 Kudos

Or function module - WS_EXCEL.

Former Member
0 Kudos

Hello Deva,

You can do that in different ways.

1) By calling GUI_DOWNLOAD function module.

2) using ALV reports-user can download directly from the list if he wants to

3) You can display the list first and give one option for the user to download. In that write logic for downloding your file in XL format.

0 Kudos

thnx for the responses.

i'm using a conventional report not a alv report.

the user wants a button on the screen, and when it is clicked, the output should be downloaded into excel.

wt would be the better approach?

thnx a ton,

0 Kudos

Do you want the excel to be fired when the user pushes the button, If so, then use the WS_EXCEL in my sample above. If you just want to write it somewhere on the users harddrive, then you can use the GUI_DOWNLOAD.

Regards,

Rich Heilman

0 Kudos

Here is a sample program, where the user hits a button on the application toolbar to fire the excel.



report zrich_0001.


data: imara type table of mara with header line.

start-of-selection.

  set pf-status 'LIST'.

  select * into table imara up to 100 rows
            from mara.
  loop at imara.
    write:/ imara-matnr.
  endloop.


at user-command.

  case sy-ucomm.

    when 'FIREEXCEL'.

      call function 'WS_EXCEL'
           exporting
                filename = 'TEST.XLS'
           tables
                data     = imara.

  endcase.

Regards,

Rich Heilman

0 Kudos

if you want to download it presentation server, use GUI_DOWNLOAD,as given by me in earlier post, if user clicks on that button "download".

use AT user command event, & if sy-ucomm = 'download" place the logic here.

regards

srikanth

Former Member
0 Kudos

thnx all.