sapdev logo background
sapdev logo sapdev logo
Comments

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 ).




comments powered by Disqus