cancel
Showing results for 
Search instead for 
Did you mean: 

POPUP window with YES NO Cancel buttons

Former Member
0 Kudos

HI All,

I have a senario in which user enters the login details,if the details are wrong we get a popup window asking to create a new account with three buttons in it say YES ,NO ,CANCEL.

If users press yes it should go to registration view if no come back to first view and cancel close the popup window.

I have used the below code to call the [popup with three buttons.

Can any one tell me how to or where to write the code to capture the YES NO or CANCEL buttons and act according to it.

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.
    data lo_window1         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            = 'POPUP'
                       title                  = 'POPUP WINDOW'
*                  close_in_any_case      = abap_true
                       message_display_mode   = if_wd_window=>co_msg_display_mode_selected
*                  close_button           = abap_true
                       button_kind            = if_wd_window=>co_buttons_yesnocancel                   message_type           = if_wd_window=>co_msg_type_none
*                   default_button         = if_wd_window=>co_buttons_yesnocancel
                       ).

    lo_window->open( ).

Regards,

Anusha V.

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Anusha,

You can first create associated actions for these 3 buttons & then you can create the action handlers for these actions. Take a look at the code snippet below:

* Data declaration
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 `Estimation Variant already exist` INTO TABLE L_TEXT.
INSERT `Do you want to modify?` INTO TABLE L_TEXT.
 
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( ).

Create Action with the name 'yes', 'no', 'cancel' and write coding as per the requirement.

Regards,

Uday

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

While creating Popup, you might have create Buttons also for YES, NO and CANCEL. for all these buttons you create events. and write your code inside events.

For further help check this standard application WDR_POPUP_TO_CONFIRM.

Regards

Vishnu Gupta

uday_gubbala2
Active Contributor
0 Kudos

Hi Anusha,

You can also go through this [link |http://sapdev.co.uk/sap-webapps/sap-webdynpro/wdp_displaypopup.htm]for information regarding the same.

Regards,

Uday

Former Member
0 Kudos

hi Anusha,

You will have to make use of subscribe_to_button_event method. Create three different actions for Yes . NO and Cancel and write the code to navigate to the respective view in that event handler.



lo_window->subscribe_to_button_event(
    button            = 7     " 7 is for Yes, 6 for Cancel and 8 for No 
*    button_text       = ''
    tooltip           = 'Click yes to Exit'
    action_name       = 'POPUP_YES'    " Event to handle Click on Yes.
    action_view       = l_api
*    is_default_button = ABAP_FALSE
       ).

Regards

Runal