on 03-01-2006 5:41 AM
hi fiends.
following is my code for putting Internal table data to Excel file...it is doing well..
but now i want to display that excel file from same list by pressing Entr Key ...Plz Help..
tables : mseg.
Data : begin of itab occurs 0,
matnr like mseg-matnr,
menge like mseg-menge,
end of itab.
parameters : docno like mseg-mblnr.
set pf-status 'MENU'.
select * into corresponding fields of table itab from mseg
where mblnr = docno.
write : 'Material Quantity' , / .
loop at itab.
write : / itab-matnr, itab-menge .
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:\abc.xls'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
data_tab = itab
.
Hi,
This is the code , Just check it.
and set the Pf-status menu, and set the FCODE for enter
REPORT ZTEST_EXCEL .
TABLES : MSEG.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MSEG-MATNR,
MENGE LIKE MSEG-MENGE,
END OF ITAB.
PARAMETERS : DOCNO LIKE MSEG-MBLNR.
START-OF-SELECTION.
SET PF-STATUS 'MENU'. "now set the pf-status for ENTER (Green Tick as <b>ENTER</b> in the Function keys)
SELECT * INTO CORRESPONDING FIELDS OF TABLE ITAB FROM MSEG
WHERE MBLNR = DOCNO.
WRITE : 'Material Quantity' , / .
LOOP AT ITAB.
WRITE : / ITAB-MATNR, ITAB-MENGE .
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'D:abc.xls'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = ITAB.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'ENTER'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT = 'D:abc.xls'
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.
ENDIF.
ENDCASE.
Regards
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks vijay sir..
what i was missing is AT User-Command Event..
job done thanks...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try this
tables : mseg.
Data : begin of itab occurs 0,
matnr like mseg-matnr,
menge like mseg-menge,
end of itab.
parameters : docno like mseg-mblnr.
set pf-status 'MENU'.
at selection-screen.
select * into corresponding fields of table itab from mseg
where mblnr = docno.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:\assign\abc.xls'
FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
tables
data_tab = itab
.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = 'd:\assign\abc.xls'
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.
endif.
start-of-selection.
write : 'Material Quantity' , / .
loop at itab.
write : / itab-matnr, itab-menge .
regards
austin
Message was edited by: Joseph Austin Prabhu Paulthas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI madan,
1. i have made an independent form
to open any specified xls file
(using ole technology)
2. just copy paste in new program
REPORT abc.
*----
Important
TYPE-POOLS ole2.
DATA workbook TYPE ole2_object.
DATA excel TYPE ole2_object.
DATA aw TYPE ole2_object. "-- active workbook
*----
PERFORM startexcel USING 'd:\abc.xls'.
*----
INDEPENDENT FORM
*----
FORM startexcel USING filename.
CREATE OBJECT excel 'Excel.Application' .
SET PROPERTY OF excel 'Visible' = 1.
CALL METHOD OF excel 'Workbooks' = workbook.
CALL METHOD OF workbook 'Open'
EXPORTING
#1 = filename.
CALL METHOD OF excel 'ActiveWorkbook' = aw.
ENDFORM. "startexcel
regards,
amit m.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
WHEN YOU PRESS enter , handle the sy-ucomm,
case sy-ucomm.
when 'ENTER'.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = 'C:Test.xls'
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.
endif.
endcase.
or else you can try with GUI_EXEC FM
Regards
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.