cancel
Showing results for 
Search instead for 
Did you mean: 

How to close the window on click of a button

Former Member
0 Kudos

Hi,

I have an application which consists of two windows.

I am able to open one window from another window using

lo_window = lo_window_manager->create_window(

window_name = 'ZDUPLICATE'

title = 'DUPLICATE CANDIDATES LISTS'

close_in_any_case = abap_true

message_display_mode = if_wd_window=>co_msg_display_mode_selected

close_button = abap_true

message_type = if_wd_window=>co_msg_type_none

).

But the problem is on the click of a button i want to close the opened window.

Please let me know the solutions

Thanks

Bala Duvvuri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If u r opening the pop up from view then call the component controller method from view

and in component controller method write the coding related to pop up

wd_this->mo_popup = lo_win_manager->create_window(

title = lv_title

window_name = lv_window_name

button_kind = lv_btn_kind

message_type = lv_message_type ).

wd_this->mo_popup->open( ).

where mo_popup is an attribute in component controller of type ref to if_wd_window.

when you click on the button to close the window then call in action method

component controller method wd_comp_controller->close().

in component controller close method write the following coding

wd_this->mo_popup->close().

Former Member
0 Kudos

Thanks sridevi that solved my problem.

thanks all

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

You should not re-create the lo_window attribute again.

Do the following:

1. In the component controller OR view controller, define an attribute lo_window of type IF_WD_WINDOW

2. Create and open the window wherever required.


lo_window = lo_window_manager->create_window(
window_name = 'ZDUPLICATE'
title = 'DUPLICATE CANDIDATES LISTS'
close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
close_button = abap_true
message_type = if_wd_window=>co_msg_type_none
).
lo_window->open( ).

3. In the event handler method write only the following statement for closing the window

 lo_window->close( ). 

Regards

Wenonah

Former Member
0 Kudos

Hi Bala

You need to write it in the event handler of the button you are using to close the window from. However, for this method you also have to define lo_window (the reference to the object) as a global attribute (either in the view, or the component controller)

Regards,

Wenonah

Former Member
0 Kudos

I wrote the following code

method ONACTIONCANCEL .

try.

data:

lv_url_string type string,

lt_parameters type tihttpnvp,

lo_api_componentcontroller type ref to if_wd_component,

lo_window_mgr type ref to if_wd_window_manager,

lo_window type ref to if_wd_window,

lv_title type string,

lv_application type string.

DATA:

LO_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER,

LO_EX TYPE REF TO CX_ROOT.

    • Get a reference to the window manager.

lo_api_componentcontroller = wd_comp_controller->wd_get_api( ).

lo_window_mgr = lo_api_componentcontroller->get_window_manager( ).

data lo_window_manager type ref to if_wd_window_manager.

data lo_api_component type ref to if_wd_component.

*data lo_window type ref to if_wd_window.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

lo_window = lo_window_manager->create_window(

window_name = 'ZDUPLICATE'

title = 'DUPLICATE CANDIDATES LISTS'

close_in_any_case = abap_true

message_display_mode = if_wd_window=>co_msg_display_mode_selected

close_button = abap_true

message_type = if_wd_window=>co_msg_type_none

).

  • close the new window.

lo_window->close( ).

CATCH CX_HRRCF.

CATCH CX_ROOT INTO LO_EX.

CALL METHOD CL_HRRCF_EXCEPTION_HANDLER=>WRITE_EXCEPTION_LOG

EXPORTING

EX = LO_EX.

CALL METHOD LO_MESSAGE_MANAGER->REPORT_T100_MESSAGE

EXPORTING

MSGID = 'HRRCF0002'

MSGNO = '800'

MSGTY = 'A'.

ENDTRY.

endmethod.

it is not working.

any other solutions

Former Member
0 Kudos

Hi,

After creating the window, lo_window, you will be invoking:

lo_window->open( ).

Similarly, whenever you want to close the window, just invoke:

lo_window->close( ).

Regards,

Wenonah

Former Member
0 Kudos

Hi Wenonah Jaques ,

Where do i need to write

lo_window->close( )

send me the full code snippet.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Not a problem. Just add a little extra code after the create window to register your own action for the close button:


 l_api = wd_this->wd_get_api( ).
  l_window->subscribe_to_button_event(
               button            = if_wd_window=>co_button_cancel
               action_name       = ACTION_CANCEL'
               action_view       = l_api
               is_default_button = abap_true ).

  l_window->open( ).

Former Member
0 Kudos

Thomas,

Thanks for the reply.

i dont understand what is l_api.I assume it is type ref to if_wd_component.if not send me the decalration part.

and also i have another doubt.

In that window i am displaying a table of entries and after selecting an entry and click on Selected Candidate button it should call another method and it should close the window.

I am able to call action but dont know how to close the window

Please let me the solutions

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

dont understand what is l_api.

Sorry about that. l_api is type ref to if_wd_view_controller.


data: l_window_manager type ref to if_wd_window_manager,
        l_cmp_api        type ref to if_wd_component,
        l_window         type ref to if_wd_window,
        l_api            type ref to if_wd_view_controller.


  l_cmp_api        = wd_comp_controller->wd_get_api( ).
  l_window_manager = l_cmp_api->get_window_manager( ).

I'm hooking the standard cancel or ok button. You can do this if you want to fire your own logic on these standard events. You can also do as others have suggested and save a reference to the window and close it manually as well.