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: 

opening excel file automatically

former_member189406
Active Participant
0 Kudos

guys,

how do i make my excel fiel sutomatically open when i press the download button...

actually , am downling values into excel file using gui_download.....now, i wanna make it open automatically after downloading..........

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi balaji,

after the FM GUI_DOWNLOAD...

use CL_GUI_FRONTEND_SERVICES=>EXECUTE

W_APPLICATION = 'EXCEL'.

W_PARAMETER = W_PATH.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

EXPORTING

  • DOCUMENT =

APPLICATION = W_APPLICATION

PARAMETER = W_PARAMETER

  • DEFAULT_DIRECTORY =

  • MAXIMIZED =

  • MINIMIZED =

  • SYNCHRONOUS =

  • OPERATION = 'OPEN'

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

BAD_PARAMETER = 3

FILE_NOT_FOUND = 4

PATH_NOT_FOUND = 5

FILE_EXTENSION_UNKNOWN = 6

ERROR_EXECUTE_FAILED = 7

SYNCHRONOUS_FAILED = 8

NOT_SUPPORTED_BY_GUI = 9

others = 10.

hope this helps,

priya.

10 REPLIES 10

Former Member
0 Kudos

Hello,

Use the FM.

<b>RH_START_EXCEL_WITH_DATA</b>.

Check this sample report:

REPORT abc.

data : t001 like table of t001 with header line.

select * from t001 into table t001.

CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'

EXPORTING

DATA_FILENAME = 'TEST.DAT'

DATA_PATH_FLAG = 'W'

  • DATA_ENVIRONMENT =

DATA_TABLE = t001[]

  • MACRO_FILENAME =

  • MACRO_PATH_FLAG = 'E'

  • MACRO_ENVIRONMENT =

WAIT = 'X'

  • DELETE_FILE = 'X'

EXCEPTIONS

NO_BATCH = 1

EXCEL_NOT_INSTALLED = 2

INTERNAL_ERROR = 3

CANCELLED = 4

DOWNLOAD_ERROR = 5

NO_AUTHORITY = 6

FILE_NOT_DELETED = 7

OTHERS = 8

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Vasanth

Former Member
0 Kudos

Use the method EXECUTE in the class CL_GUI_FRONTEND_SERVICES

Manoj

Former Member
0 Kudos

Balaji,

Try this (l_file is the name of the file you wish to open

CALL METHOD cl_gui_frontend_services=>execute

EXPORTING

document = l_file

maximized = 'X'

operation = 'OPEN'

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

bad_parameter = 3

file_not_found = 4

path_not_found = 5

file_extension_unknown = 6

error_execute_failed = 7

synchronous_failed = 8

not_supported_by_gui = 9

OTHERS = 10.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Former Member

Hi Balaci,

here a short example:

TABLES: MARA.

*

DATA: DATEI_PC TYPE STRING VALUE 'D:\MATNR.TXT'.

*

TYPES: BEGIN OF IMARA,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MATNR,

END OF IMARA.

*

DATA: ITAB TYPE TABLE OF IMARA WITH HEADER LINE.

*

START-OF-SELECTION.

*

SELECT MATNR MTART INTO TABLE ITAB FROM MARA UP TO 10 ROWS.

*

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

FILENAME = DATEI_PC

CHANGING

DATA_TAB = ITAB[].

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

EXPORTING

DOCUMENT = DATEI_PC.

*

Regards, Dieter

Former Member
0 Kudos

hi

good

gui_download ll help you to down load the data from sap ssytem to the excel file,but i dont think this function module ll help you to open the excel sheet automatically.

You have to open your excel sheet of your own.

thanks

mrutyun^

Former Member
0 Kudos

hi balaji,

after the FM GUI_DOWNLOAD...

use CL_GUI_FRONTEND_SERVICES=>EXECUTE

W_APPLICATION = 'EXCEL'.

W_PARAMETER = W_PATH.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

EXPORTING

  • DOCUMENT =

APPLICATION = W_APPLICATION

PARAMETER = W_PARAMETER

  • DEFAULT_DIRECTORY =

  • MAXIMIZED =

  • MINIMIZED =

  • SYNCHRONOUS =

  • OPERATION = 'OPEN'

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

BAD_PARAMETER = 3

FILE_NOT_FOUND = 4

PATH_NOT_FOUND = 5

FILE_EXTENSION_UNKNOWN = 6

ERROR_EXECUTE_FAILED = 7

SYNCHRONOUS_FAILED = 8

NOT_SUPPORTED_BY_GUI = 9

others = 10.

hope this helps,

priya.

0 Kudos

priya,

I used ur logic...still am not getting the field names....

0 Kudos

Hi Balaji,

did you try my example. Esp. the CL...=>EXECUTE?

You only have to give the filname which you have

downloaded.

regards, Dieter

0 Kudos

hi deiter,

am having a small problem while downloading itself....

I am not getting the field names to be displayed at the top....

only the values are displayed.............

0 Kudos

Hi Balaji,

here a short simple way.

first download the header, second download the data with parameter append.

Here the example:

TABLES: MARA.

*

DATA: DATEI_PC TYPE STRING VALUE 'D:\MATNR.XLS'.

*

TYPES: BEGIN OF IMARA,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MATNR,

END OF IMARA.

*

DATA: ITAB TYPE TABLE OF IMARA WITH HEADER LINE.

*

<b>DATA: begin of header occurs 0,

txt1(20),

txt2(20),

end of header.</b>

*

START-OF-SELECTION.

*

<b> header-txt1 = 'Material'. header-txt2 = 'Materialart'. append header.</b>

*

SELECT MATNR MTART INTO TABLE ITAB FROM MARA UP TO 10 ROWS.

*

<b> CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

FILENAME = DATEI_PC

WRITE_FIELD_SEPARATOR = 'X'

CHANGING

DATA_TAB = header[].</b>

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

FILENAME = DATEI_PC

WRITE_FIELD_SEPARATOR = 'X'

<b> append = 'X'</b>

CHANGING

DATA_TAB = ITAB[].

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

EXPORTING

DOCUMENT = DATEI_PC.

*