Display popup screen within ABAP Web dynpro

Displaying a web dypro pop up screen is a fairly simple process, it basically involves creating a view containing the message or fields you want to display on the wdp popup, create a window and embend the view into it. Then insert the correct ABAP code at the point where you want the screen to be displayed. Here are the simple steps required to implement you ABAP web dynpro popup screen.


Step 1 - Within your created web dynpro application create a new view
Create a new web dynpro 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 basic web dynpro 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 wdp 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'
	action_view = lr_view_controller ).


Related Articles

Add programmed/OVS search help to FPM ESS/MSS application via enhancement to CL_HRESS_PER_DETAIL
BIND_STRUCTURE method of interface IF_WD_CONTEXT_NODE to assign structure to context
BIND_TABLE method of interface IF_WD_CONTEXT_NODE
Get the name of the button the user has clicked on within the SAP web dynpro action ABAP code
Create field Refering to datatype of webDynpro context element
WebDynpro context for creation of screen field including standard search help
Disable SAP User Personalisation in Web Dynpro app using WDDISABLEUSERPERSONALIZATION and WDENABLEUIELEMENTSHIDE
GET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to retrieve value of context element
GET_SELECTED_ELEMENTS to get selected row of ABAP web dynpro table when not using lead selection
GET_STATIC_ATTRIBUTE_TABLE method to return all rows of a context table node
IF_WD_CONTEXT_NODE interface methods withn ABAP Web Dynpro to enable users to view and change data
ABAP code to manually trigger ABAP web dynpro plug
Popuate SAP WebDynpro field
Freely Programmed search help for your web dynpro application (custom value help/OVS)
Change the stylesheet theme used by your web dynpro and portal apps (i.e. SAP_TRADESHOW, SAP_CORBU)
Change the stylesheet theme used by your web dynpro and portal apps (i.e. SAP_TRADESHOW, SAP_CORBU)
SET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to assign value to individuale context attribute
Clear context attribute using SET_ATTRIBUTE_NULL method of interface IF_WD_CONTEXT_NODE
Add Dropdown by index UI Element to table field within abap web dynpro
Add freely Programmed search help to a web dynpro application field
Retrieve SAP webDynpro field value entered by user
ABAP Web dynpro ALV report table
Hide fields of a web dynpro ALV table
Display web dynpro ALV report select options to resict output results
Assign value to ABAP web dynpro context via table, structure or individual attribute
Get selected ABAP Web dynpro dropdown byindex value (dropdownbyindex UI element)
ABAP web dynpro Dropdown by index UI Element allows a field to display a drop down list of values
ABAP web dynpro Dropdown default value, allow you to set current value of dropdown UI element
Change SAP web dynpro logon screen
Read ABAP Web dynpro table context on action / button click
ABAP Web Dynpro tables to allow users to view and change data
Get selected row of ABAP web dynpro table
Get all selected rows of table within your web dynpro for ABAP applications using GET_SELECTED_ELEMENTS
Get selected row of ABAP web dynpro table
ABAP Web Dynpro tree structure, display HR org structure as example
SAP ABAP Web Dynpro UI elements
View Container UI Element to display a web dynpro view within a wdp view
ALV ABAP Web Dynpro application
ABAP Web dynpro button click / Action
Call URL from SAP Webdynpro for ABAP ACTION
Call URL from SAP Webdynpro for ABAP ACTION
ABAP Web dynpro populate table on action / button click
ABAP code to Print abap web dynpro table
Adding URL parameters to you ABAP webdynpro to change thinks like the CSS