Application Development and Automation 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: 
Read only

Function Module WS_EXCEL

Former Member
0 Likes
1,576

Hi all,

I need your help. I am using the FM 'WS_EXCEL' to download an internal table into an excel file. This FM creates the excel file and then automatically opens the file.

Here is the simple code that I'm using:

DATA: v_filename LIKE ibipparms-path.

v_filename = 'C:\My Documents\groupkey.xls'.

CALL FUNCTION 'WS_EXCEL'

EXPORTING

filename = v_filename

TABLES

data = i_rptd.

The file is being successfuly saved in the following path 'C:\My Documents\groupkey.xls'. However, when the FM tries to open the file it looks like is having problem with the space between 'My Documents', becuase I am getting the following 2 Windows error messages:

1. 'C:\My.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.

2. 'Documents\groupkey.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.

Note: If I change the path to 'C:\groupkey.xls' is working fine. But the user wants to save the file in 'My Documents' folder.

Any help is greatly appreciated.

Thanks,

Francisco

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
836

Try this way


CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
	EXPORTING
		FILENAME = v_filename
	CHANGING
		DATA_TAB = i_rptd[].

then call


CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
	EXPORTING
		DOCUMENT = v_filename.

a®

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
837

Try this way


CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
	EXPORTING
		FILENAME = v_filename
	CHANGING
		DATA_TAB = i_rptd[].

then call


CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
	EXPORTING
		DOCUMENT = v_filename.

a®

Read only

0 Likes
836

a®s thanks for your help!

This was my final code:


DATA: v_filename type STRING.

v_filename = 'C:My Documentsgroupkey.xls'. 

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
  EXPORTING
    FILENAME = v_filename
    FILETYPE = 'DAT'
    CONFIRM_OVERWRITE = 'X'

  CHANGING
    DATA_TAB = i_rptd[].

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
  EXPORTING
    DOCUMENT = v_filename.

Read only

Former Member
0 Likes
836

Hi,

Don't use function module WS_EXCEL.

use function module GUI_DOWNLOAD & make the file extension '.xls'.

Or you can try using FM : SAP_CONVERT_TO_XLS_FORMAT

Regards,

Tutun