cancel
Showing results for 
Search instead for 
Did you mean: 

Message in a POPUP using Web Dynpro ABAP

kedarT
Active Contributor
0 Kudos

Hi,

I have developed a Web Dynpro ABAP application.On this application i want a popup with error/success messages to come up once a certain action is performed on the screen.

Please let me know how this can be achieved.

Thanks in advance.

Regards,

Kedar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi,

You can go for the code mentioned above.

For full document you can go for the following. It shows step by step approach.

Step 1 - Within your created web dynpro application create a new view

Create a new view which contains the text and UI elements you want to display

Step 2 - Create a new WINDOW (WND_POPUP) to embed the view into

Create a new window and embed the view you have just created into it. see hello world example to see how to embed a view into a window.

Step 3 - Add ABAP code

Insert the following ABAP code into the appropriate place. i.e. in the action method of your desired button

Data: context_node type ref to if_wd_context_node.

data: lr_popup type ref to if_wd_window,

lr_view_controller type ref to if_wd_view_controller.

data: lr_api_comp_controller type ref to if_wd_component,

lr_window_manager type ref to if_wd_window_manager.

lr_api_comp_controller = wd_comp_controller->wd_get_api( ).

lr_window_manager = lr_api_comp_controller->get_window_manager( ).

lr_popup = lr_window_manager->create_window(

MODAL = ABAP_TRUE

window_name = 'WND_POPUP' "Name of the window created in step 2

TITLE = 'Please enter all information'

CLOSE_BUTTON = ABAP_TRUE

BUTTON_KIND = if_wd_window=>CO_BUTTONS_YESNO

MESSAGE_TYPE = if_wd_window=>co_msg_type_error

CLOSE_IN_ANY_CASE = ABAP_TRUE

*MESSAGE_DISPLAY_MODE = MESSAGE_DISPLAY_MODE

).

  • Adds an action to the popup screen buttons

  • lr_view_controller = wd_this->wd_get_api( ).

  • lr_popup->subscribe_to_button_event(

  • button = if_wd_window=>co_button_ok

  • button_text = 'Yes'

  • action_name = 'SUBMIT'

  • action_view = lr_view_controller ).

lr_popup->open( ).

Step 4 - Popup screen options

The code in step 3 will display your popup screen as an error message with two buttons saying 'YES' and 'NO', these buttons will not perform an action and will simply return the user back to the main window. If this is not what you require below is a list of options which will allow you to change this display to suit your needs (adding different buttons, change message type, add action to buttons):

Options for the BUTTON_KIND parameter (which can be found by double clicking on 'co_buttons_ok' within the above ABAP code):

CO_BUTTONS_NONE - No Buttons

CO_BUTTONS_ABORTRETRYIGNORE - Buttons for 'Cancel', 'Repeat', 'Ignore'

CO_BUTTONS_OK - Buttons for 'O.K.'

CO_BUTTONS_CLOSE - Buttons for 'Close'

CO_BUTTONS_OKCANCEL - Buttons for 'O.k.', 'Cancel'

CO_BUTTONS_YESNO - Buttons for 'Yes', 'No'

CO_BUTTONS_YESNOCANCEL - Buttons for 'Yes', 'No', 'Close'

CO_BUTTON_ABORT - Button for 'Cancel'

CO_BUTTON_RETRY - Button for 'Repeat'

CO_BUTTON_IGNORE - Button for 'Ignore'

CO_BUTTON_OK - Button for 'Ok.'

CO_BUTTON_CLOSE - Button for 'Close'

CO_BUTTON_CANCEL - Button for 'Cancel'

CO_BUTTON_YES - Button for 'Yes'

CO_BUTTON_NO - Button for 'No'

Options for the MESSAGE_TYPE parameter (which can be found by double clicking on 'co_msg_type_error' within the above ABAP code):

CO_MSG_TYPE_NONE - No message type

CO_MSG_TYPE_WARNING - Warning

CO_MSG_TYPE_INFORMATION - Information

CO_MSG_TYPE_QUESTION - Question

CO_MSG_TYPE_ERROR - Error

CO_MSG_TYPE_STOPP - Cancel

Adding actions to popup screen buttons (Yes, OK etc)

Add the following code to that found in step 3, after the method 'create_window' has been called (or simple uncomment it!!)

lr_view_controller = wd_this->wd_get_api( ).

lr_popup->subscribe_to_button_event(

button = if_wd_window=>co_button_ok

button_text = 'Yes'

action_name = 'SUBMIT'

I hope this would be helpful to you.

Thanx

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Although the posts here are quite correct in the process for creating a custom popup window, that approach is not necessary if you just want to produce a warning or confirmation dialog. SAP provides a resuable object for such basic dialogs. This saves you the effort of having to create the window and the view to display in the popup.

Here is a link to the help topic on this subject:

http://help.sap.com/saphelp_nw70/helpdata/EN/43/c2283b2320332ce10000000a11466f/frameset.htm

AnthonyP
Advisor
Advisor
0 Kudos

Thomas is there any way of making a message area larger?

Answers (5)

Answers (5)

nandishm
Participant
0 Kudos

By default i am getting 3 buttons 'YES'  'NO' and "CANCEL'..............

is there any way to add single button

former_member201541
Participant
0 Kudos

Hi,

Below is the code to display error/success message in WDA.

DATA: lo_api_controller  TYPE REF TO if_wd_controller,

         lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

     CALL METHOD lo_api_controller->get_message_manager

       RECEIVING

         message_manager = lo_message_manager.

* report message

     CALL METHOD lo_message_manager->report_warning

       EXPORTING

         message_text = 'Please select a category'.

You can replace warning with success/error.

Former Member
0 Kudos

hi,

for displaying a pop-up you have to create a new window( Z_FREEZE_POP_UP ) and new view. then append that view to the window.

Now create a text view in the view and type your message in that text view.

then type the following code in the action of the button.

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 lr_view_controller TYPE REF TO if_wd_view_controller.

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 = 'Z_FREEZE_POP_UP'

  • title =

  • close_in_any_case = abap_true

message_display_mode = if_wd_window=>co_msg_display_mode_selected

  • close_button = abap_true2

button_kind = if_wd_window=>co_buttons_okcancel

message_type = if_wd_window=>co_msg_type_question

default_button = if_wd_window=>co_button_ok

).

lo_window->open( ).

you can change the message_type and button_kind.

for changing these just double click on the that and you will see all the options whiuch u can use.

uday_gubbala2
Active Contributor
0 Kudos

Hi Kedar,

When you use the if_wd_message_manager's methods to display your message you will get a parameter called "VIEW". Specify your popup views name in there so that the message would ge displayed in the popup and not on your main view.

ex:

CALL METHOD lo_message_manager->report_success
EXPORTING
message_text =

    * params =
    * msg_user_data =
    * is_permanent = ABAP_FALSE
    * scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER

view = 'POPUP_VIEW' " You need to specify the view in which you want your message to appear. Or else by default it would take it as the view from where you are calling the popup window

    * show_as_popup =
    * controller_permanent_msg =
    * msg_index =
    * cancel_navigation =

Regards,

Uday

Former Member
0 Kudos