dynpro 弹出对话框

来源:互联网 发布:淘宝导航栏透明代码 编辑:程序博客网 时间:2024/06/08 03:05

SAP自带的例子的程序名称是:DEMO_POPUPS_01、DEMO_POPUPS_02、DEMO_POPUPS_03

查找方法:SE80——Web Dynpro Comp./ Intf.——DEMO_POPUPS_01

如下图:dynpro <wbr>弹出对话框

第一步:创建VIEW,命名为:V_POPUP

第二步:创建WINDOW,命名为:W_POPUP,并把V_POPUP嵌套到该WINDOW中

第三步:写代码

DATAcontext_node TYPE REF TO if_wd_context_node.
DATAlr_popup TYPE REF TO if_wd_window,
        lr_view_controller TYPE REF TO if_wd_view_controller.

  DATAlr_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         'W_POPUP'  "Name of the window created in step 2
  title               '警告'
  close_button        '' "abap_true'
  button_kind         if_wd_window=>co_buttons_okcancel
  message_type        if_wd_window=>co_msg_type_information
 close_in_any_case   abap_true
*MESSAGE_DISPLAY_MODE MESSAGE_DISPLAY_MODE
  ).

  lr_view_controller wd_this->wd_get_api).

  lr_popup->subscribe_to_button_event(
  button if_wd_window=>co_button_ok
 button_text 'OK'
  action_name 'DO_OK' 
  action_view lr_view_controller ).

  lr_popup->open).

 

执行程序后,效果如下图:

dynpro <wbr>弹出对话框

注释:DO_OK为ACTIONS;

引用:http://www.sapdev.co.uk/sap-webapps/sap-webdynpro/wdp_displaypopup.htm

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 ).
原创粉丝点击