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

Clear Custom Control Area

Former Member
0 Likes
1,508

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.

5 REPLIES 5
Read only

Former Member
0 Likes
953

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.

Read only

0 Likes
953

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

Read only

Former Member
0 Likes
953

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

Read only

0 Likes
953

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

Read only

Former Member
0 Likes
953

I used method 'free' and it worked fine for me...

Thanks