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

Problem in Dloading O/P

Former Member
0 Likes
442

Hi all,

I am trying to save a Classical report output as a excel file using CALL METHOD. wat i want is to give functionality to the user so he can select his own path to save the excel file. I was successful till that. but after it is saved, i am unable to open it. But if i copy and save the same excel i am able to open and see the output in excel. Can any one tell wat might be wrong??

I would hav copied the code but its too big to post it in the thread.

Also please tell me wat Call methods to be applied to download and save the O/P as excel.

I am using

DATA: NAME TYPE STRING,

PATH TYPE STRING,

FULLPATH TYPE STRING,

EXT TYPE STRING,

FILTER TYPE STRING,

SIZE TYPE I,

  • GUIOBJ TYPE REF TO CL_GUI_FRONTEND_SERVICES,

UACT TYPE I

SHEET TYPE OLE2_OBJECT.

CONDENSE V_FILE NO-GAPS.

EXT = 'xls'.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

EXPORTING

DEFAULT_EXTENSION = EXT

DEFAULT_FILE_NAME = NAME

FILE_FILTER = FILTER

CHANGING

FILENAME = NAME

PATH = PATH

FULLPATH = FULLPATH

USER_ACTION = UACT.

V_FILE = FULLPATH.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST

EXPORTING

DIRECTORY = V_FILE

RECEIVING

RESULT = W_RESULT

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

OTHERS = 5.

IF SY-SUBRC EQ 0.

CONCATENATE 'Excel Saved at' V_FILE 'successfully' INTO MSG SEPARATED BY SPACE.

MESSAGE MSG TYPE 'I'.

ENDIF.

*Save excel speadsheet to particular filename

CALL METHOD OF SHEET 'SaveAs'

EXPORTING

#1 = V_FILE "filename

#2 = 1. "fileFormat

  • Save Excel document

CALL METHOD OF SHEET 'SAVE'.

  • Quits out of Excel document

CALL METHOD OF SHEET 'QUIT'.

  • Closes visible Excel window, data is lost if not saved

SET PROPERTY OF APPLICATION 'visible' = 0.

Thank you.

Best regards

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
411

If I understand well what you say, you just don't use the correct technology : if your report displays a classic output (I understand it's a "list" based on WRITE abap statement?), you can't juste use OLE (call method of) to convert and save the list to an excel file. You must use CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD method, passing an internal table with comma separated values.

Read only

Former Member
0 Likes
411

directly use GUI_DOWNLOAD