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: 

Download to Excel Function in ALV

Former Member
0 Kudos

Hai Friends,

I am using the following methods to download the report to an Excel Sheet from ALV.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

CALL FUNCTION 'GUI_DOWNLOAD'

The report is downloaded to Excel but the Column names are not displayed. It is displaying as F1, F2, F3..................

How can i solve this?.

6 REPLIES 6

Former Member
0 Kudos

Instead of GUI_DOWNLOAD use

SAP_CONVERT_TO_XLS_FORMAT

Hope this helps!!

Regards,

Prashant

I355602
Advisor
Advisor
0 Kudos

Hi,

Use this link:-

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

If you only want to transfer the data to Excel like when you transfer the data from

ALV to Excel simply use the Function Modules:

XXL_SIMPLE_API

If you want more modifications when you transfer it to Excel use:

XXL_FULL_API

Hope this helps you.

Thanks & Regards,

Tarun Gambhir

Former Member
0 Kudos

Hi,

I have also used the same method and function module for downloading into excel. You have to append the header part to the same interanl table along with the values that is getting downloded to excel which is being passed to the FM.

Former Member
0 Kudos

Hai Friends,

still i didnt get the column names in the Excel when i download.

Former Member
0 Kudos

Hi ,

Why are you using the methods to download the data to excel , ALV has an inbuilt functionality to download the data into excel , why not use it .

If you want to use the methods then you will have to insert the header to the internal table as its first line and then use the method to download the file.,

Regards

Arun

Former Member
0 Kudos

Hi,

Please check with the sample code below:

*"Excel sheet header

CLEAR e_excel.

MOVE text-001 TO e_excel-var1.

MOVE text-002 TO e_excel-var2.

APPEND e_excel TO t_excel.

CLEAR e_excel.

UNASSIGN <fs_t_final>.

REFRESH t_excel.

LOOP AT t_final

ASSIGNING <fs_t_final>.

CHECK <fs_t_final> IS ASSIGNED.

*"Data continued after the header part

MOVE <fs_t_final>-var1 TO e_excel-var1.

MOVE <fs_t_final>-var2 TO e_excel-var2.

APPEND e_excel TO t_excel.

CLEAR e_excel.

data: w_savetitle TYPE string,

w_filname TYPE string,

w_filename TYPE string,

w_path TYPE string,

w_fpath TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = w_savetitle

CHANGING

filename = w_filname

path = w_path

fullpath = w_fpath

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

OTHERS = 4.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = w_filename

filetype = ASC

write_field_separator =

codepage =

TABLES

data_tab = t_excel

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.