Upload
largeman
View
223
Download
0
Embed Size (px)
Citation preview
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 1/9
Working with Dialog Boxes
Release NW2004S SPS7 H E L P . B C W
D A B A P P
R O G M A N
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 2/9
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 3/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 3
Icons in Body Text
Icon Meaning
Caution
Example
Note
Recommendation
Syntax
Additional icons are used in SAP Library documentation to help you identify different types of
information at a glance. For more information, see Help on Help → General Information Classes and Information Classes for Business Information Warehouse on the first page of any
version of SAP Library .
Typographic Conventions
Type Style Description
Example text Words or characters quoted from the screen. These include fieldnames, screen titles, pushbuttons labels, menu names, menu paths,and menu options.
Cross-references to other documentation.
Example text Emphasized words or phrases in body text, graphic titles, and tabletitles.
EXAMPLE TEXT Technical names of system objects. These include report names,program names, transaction codes, table names, and key concepts of aprogramming language when they are surrounded by body text, forexample, SELECT and INCLUDE.
Example text Output on the screen. This includes file and directory names and theirpaths, messages, names of variables and parameters, source text, andnames of installation, upgrade and database tools.
Example text Exact user entry. These are words or characters that you enter in thesystem exactly as they appear in the documentation.
<Example text> Variable user entry. Angle brackets indicate that you replace thesewords and characters with appropriate entries to make entries in thesystem.
EXAMPLE TEXT Keys on the keyboard, for example, F2 or ENTER.
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 4/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 4
Working with Dialog Boxes ......................................................................................................5 Calling Dialog Boxes of the Same Component.....................................................................5 Calling Dialog Boxes of a Used Component.........................................................................7 Calling a Confirmation Dialog Box ........................................................................................8
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 5/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 5
Working with Dialog BoxesDialog boxes are used to display concrete information or possible settings on a Web Dynproview. After the dialog has been exited, either the view underneath becomes active again oryou can navigate to another screen. There are two different types of dialog boxes:
● Modal
A modal dialog box opens in the current browser window.
Each modal dialog box has its own phase model instance [external].
● External
An external dialog box is opened in a separate browser window and can be movedaround the screen independently of the original window. External dialog boxes aregenerally modeless.
Calling a Dialog Box
● Dialog boxes are implemented within a Web Dynpro application via an additionalwindow and are generally called by the event handler of an action (if necessaryhowever, all other methods of the phase model can be used). The componentcontroller contains the interface IF_WD_WINDOW_MANAGER, with which a newwindow for the content of the dialog box can be created and opened. (During thecreation process, a usage of the corresponding component controller is automaticallyset up for every view controller.) In most cases, you will use a modal dialog box in yourapplication.
In your system you will find the detailed example componentWDR_TEST_POPUPS_RT_00. It is located in package SWDP_TEST.
The parameter MODAL is no longer used. It is contained in the parameterlist for compatibility reasons.
Calling Dialog Boxes of the Same Component
● If the dialog box that you want to display is connected to the current component bycontent and was created specifically for this purpose, you should also create the
corresponding window in this component.● The method CREATE_WINDOW of the interface IF_WD_WINDOW_MANAGER allows
you to create a dialog box in an event handler method from a displayed window atruntime. The name of the window to be opened is passed to the CREATE_WINDOWmethod as a parameter.
method onactionpopup1_1 .
data: l_cmp_api type ref to if_wd_component,l_window_manager type ref to if_wd_window_manager.
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 6/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 6
l_cmp_api = wd_comp_controller->wd_get_api( ).l_window_manager = l_cmp_api->get_window_manager( ).if wd_this->m_popup1_1 is initial.wd_this->m_popup1_1 = l_window_manager->create_window(
window_name = 'POPUP1_1'button_kind = if_wd_window=>co_buttons_yesnocancelmessage_type = if_wd_window=>co_msg_type_question ).
endif.
wd_this->m_popup1_1->open( ).
endmethod.
● Note that the CREATE_WINDOW method only creates the new dialog box, it does notopen it. To open the dialog box you also need the OPEN method.
The Buttons of the Dialog Box
● Using the parameter BUTTON_KIND, you specify which buttons should appear in thedialog box. In the example above, the constant CO_BUTTONS_YESNOCANCEL isset. This constant is of the ABAP Dictionary type WDR_POPUP_BUTTON_KIND, thedomain of which has a set of fixed values. The fixed values represent all the meaningfulcombination possibilities for dialog box buttons, such as OK, OK/Cancel, orYes/No/Cancel. The default of the constant, an attribute of the interfaceIF_WD_WINDOW, is the value 5. That means, the combination contains the constantsCO_BUTTON_YES, CO_BUTTON_NO, CO_BUTTON_CANCEL, and three buttonswill be created in the dialog box, one each for Yes, No, and Cancel .
The Window of the Dialog Box
● In the hook method WDDOINIT of the view of the dialog box, the button constants arelinked to appropriate actions. For this purpose, the interface IF_WD_WINDOW containsthe method SUBSCRIBE_TO_BUTTON_EVENT. The actions must be created directlyin the dialog box and the automatically created event handler methods must beprogrammed accordingly.
method wddoinit .
data:
l_api type ref to if_wd_view_controller,l_window_ctlr type ref to if_wd_window_controller,l_popup type ref to if_wd_window.
l_api = wd_this->wd_get_api( ).l_window_ctlr = l_api->get_embedding_window_ctlr( ).if l_window_ctlr is bound.l_popup = l_window_ctlr->get_window( ).if l_popup is bound.l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_yesbutton_text = 'Yes' "#EC *action_name = 'YES'action_view = l_apiis_default_button = abap_true ).
l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_nobutton_text = 'No' "#EC *action_name = 'NO'action_view = l_apiis_default_button = abap_true ).
l_popup->subscribe_to_button_event(button = if_wd_window=>co_button_cancelbutton_text = 'Cancel' "#EC *action_name = 'CANCEL'action_view = l_apiis_default_button = abap_true ).
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 7/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 7
endif.endif.
endmethod.
● The phase model instance of the dialog box is attached to the same component as the
instance of the calling window. For this reason, when the dialog box is opened not only are allthe hook methods [external] of the view called that are displayed in the dialog box, all thehook methods of the view that are imbedded in the calling window are called as well.
The WDDOONOPEN and WDDOONCLOSE Methods
Every window controller has the hook methods WDDOONOPEN and WDDOONCLOSE.These two methods are only processed when a window is opened, or closed, as a dialog box.Since the opening of a dialog box does not involve any navigation, no inbound plug is calledand therefore no event handler method is processed. The method WDDOONOPEN cantherefore be used to implement initializations.
Calling Dialog Boxes of a Used Component
● If the dialog box that you want to display is of a generic nature and can be used inmany different components, you create the corresponding window in a separatecomponent, which is then used by the current component. In this case, you create thedialog box at runtime in the current component using the methodCREATE_WINDOW_FOR_CMP_USAGE and pass the names of the interface view and the component usage. There must be a component-usage [external] entry in theattribute table of the current component for the component to which the dialog boxbelongs.
● method ONACTIONPOPUP2_1 .
data: l_cmp_api type ref to if_wd_component,l_window_manager type ref to if_wd_window_manager.
l_cmp_api = wd_comp_controller->wd_get_api( ).l_window_manager = l_cmp_api->get_window_manager( ).if wd_this->m_popup2_1 is initial.wd_this->m_popup2_1 = l_window_manager->CREATE_WINDOW_FOR_CMP_USAGE(
interface_view_name = 'MAIN'component_usage_name = 'USAGE_POPUP2_1' ).
endif.wd_this->m_popup2_1->open( ).
endmethod.
● Setting the Buttons of a Dialog Box of a Used Component
Unlike with dialog boxes of the separate component, the buttons of the dialog box that is to beopened cannot be created in one of the methods on the view controller of the calling view asbuttons can only be set by the separate component. Dieser Schritt wird bei Dialogfensternvon Components, die zur Verwendung durch andere Components erstellt wurden, in derHook-Methode WDDOONOPEN an dessen Window-Controller implementiert (see documentCalling Dialog Boxes of the Same Component [page 5]).
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 8/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 8
● The following source code shows the method WDDOOPEN on the controller of thedialog box:
method wddoonopen .
if window_descr->is_popup = abap_true.
window_descr->window->set_button_kind(
if_wd_window=>co_buttons_yesnocancel ).window_descr->window->set_message_type( if_wd_window=>co_msg_type_question).
endif.
endmethod.
● If the dialog box is not part of the separate component, but was created in a
used component, the phase model instances of the two windows are notattached to the same component either. If the dialog box is open, only the hookmethods of the views that are embedded in the dialog box will be processed.
Calling a Confirmation Dialog Box
● To quickly create dialog boxes of a standardized layout (for example, for theconfirmation of changes to current data) you can call theCREATE_POPUP_TO_CONFIRM method of the IF_WD_WINDOW_MANAGER. Youdo not need to create a separate window for this. The dialog box is createdautomatically by the runtime.
● The CREATE_POPUP_TO_CONFIRM method creates an object of the typeIF_WD_WINDOW; the dialog box can be created using its parameters.
method onactionpopup4_1 .
data: l_cmp_api type ref to if_wd_component,l_window_manager type ref to if_wd_window_manager,l_popup type ref to if_wd_window,l_text type string_table,l_api type ref to if_wd_view_controller.
l_cmp_api = wd_comp_controller->wd_get_api( ).l_window_manager = l_cmp_api->get_window_manager( ).insert `Data where changed` into table l_text. "#EC *insert `Do you want to save?` into table l_text. "#EC *
l_popup = l_window_manager->create_popup_to_confirm(
text = l_textbutton_kind = if_wd_window=>co_buttons_yesnocancelmessage_type = if_wd_window=>co_msg_type_questionwindow_title = 'Test: Popup to confirm'window_position = if_wd_window=>co_center )."#EC *
l_api = wd_this->wd_get_api( ).
l_popup->subscribe_to_button_event(button = if_wd_window=>co_button_yesaction_name = 'YES'action_view = l_api
7/31/2019 Working With Dialog Boxes
http://slidepdf.com/reader/full/working-with-dialog-boxes 9/9
SAP Online Help preliminary version 14.03.2006
Working with Dialog Boxes NW2004s SPS7 9
is_default_button = abap_true ).l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_noaction_name = 'NO'action_view = l_apiis_default_button = abap_false ).
l_popup->subscribe_to_button_event(button = if_wd_window=>co_button_cancel
action_name = 'CANCEL'action_view = l_apiis_default_button = abap_false ).
l_popup->open( ).endmethod.
The SUBSCRIBE_TO_BUTTON_EVENT method of IF_WD_WINDOW assigns the actions tothe appropriate buttons. If you have created a window for the dialog box yourself, theassignment of individual actions to the buttons takes place in the hook method WDDOINIT(see document Calling Dialog Boxes of the Same Component [page 5]).
● As no explicitly created window exists in this case, the corresponding actions arecreated in the same view in which the dialog box is called. Assignment using themethod SUBSCRIBE_TO_BUTTON_EVENT takes place immediately after the creation
of the dialog box in same method.