cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing the events (OK/Cancel Buttons) in popup windows

Former Member
0 Kudos

Hello All,

When the user clicks on a button I am displaying the popup window. But I am unable to trace the event, when the user clicks on Ok or Cancel button on the popup window. The code I wrote in the windoopen method is,

window_descr->window->set_window_title( 'Select Activity Type' ).

window_descr->window->set_remove_on_close( abap_true ).

window_descr->window->set_close_in_any_case( abap_false ).

window_descr->window->set_button_kind( if_wd_window=>co_buttons_okcancel ).

Please suggest how to implement the logice in those events. Thanks in advance.

Regards,

Anand

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Anand,

I'm not sure how it works with the windowopen method. I usually use the create_popup_to_confirm method. That one, you set the type of buttons you want and what actions they trigger. Then you need to crate actions with the same name in your view. When the button is clicked, the corresponding action is executed. Here's some code that SAP gives for the method...

data: l_cmp_api type ref to if_wd_component,
            l_window_manager type ref to if_wd_window_manager,
            l_popup type ref to if_wd_window,
            l_text type string_table,
            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( ).

insert `Data where changed` into table l_text. "#EC *
insert `Do you want to save?` into table l_text. "#EC *

l_popup = l_window_manager->create_popup_to_confirm(
                   text = l_text
                   button_kind = if_wd_window=>co_buttons_yesnocancel
                   message_type = if_wd_window=>co_msg_type_question
                   window_title = 'Test: Popup to confirm'
                   window_position = if_wd_window=>co_center )."#EC *

l_api = wd_this->wd_get_api( ).

l_popup->subscribe_to_button_event(
                   button = if_wd_window=>co_button_yes
                   action_name = 'YES'
                   action_view = l_api
                   is_default_button = abap_true ).
l_popup->subscribe_to_button_event(
                   button = if_wd_window=>co_button_no
                   action_name = 'NO'
                   action_view = l_api
                   is_default_button = abap_false ).
l_popup->subscribe_to_button_event(
                   button = if_wd_window=>co_button_cancel
                   action_name = 'CANCEL'
                   action_view = l_api
                   is_default_button = abap_false ).

l_popup->open( ).

Hope that helps.

Adam

Former Member
0 Kudos

Hi Adam,

Thanks for the reply. I got the solution from the package SWDP_TEST. Thank you very much for your quick response.

Regards,

Anand