2006 Sep 25 9:43 AM
Hi Experts,
I am using custom-control to embed an excel file in SAP. The problem is that when I m trying to open another excel file the one opened before still exists. I have debugged the program and found that the code is opening the new excel file but it is hidden behind the one opened before that file. I am using interface I_OI_DOCUMENT_PROXY and method 'OPEN_DOCUMENT' to embed the the excel file. I tried 'CLOSE_DOCUMENT', 'CLEAR_DOCUMENT' & 'CLEAR_SELECTION' methods but of no use.
Below is the code I am using to embed an excel file into SAP. Hope this will help to understand the problem.
******Begin of Code**********************************
IF NOT firsttime IS INITIAL.
CLEAR firsttime.
CLEAR: is_gui_container,
l_document_url.
lv_cnt = lv_cnt + 1.
*
CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
IMPORTING
control = g_control
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CREATE OBJECT g_container
EXPORTING
container_name = 'CONT1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
is_gui_container-application_name = 'Our test'.
is_gui_container-container_name = 'CONT1'.
is_gui_container-rep_id = sy-repid .
is_gui_container-dynpro_nr = '0100'.
PERFORM pc_has_excel_or_excel2003.
CALL METHOD g_control->destroy_control.
CALL METHOD g_control->init_control
EXPORTING
r3_application_name = is_gui_container-application_name
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = g_container
register_on_close_event = ' '
register_on_custom_event = ' '
rep_id = is_gui_container-rep_id
dynpro_nr = is_gui_container-dynpro_nr
IMPORTING
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CALL METHOD g_control->get_table_collection
IMPORTING
table_collection = g_table_coll
retcode = g_retcode.
CALL METHOD g_control->get_document_proxy
EXPORTING
document_type = soi_doctype_excel97_sheet
IMPORTING
document_proxy = g_document
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CONCATENATE 'file://' p_file INTO l_document_url.
CALL METHOD g_document->clear_selection
EXPORTING
no_flush = ' '
IMPORTING
retcode = g_retcode.
CALL METHOD g_document->open_document
EXPORTING
document_url = l_document_url
open_inplace = 'X'
IMPORTING
retcode = g_retcode.
ENDIF.
******End of Code*************************************
Let me know if you want more details.
Hi Experts,
I am using custom-control to embed an excel file in SAP. The problem is that when I m trying to open another excel file the one opened before still exists. I have debugged the program and found that the code is opening the new excel file but it is hidden behind the one opened before that file. I am using interface I_OI_DOCUMENT_PROXY and method 'OPEN_DOCUMENT' to embed the the excel file. I tried 'CLOSE_DOCUMENT', 'CLEAR_DOCUMENT' & 'CLEAR_SELECTION' methods but of no use.
Below is the code I am using to embed an excel file into SAP. Hope this will help to understand the problem.
******Begin of Code**********************************
IF NOT firsttime IS INITIAL.
CLEAR firsttime.
CLEAR: is_gui_container,
l_document_url.
lv_cnt = lv_cnt + 1.
*
CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
IMPORTING
control = g_control
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CREATE OBJECT g_container
EXPORTING
container_name = 'CONT1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
is_gui_container-application_name = 'Our test'.
is_gui_container-container_name = 'CONT1'.
is_gui_container-rep_id = sy-repid .
is_gui_container-dynpro_nr = '0100'.
PERFORM pc_has_excel_or_excel2003.
CALL METHOD g_control->destroy_control.
CALL METHOD g_control->init_control
EXPORTING
r3_application_name = is_gui_container-application_name
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = g_container
register_on_close_event = ' '
register_on_custom_event = ' '
rep_id = is_gui_container-rep_id
dynpro_nr = is_gui_container-dynpro_nr
IMPORTING
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CALL METHOD g_control->get_table_collection
IMPORTING
table_collection = g_table_coll
retcode = g_retcode.
CALL METHOD g_control->get_document_proxy
EXPORTING
document_type = soi_doctype_excel97_sheet
IMPORTING
document_proxy = g_document
retcode = g_retcode.
CALL METHOD c_oi_errors=>show_message
EXPORTING
type = 'E'.
CONCATENATE 'file://' p_file INTO l_document_url.
CALL METHOD g_document->clear_selection
EXPORTING
no_flush = ' '
IMPORTING
retcode = g_retcode.
CALL METHOD g_document->open_document
EXPORTING
document_url = l_document_url
open_inplace = 'X'
IMPORTING
retcode = g_retcode.
ENDIF.
******End of Code*************************************
Let me know if you want more details.
2006 Sep 25 10:02 AM
Hi Rajesh,
Try to Rrefresh that custom control, I had a similar problem with table control then i used the below method to solve that problem.
set row & column to be stable after refresh
CLEAR l_s_stable.
l_s_stable-row = 'X'.
l_s_stable-col = 'X'.
CALL METHOD alvgrid->refresh_table_display
EXPORTING
is_stable = l_s_stable
i_soft_refresh = 'X'..
if you search you may find out any other similar methods for your requirements..
Reward with points if usefull..
Regards,
Srinivas.
2006 Sep 25 10:44 AM
Hi Srinivas,
There is no 'refresh' method for the instance I am using. I have tried close, clear, release methods but none of them actually fulfilling my requirement.
Thanks anyway.
Rajesh
2006 Sep 25 10:06 AM
Hi Rajesh,
Goto se38->Environment->control Examples there you will get some examples for opening excel file etc..
there if you find any example which is similar to your requirement debugg that and find out how he has done that.
Reward if usefull..
Regards,
Srinivas
2006 Sep 25 11:19 AM
Hi Sri,
I have seen this Transaction before. Here in the examples the program is opening an excel document separately. But in my program I have embedded the excel file and want to close or clear the embedded excel file once I am done with my processing or when I am trying to open another excel file.
Thanks
Rajesh
2006 Sep 27 9:23 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |