cancel
Showing results for 
Search instead for 
Did you mean: 

Handling the events of the default buttons of my popup window

Former Member
0 Kudos

Hi!

I have 2 windows, WMAIN and WPOPUP, and 2 views, VMAIN and VPOPUP. WMAIN contains VMAIN view and the WPOPUP contains the VPOPUP view.

The popup is called from the main with a buttonclick. I'm using the default OK/Cancel buttons for the popup, and I would like to handle the OK button's event (APPLY_RESULTS). I would like to use something like that, but it's causing DUMP for me.

It is the code of the starter button in the VMAIN view:

DATA: lo_window TYPE REF TO if_wd_window,
        lo_window_manager TYPE REF TO if_wd_window_manager,
        lo_api_component TYPE REF TO IF_WD_COMPONENT.

    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            = 'WPOPUP'
                       message_display_mode   = if_wd_window=>co_msg_display_mode_selected
                       button_kind            = if_wd_window=>CO_BUTTONS_OKCANCEL "OK/Cancel
                       message_type           = if_wd_window=>co_msg_type_none
                       default_button         = if_wd_window=>co_button_ok
                       ).

    DATA:  lo_view_controller TYPE REF TO if_wd_view_controller.

    lo_view_controller = wd_this->wd_get_api( ).

    " subscribe action for Ok button
    lo_window->subscribe_to_button_event(
            button             = if_wd_window=>co_button_ok
            action_name        = 'APPLY_RESULTS'
            action_view        = lo_view_controller
            is_default_button  = abap_true ).

    lo_window->open( ).

The dump occurs during the "subscribe_to_button_event" method, because - I think - the lo_view_controller points to the wd_this, which is the VMAIN view, and not the VPOPUP view.

How can I correct this? I hope it will be easy for you I'm stucked with it a bit...

Thank you

Tamá

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear Tamás ,

You are correct the API refers to WD_THIS.

You can correct the error by 2 ways:

1. Create APPLY_RESULTS event in Current View and handle your button in the calling view itself.

2. Subscribe buttons in WDINIT method of view (say VPOPUP in windowWPOPUP) and create APPLY_RESULTS event in VPOPUP view.

Regards.

Former Member
0 Kudos

Thank you for the input.

I would like to make additinal checks before leaving the popup, so the 1st version is not good for me.

So I think subscribing the event in the WDDOINIT would be good.

Do you have an example for this?

Thank you

Tamá

ChrisPaine
Active Contributor
0 Kudos

Hello,

here's an example where I had an employee search popup - which i wanted to validate the selections before closing.

in the component controller in method to launch popup.


* set title of window

  l_title_text =
    wd_assist->if_wd_component_assistance~get_text( '001' ). "Search for Emp in structure


* now show the window.
  lo_api_component  = wd_this->wd_get_api( ).
  lo_window_manager = lo_api_component->get_window_manager( ).
  wd_this->ao_search_window = lo_window_manager->create_window(
                     window_name            = 'EMP_SEARCH_POPUP_W'
                     title                  = l_title_text
                     message_display_mode   = if_wd_window=>co_msg_display_mode_selected
                     close_button           = abap_true
                     close_in_any_case      = abap_false
                     button_kind            = if_wd_window=>co_buttons_ok
                     message_type           = if_wd_window=>co_msg_type_none
                     default_button         = if_wd_window=>co_button_ok
                     ).


  wd_this->ao_search_window->open( ).

and in the view: in WDDOINIT



  lo_view_controller = wd_this->wd_get_api( ).

  lo_window = wd_comp_controller->ao_search_window.


  lo_window->set_on_close_action( view = lo_view_controller
                                  action_name = 'CANCEL_BUTTON' ).

  l_button_text =
    wd_assist->if_wd_component_assistance~get_text( '002' ).

  lo_window->subscribe_to_button_event(
     button            = if_wd_window=>co_button_ok
     button_text       = l_button_text
     action_name       = 'OK_BUTTON'
     action_view       = lo_view_controller
     is_default_button = abap_true ).

and then in the handler for OK_BUTTON


 l_is_ok = wd_comp_controller->on_highlight_employee( ).

  if l_is_ok = abap_true.

    wd_comp_controller->ao_search_window->close( ).
  else.
...

hope that's a useful example.

Cheers,

Chris