cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a reference to a popup button?

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

pretty dumb question, but it's driving me mad 😕

I create a popup in the following way:

     lo_window         = lo_window_manager->create_window(

                         window_name            = 'CONDITIONS_POPUP'

                          title                  = lv_title

*                       close_in_any_case      = abap_true

                         message_display_mode   = if_wd_window=>co_msg_display_mode_selected

                         close_button           = abap_false

                         button_kind            = if_wd_window=>CO_BUTTONS_OKCANCEL

                         message_type           = if_wd_window=>co_msg_type_none

                         default_button         = if_wd_window=>co_button_ok

                      ).

Notice that I need basically two buttons; one to confirm, and the other one to cancel.

After that, I bind both buttons to the corresponding actions (in the meantime, I also change their labels):

*Subscribe to event OK

     lo_window->subscribe_to_button_event(

     button             = if_wd_window=>co_button_ok

     BUTTON_TEXT        = 'I agree'

     action_name        = 'CONFIRM_OK'

     action_view        = L_RUNTIMEAPI

     ).

*Subscribe to event Cancel

     lo_window->subscribe_to_button_event(

     button             = if_wd_window=>co_button_cancel

     BUTTON_TEXT        = 'I disagree'

     action_name        = 'CONFIRM_CANCEL'

     action_view        = l_runtimeapi

     ).


Now... the task is simple: I have to enable/disable dynamically the OK button. In order to do so, I have to get a reference to that WD UI element in WDDOMODIFYVIEW so that I can easily adjust the ENABLED property. The odd fact is that I cannot find that element in debug navigating thru the VIEW object... and I need an ID to use the VIEW's GET_ELEMENT method.

Could anyone help me with this - apparently - simple task? Any help will be appreciated .


Accepted Solutions (1)

Accepted Solutions (1)

Abhinav_Sharma
Contributor
0 Kudos

Hi Matteo.

If you want to enable or disable the POPUP buttons you can use SET_BUTTON_ENABLED method of IF_WD_WINDOW.

There are two parameters one of type WDR_POPUP_BUTTON and another is boolean to set the button enabled. By default all the popup buttons are enabled. So you can call something like:

lo_window->set_button_enabled(

     button             = if_wd_window=>co_button_ok

     is_enabled = abap_false ). " To disable the okay button

Hope it helps.

Regards

Abhinav

matteo_montalto
Contributor
0 Kudos

Thanks abhinav, that did the trick.

There's just a thing missing; how to obtain window reference in WDDOMODIFYVIEW.

Did it as follows:

DATA w TYPE REF TO if_wd_window.
     w = wd_this->wd_get_api( )->get_embedding_window( ).

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

As Abhinav said you can use the above code.

If you want the refernce global please declare a attribute at component controller level and pass the reference of lo_window post create_window method.

With the reference you can play with the enabling and disabling.

eg:

global_reference ?= lo_window.