cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ID of the button used in a pop-up window

UmaArjunan
Active Participant
0 Kudos

I want to control the closing of pop-up window based on the warning / error message. I have written the code in the DO-before action to close the pop-up window.

Warning message / erorr messages are thrown based on selecting the row in a table in the pop-up window.

On selecting a particular row , user can see the error / warning message of that row. Now i want to close the pop-up window when there is no error / warning messsage.

For that I want to get the button id of pop-up window. ?How to get ID of the button used in a pop-up window. Please suggest

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

You can get the ID of the button as follows :

In the action handler of the button

DATA : lv_event type string.

lv_event = wdevent->get_string('ID').

Lv_event will have the ID of the button.

UmaArjunan
Active Participant
0 Kudos

Thanks for the reply.

i can get the value  WD_OK as the button ID in the action handler. I want to perform some logic using this buttion id in the wd do before action. how to compare the value of Button ID in that method.

Former Member
0 Kudos

Given your requirement I would suggest doing this.

You don't need to code anything in the dobeforeaction.

Try this.

in the event handler your button in the popup :

method onactionclose .

  data: lo_cmp             type ref to if_wd_component,

        lo_window_manager  type ref to if_wd_window_manager,

        lo_popup           type ref to if_wd_window,

        lo_view            type ref to if_wd_view_controller,

        lv_text            type string,

        lt_text            type table of string.

  lo_cmp            = wd_comp_controller->wd_get_api( ).

  lo_window_manager = lo_cmp->get_window_manager( ).

 

  insert `Do you want to close this popup?` into table lt_text. 

  lo_popup = l_window_manager->create_popup_to_confirm(

                text            = lt_text

                button_kind     = if_wd_window=>co_buttons_yesno

                message_type    = if_wd_window=>co_msg_type_question

                window_title    = 'Test: Confirm action'

                window_position = if_wd_window=>co_center )."#EC *

  lo_view = wd_this->wd_get_api( ).

  lo_popup->subscribe_to_button_event(

               button            = if_wd_window=>co_button_yes

               action_name       = 'YES'

               action_view       = lo_view "Your popup view

               is_default_button = abap_true ).

  lo_popup->open( ).

endmethod.

And then create an Action 'YES' in the view of your popup and do the coding for closing the popup there.

Answers (1)

Answers (1)

Former Member
0 Kudos

Or you can also use the subscribe_to_button_event( ) function in your popup view to handle an event on the button 'WD_OK'.

Check for warning/Error messages and then if needed call the window_close( ) function and you are done.

Kiron