cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Webdynpro Popup

Former Member
0 Kudos

Hi,

In abap webdynpro when i click save button I want to have a popup with two buttons asking for "do you want to continue" 'yes' or 'no'. if 'yes' navigate to next screen .if 'no' remain in same screen.How to get this done.

Please help.

Regards,

Rheema Rahael.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182190
Active Participant
0 Kudos

Hello,

You can use this code as reference..

lo_window_manager TYPE REF TO if_wd_window_manager,

lo_popup TYPE REF TO if_wd_window,

lv_text TYPE string_table,

lo_api TYPE REF TO if_wd_view_controller,

lv_string TYPE string_table,

l_string TYPE string,

l_title type string.

*display confirmation window

lo_cmp_api = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_cmp_api->get_window_manager( ).

lo_popup = lo_window_manager->create_popup_to_confirm(

text = lv_string

button_kind = if_wd_window=>co_buttons_yesno

window_title = l_title

close_button = abap_false

message_type = if_wd_window=>co_msg_type_warning

window_position = if_wd_window=>co_center ).

lo_api = wd_this->wd_get_api( ).

lo_popup->subscribe_to_button_event(

button = if_wd_window=>co_button_yes

action_name = 'CANC'

action_view = lo_api

is_default_button = abap_false ).

lo_popup->subscribe_to_button_event(

button = if_wd_window=>co_button_no

action_name = 'NO'

action_view = lo_api

lo_popup->open( ).

create two actions CANC and NO in the Action list of your view.

Write your code what you want in these actions as per your requirement.

Hope this solves your problem.

Regards,

Ismail.

Answers (2)

Answers (2)

rainer_liebisch
Contributor
0 Kudos

Hi guys,

don't use the class CL_WD_POPUP_FACTORY, as it is deprecated. The first answer is the correct one.

Regards,

Rainer

Former Member
0 Kudos

Hi Rheema

lets say you want to generate a popup when user press the save button.

Create the action associated with save button : SAVE_DATA.

Go inside the code of action SAVE_DATA and add following code:

DATA : lr_component_api TYPE REF TO if_wd_component.

DATA : lr_popup TYPE REF TO if_wd_popup_to_confirm.

DATA l_controller_api TYPE REF TO if_wd_controller.

DATA : l_configuration TYPE wdr_popup_to_confirm.

DATA : l_text_table TYPE string_table,

ls_text_table TYPE string .

*

l_controller_api = wd_this->wd_get_api( ).

lr_component_api = wd_comp_controller->wd_get_api( ).

ls_text_table = 'Are you sure you want to save record?'.

APPEND ls_text_table TO l_text_table .

TRY.

CALL METHOD cl_wd_popup_factory=>popup_to_confirm

EXPORTING

component = lr_component_api

text = l_text_table

window_title = 'Confirmation'

configuration = l_configuration

RECEIVING

popup_to_confirm = wd_this->popup.

CATCH cx_wd_runtime_repository .

ENDTRY.

wd_this->popup->subscribe_to_events(

controller = l_controller_api

handler_name = 'ON_CONFIRM_SAVE' ).

Go to the attribute of your view and add an attribute 'POPUP' of type IF_WD_POPUP_TO_CONFIRM.

when you will press the save button the action SAVE_DATA will be triggered and a popup will be generated.

To handle the action related to the buttons appearing on the popup window ( yes, no and cancel) create one more method in your view having name 'ON_CONFIRM_SAVE' (method type must be event handler) . in that event handler you can decide what to do when any of the button on popup window ( yes, no and cancel) is pressed.

Go inside the event handler 'ON_CONFIRM_SAVE'

write the code:

CASE wd_this->popup->answer.

WHEN if_wd_popup_to_confirm=>co_button_1_pressed.

*your code regarding yes button.

WHEN if_wd_popup_to_confirm=>co_button_2_pressed.

*your code regarding no button.

endcase.

Thanks

Vishal kapoor