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: 

Problems while using FM Gui_download.

Former Member
0 Kudos

Hi,

When we use FM GUI_DOWNLOAD it saves internal table into excel file in a 'Text-Tab delimited format' . Is there any FM which will store the contents in MICROSOFT EXCEL WORKBOOK format??

10 REPLIES 10

Former Member
0 Kudos

Refer this code

http://www.sapdevelopment.co.uk/file/file_uploadpc.htm

http://www.sapdevelopment.co.uk/file/file_updown.htm

Specify .xls instead of .txt

Reward points if u find helpful.

former_member181962
Active Contributor
0 Kudos

Hi Abhijeet,

the same fm can be used to download to EXCEL as well.

Just that you need to specify the file name as <Name>.xls. and pass the

HAS_FIELD_SEPARATOR = 'X'.

Regards,

Ravi

Former Member
0 Kudos

Hi Abhijit,

For downaloading to Excel file you can sipmly give the extension of file name as .xls. It will create a excel file on presentation server.

Reward points if helpful answer.

Ashvender

Former Member
0 Kudos

use GUI_DOWNLOAD and in file name specify as tab.xls along with

HAS_FIELD_SEPARATOR = 'X'.

0 Kudos

Hi all,

I am facing the same prob as Abhijeet is having.. I have tried all options u hve suggested.. Gui_download is nt working for that.

after downloading into excel format using(gui_download), if i changed the data in the excel sheet and try to save the data it directly goes to save as dialogue box.

using gui_download , it saves the data in text(tab delimited format) but it should save it as in the format microsoft work book.

if any body has the solution plaese tell me...its urgent..

Hari

Former Member
0 Kudos

USe the FM ASLM_EXCEL_TO_INTERNAL_TABLE This will Definately Work.After See ing this Give some points.

0 Kudos

Hi anilkumar,

My problem is while downloading internal table to excel file. but the FM you told is for excel to internal table.

Former Member
0 Kudos

Hi,

Please use the following code,

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm,

lv_file(80),

lv_fieldln TYPE i,

lv_def_path TYPE rlgrap-filename,

lv_mode TYPE c VALUE 'S',

lv_tmp_filename TYPE rlgrap-filename,

lv_tmp_mask(80).

FIELD-SYMBOLS: <fs_tmp_sym>.

save_ok = ok_code.

CASE save_ok.

WHEN 'EXCEL'.

*--- On click of 'Download to Excel' button transfer the ALV data to

*--- Excel sheet.

lv_tmp_mask = ',.,..'.

lv_fieldln = strlen( lv_def_path ) - 1.

ASSIGN lv_def_path+lv_fieldln(1) TO <fs_tmp_sym>.

IF <fs_tmp_sym> = '/' OR <fs_tmp_sym> = '\'.

CLEAR <fs_tmp_sym>.

ENDIF.

*--- Get the file name & path to which file has to be downloaded.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_path = lv_def_path

mask = lv_tmp_mask

mode = lv_mode

IMPORTING

filename = lv_tmp_filename

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF sy-subrc = 0.

*--- As we need to download the file in 'XLS' format add the

*--- extension '.XLS' if it is not provided by the user.

IF NOT lv_tmp_filename CS c_excel.

CONCATENATE lv_tmp_filename c_excel INTO lv_file.

ELSE.

lv_file = lv_tmp_filename.

ENDIF.

ELSE.

EXIT.

ENDIF.

*--- Down load the file to the path and filename provided above.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

filename = lv_file

filetype = 'DAT'

TABLES

data_tab = gt_excel1

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.

IF sy-subrc = 0.

MESSAGE i000(zf) WITH text-017.

ELSE.

MESSAGE e939(zf) WITH lv_file. "Errors while downloading.

ENDIF.

ENDCASE.

****************

gt_excel1 is the internal table you provide to the FM for downloading.

lv_file is automatically taken care of from the input provided by the user.

The above code is triggered when a button in Application tool bar is clicked. Please use it as needed. It will ask for the path to which file has to be downloaded and once provided it will download the table only to excel.

You can also use GUI download and pass the internal table appropriately.

It will work for sure.

Regards,

Paul.

0 Kudos

Thanks paul your code really helpfull.

Even i have used SAP_CONVERT_TO_XLS_FORMAT after gui_download & it is working fine.

Thanks lot.

0 Kudos

No Probs. Have a nice day.