05-12-2006 2:36 AM
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
05-12-2006 4:35 AM
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>
05-12-2006 4:06 AM
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.
05-12-2006 4:08 AM
05-12-2006 4:35 AM
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>
05-12-2006 4:41 AM
05-12-2006 4:47 AM
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.
05-12-2006 5:09 AM
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>