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: 

How to download to Excel using ALV

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I am using ALV(block) and I would like to know on how do I download the results to Excel. Again, Thank you guys and have a nice day!

Message was edited by: viraylab

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Viraj,

The ALV contents are there in some internal table..they can be downloaded to excel file using GUI_DOWNLOAD.

For example, if ur internal used in case of ALV is itab.

Then, use this...

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'c:\myfile.xls'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

tables

data_tab = itab[]

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

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

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

ENDIF.

Reagards,

Tanveer.

<b>Please mark helpful answers</b>

6 REPLIES 6

Simha_
Employee
Employee
0 Kudos

Hi,

check this link,

it will be helpful..

http://www.cdg-inc.com/news/WhitePaper_ALV_Reporting_Power.htm

Now check it out..

Gimme ur mail id..

i will send u some docs..

Regards,

Simha.

0 Kudos

Hi,

the link you provided does not work.

Former Member
0 Kudos

Hi Viraj,

The ALV contents are there in some internal table..they can be downloaded to excel file using GUI_DOWNLOAD.

For example, if ur internal used in case of ALV is itab.

Then, use this...

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'c:\myfile.xls'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

tables

data_tab = itab[]

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

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

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

ENDIF.

Reagards,

Tanveer.

<b>Please mark helpful answers</b>

Former Member
0 Kudos

HI

GOOD

GO THROUGH THIS LINK

http://sap.ittoolbox.com/code/archives.asp?d=1721&a=s&i=10

THANKS

MRUTYUN

0 Kudos

Hi Viray,

In the ALV Grid Toolbar click on the button <b>Save List</b>...SpreadSheet to download the results to Excel.

Else you can implement the same functionality using FM: <b>SAP_CONVERT_TO_XLS_FORMAT</b> from the data in your internal table.

PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:tmptest.xls'.
DATA: itab LIKE t001 OCCURS 0 WITH HEADER LINE.
SELECT * FROM t001 INTO TABLE itab.

CALL FUNCTION <b>'SAP_CONVERT_TO_XLS_FORMAT'</b>
  EXPORTING
    i_filename     = p_file
  TABLES
    i_tab_sap_data = itab.

sbhutani1
Contributor
0 Kudos

Hi viraylab,

You can download your data in excel through alv.

If you will see in alv grid there is export button in alv grid when you will click on that there is first option which is spreadsheet if you will click on this it will ask for destination path for excel file, give the dest path and it will download the data in excel file

Hope this will help you

Regards

Sumit Bhutani

<b>Ps reward pts if helpful</b>