15
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 1 Embedding a BRFplus Object in an ABAP WebDynpro Application Applies to: Business Rule Framework plus (BRFplus) shipped with SAP NetWeaver 7.0 Enhancement Package 1. For a detailed introduction to BRFplus please visit Business Rules Management at the SDN network and select BRFplus in the Related Content section. Summary This paper is about the integration of a BRFplus object into your ABAP WebDynpro application. It shows you step by step how to embed the object and modify its UI, introduces you to events which can be raised by the embedded object and explains how to deal with exceptions. The document gives you advise concerning some aspects of the used component like deallocating of resources when the object is forced to close or how to handle user actions in a confirmation dialog displayed by the embedded object. Authors: Daniel Schüler, Patrick Lorenz, Thomas Albrecht Company: SAP AG Created on: September 11, 2009 Author's Bio Daniel Schüler and Patrick Lorenz are students of Information Technology at the University of Corporate Education in Karlsruhe. They joined SAP in 2008. During their vocational training they work at different departments at SAP, mainly in the development area. Thomas Albrecht is a developer in the team of Business Rule Framework plus. Since joining SAP in 2003, he has worked in and driven several development projects in ERP Travel Management with focus on architecture. In 2008, he joined the BRFplus development team.

Embedding a BRFplus Object in an ABAP WebDynpro Applicationa248.g.akamai.net/n/248/420835/4f750eeede2f633ffdecd3291... · 2016. 1. 6. · an ABAP WebDynpro Application Applies to:

  • Upload
    others

  • View
    48

  • Download
    4

Embed Size (px)

Citation preview

  • SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 1

    Embedding a BRFplus Object in

    an ABAP WebDynpro Application

    Applies to:

    Business Rule Framework plus (BRFplus) shipped with SAP NetWeaver 7.0 Enhancement Package 1.

    For a detailed introduction to BRFplus please visit Business Rules Management at the SDN network and select „BRFplus‟ in the Related Content section.

    Summary

    This paper is about the integration of a BRFplus object into your ABAP WebDynpro application. It shows you step by step how to embed the object and modify its UI, introduces you to events which can be raised by the embedded object and explains how to deal with exceptions.

    The document gives you advise concerning some aspects of the used component like deallocating of resources when the object is forced to close or how to handle user actions in a confirmation dialog displayed by the embedded object.

    Authors: Daniel Schüler, Patrick Lorenz, Thomas Albrecht

    Company: SAP AG

    Created on: September 11, 2009

    Author's Bio

    Daniel Schüler and Patrick Lorenz are students of Information Technology at the University of Corporate Education in Karlsruhe. They joined SAP in 2008. During their vocational training they work at different departments at SAP, mainly in the development area.

    Thomas Albrecht is a developer in the team of Business Rule Framework plus. Since joining SAP in 2003, he has worked in and driven several development projects in ERP Travel Management with focus on architecture. In 2008, he joined the BRFplus development team.

    https://www.sdn.sap.com/irj/sdn/nw-rules-managementhttps://www.sdn.sap.com/irj/sdn/nw-rules-management?rid=/webcontent/uuid/d00df7db-c783-2b10-aa97-ccfeacc19fcb

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 2

    Table of Contents

    Use of the Object Manager component to embed BRF+ objects ................................................................... 3

    Integration of the Object Manager component ............................................................................................................. 3

    Use of the Object Manager component methods ......................................................................................................... 5

    Edit and save a BRFplus object with the object manager .............................................................................. 5

    Create a BRFplus object with the object manager ......................................................................................... 6

    Free resources ................................................................................................................................................ 7

    Handle user action in the confirmation dialog ................................................................................................. 7

    Modifying the UI of the embedded object ....................................................................................................... 9

    Direct configuration (7.0/7.1 EHP 1) ............................................................................................................................ 9

    Configuration through a UI mode class (7.0/7.1 EHP2) ............................................................................................. 10

    Handling exceptions in the object manager .................................................................................................. 11

    IMPORTANT: Definition of exceptions in the interface of the object manager in releases 7.0 and 7.1 ...................... 11

    Catching more specific exceptions when calling methods of the object manager ...................................................... 11

    Overview of the Object Manager .................................................................................................................. 13

    Interfaces used to configure the UI-Modes ................................................................................................... 13

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 3

    Prerequisites

    Basic knowledge of ABAP Web Dynpro

    Basic knowledge of BRFplus

    Learning Objectives

    After this tutorial you can…

    embed a BRFplus object into your Web Dynpro application

    modify the UI of the BRFplus object according to your needs

    use and react on different events which are provided by the BRFplus Object Manager

    Procedure

    Use of the Object Manager component to embed BRF+ objects

    In this first example we create a small Web Dynpro component which is able to display and close a BFRplus object. You will learn how to create, instantiate and use the Object Manager component provided by the BRFplus framework.

    Integration of the Object Manager component

    1. As a first step, you have to define the component usage of the Object Manager in your Web Dynpro component. For this, navigate to the Used Components tab of your Web Dynpro component and add the interface FDT_IWD_OBJECT_MANAGER to your application. Name it, for example, OBJECT_MANAGER.

    Figure 1 - Implement the component in your application

    2. Afterwards, you have to add the Object Manager component usage of the component controller of your component.

    On the Properties tab of your component controller, choose Create Controller Usage. Then, choose the interface controller of the component FDT_IWD_OBJECT_MANAGER from the list in the popup.

    Figure 2 - Create the component Usage

    3. Now we need a place on one of our views to display the BRFplus object. Navigate to the layout tab of that view and create a ViewContainerUIElement. Also add two buttons on the view which will be used later to display and close our object. Your view could look like this:

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 4

    Figure 3 - Example Layout of your view

    Now you can embed the “main_window” of the implemented Object Manager component in your ViewContainerUIElement. To do so, navigate to the window of your component, select the ViewContainer und choose Embed View. In the following dialogs, select the “MAIN_WINDOW” of the Object Manager.

    Figure 4 - Embed the Object Manager View in your view container

    4. To fill our ViewContainerUIElement, we need to create an instance of our Object Manager first. So choose a method in which we can instantiate our Object Manager component, for example the method WDOINIT of your component controller.

    Note: You have to choose a method which is called before the view in which you implemented your ViewContainerUIElement is displayed. Otherwise, the ViewContainer tries to display an object

    which has no instance and will raise an exception.

    Write the following code in your method to create an instance of your Object Manager component (see comments for explanation):

    DATA: lo_usage TYPE REF TO if_wd_component_usage.

    "

    " Instance of object manager has to be created in order to use the

    " methods of object manager component

    "

    " get the component usage

    lo_usage = wd_this->wd_cpuse_object_manager( ).

    " if the usage has no active component, create the object manager

    " component

    IF lo_usage->has_active_component( ) IS INITIAL.

    cl_fdt_wd_factory=>if_fdt_wd_factory~get_instance( )->

    if_fdt_wd_component_factory~create_object_manager_comp(

    io_usage = lo_usage ).

    ENDIF.

    The preparation for the use of the Object Manager component is now done. In the next steps, you will use this component to display and close a BRFplus object.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 5

    Use of the Object Manager component methods

    5. Now we are able to call the methods provided by the Object Manager component to display our BRFplus object. In the component controller of your application, create a method (e.g. DISPLAY( )) and insert the following code (see comments for explanation):

    method DISPLAY .

    " reference to a BRFplus exception object

    DATA: lx_fdt_wd TYPE REF TO cx_fdt_wd.

    TRY .

    “ call the method display() of the object manager interface with the

    “ id of a BRFplus object to display the object in the viewcontainer

    wd_this->wd_cpifc_object_manager( )->

    display( iv_id = '00145EF41CBA02DD93ADEB45F6CA8A54' ).

    CATCH cx_fdt_wd INTO lx_fdt_wd.

    " if an exception occurs, forward the exception to the

    “ report_exception() method together with a reference to the message “

    manager of your component. A message will then be displayed at the “ top of

    you WD-View

    cl_fdt_wd_service=>report_exception(

    EXPORTING

    io_message_manager = wd_this->wd_get_api( )->

    get_message_manager( )

    ix_wd_exception = lx_fdt_wd ).

    ENDTRY.

    endmethod.

    For the Display button, implement an event handler which calls the method above in the component controller. Now you have created your first Web Dynpro application ready for embedding a BRFplus object.

    6. As a last step we implement the functionality of the Close button. The procedure is similar to the integration of the Display button. Create a method in your component controller which you call in the event handler of the Close button. The method should look like the one above but instead of “wd_this-> wd_cpifc_object_manager( )->display(…)” you call “wd_this-> wd_cpifc_object_manager( )->close()”. See the table in the appendix for optional parameters to this method.

    Note: The “close()” method doesn‟t necessarily close a displayed object. In case the object has been modified and is in an unsaved state and the IV_FORCE FLAG of the “close()” method is set to FALSE, a confirmation dialog pops up. Here, the user can decide if he or she really wants to close the object.

    See section “Handle user action in the confirmation dialog” to learn how to make sure that the embedded object is closed.

    You have successfully embedded a BRFplus object into your Web Dynpro application. In the next chapter, you will see how you can open an object in edit mode, save changes to this object and find out what you have to consider when you want to close a modified object.

    Edit and save a BRFplus object with the object manager

    In the previous section „Use of the Object Manager component methods‟, you have learned to make use of the two basic methods „display‟ and „close‟ provided by the object manager. In some business cases, however, it is desired to edit an object and react on events of the object manager.

    In this section we will learn how to open an object in edit mode and save any changes. Furthermore we have a look at the behavior of the object manager when closing unsaved objects and how you are able to influence this action.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 6

    1. First we add two buttons to our application for the additional functions „edit‟ and „save‟. When you are done, your application may look like this:

    Figure 5 – Sample layout

    2. Now we should implement our methods to call the methods in the interface of the object manager. To achieve this open the component controller of our application and switch to the Methods tab. Now add a method called EDIT.

    Implement the function call. It is very similar to the method DISPLAY. The implementation could look like this:

    method EDIT .

    DATA: lx_fdt_wd TYPE REF TO cx_fdt_wd.

    TRY .

    wd_this->wd_cpifc_object_manager( )->

    edit( iv_id = '00145EF41CBA02DD93ADEB45F6CA8A54' ).

    CATCH cx_fdt_wd INTO lx_fdt_wd.

    cl_fdt_wd_service=>report_exception(

    EXPORTING

    io_message_manager = wd_this->wd_get_api( )->get_message_manager( )

    ix_wd_exception = lx_fdt_wd ).

    ENDTRY.

    endmethod.

    To save a displayed object, use the SAVE_CURRENT_OBJECT method offered by the interface of the object manager.

    3. To make the buttons work, we need to define event handlers for them where we call the corresponding method of the component controller.

    We have now completed the functionality to open an object in editing mode und save the current status of the object.

    Create a BRFplus object with the object manager

    The object manager also provides a method to create new BRFplus objects. You can call this method just like the DISPLAY, CLOSE and SAVE methods as shown before. A popup will be created which allows the user to enter details like the object type, name and so on. The different parameters of the CREATE method allow you to modify the popup and its options in order to limit the users possibilities when creating a new object.

    One important parameter is IT_OBJECT_TYPE. In this table you can provide every object type which you want the user to be able to create. If it is initial, all types are available. Therefore, you need an internal table of type T_OBJECT_TYPE_EXTENDED which consists of lines of the structure S_OBJECT_TYPE_EXTENDED. Both types can be found in the IF_FDT_WD_TYPES interface.

    The structure S_OBJECT_TYPE_EXTENDED contains the elements TYPE, SUBTYPE and IS_ACTION. The element TYPE is of the type OBJECT_TYPE and can be set through the different constants (beginning with “GC_OBJECT_TYPE_”) defined in IF_FDT_CONSTANTS.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 7

    Besides the main types (like application or function) you can also set subtypes of a data object by using the SUBTYPE element of the structure S_OBJECT_TYPE_EXTENDED. The possible subtypes for a data object begin with “GC_DATA_OBJECT_TYPE_” and the subtypes (expression types) for expressions with “GC_EXTY_” (both defined in “IF_FDT_CONSTANTS”).

    The last element of S_OBJECT_TYPE_EXTENDED is IS_ACTION. With this element, you can choose if you want to create an expression (IS_ACTION = FALSE) or an action (IS_ACTION = TRUE) if the chosen type is expression.

    In the following code sample the available object types which can be created will be limited to a “structure”:

    Data: lt_object_types type if_fdt_wd_types=>t_object_type_extended,

    ls_object_type type if_fdt_wd_types=>s_object_type_extended.

    ls_object_type-type = if_fdt_constants=>gc_object_type_data_obect.

    ls_object_type-subtype = if_fdt_constants=>gc_data_object_type_structure.

    APPEND ls_object_type to lt_object_types.

    wd_this->wd_cpifc_object_manager( )->

    create( IT_OBJECT_TYPE = lt_object_types ).

    In the definition of the create method you will find further parameters to modify the popup.

    Free resources

    If the displaying client (e.g. browser) is closed, it also forces the Web Dynpro framework to close. The problem is that all open objects and reserved resources have to be freed. To achieve this, call the CLOSE method of the object manager with the IV_FORCE parameter set to ABAP_TRUE. In this case, no dialog will be displayed asking to save changed objects, but locked objects are released and any reserved resources are freed.

    Handle user action in the confirmation dialog

    In many situations, the application needs to know how the user responded to the confirmation dialog displayed when a changed object is closed. Because of the asynchronous behavior of Web Dynpro, it is not possible to return the result directly to the caller.

    The object manager uses events to solve this problem. They inform a registered caller about several

    events which are triggered inside of the object manager. Among other things, it is possible to register for the events STATE_CHANGE and STATE_CHANGE_CANCELED. They offer a parameter IV_TRANSITION to determine the type of state transition which was performed or canceled.

    Now we will see how to register for these events. As an example, we want to report a state change or a cancellation of a state change to the message manager of the application. In case of a state transition with target state 'closed', a specific message should be displayed.

    1. Open the component controller and go to the Methods tab.

    Figure 6 – Methods of the component controller

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 8

    2. Add a method named HDL_STATE_CHANGE and choose Event Handler as method type.

    Figure 7 – New method added

    3. With the F4 help button of the Event column, open the selection assistant and choose the STATE_CHANGE event.

    Figure 8 – The selection assistant

    Figure 9 – Choose event

    4. Now go to the implementation of the method. The method should pass a message about the state change to the message handler. In case the close transition was performed, a different message should be passed. A simple implementation could look like this:

    method HDL_STATE_CHANGE .

    DATA: lv_message_text TYPE string.

    IF iv_transition EQ if_fdt_wd_state=>gc_transition_close.

    lv_message_text = 'Close transition performed.'. "#EC NOTEXT

    ELSE.

    CONCATENATE 'State change happened. New transition: ' iv_transition

    INTO lv_message_text SEPARATED BY ' '. "#EC NOTEXT

    ENDIF.

    wd_this->wd_get_api( )->get_message_manager( )->report_message(

    message_text = lv_message_text

    message_type = if_wd_message_manager=>co_type_standard

    ).

    endmethod.

    Note: You should not use hard-coded strings in any application because of translation issues. In this demo application the attention is laid on the integration of the object manager. The comment “#EC NOTEXT” is used to suppress the error message of the enhanced program testing.

    Now we can determine what the user did in response to the confirmation dialog and implement the application behavior in the event handler methods.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 9

    Registering for the cancellation event is similar to the given example. On the selection screen (see Figure 9), just choose the event STATE_CHANGE_CANCEL. This event helps to handle the user reaction in the asynchronous Web Dynpro framework. It is triggered if the user cancels the creation of an object or cancels closing an object that has not yet been saved.

    The next part of the tutorial deals with the appearance of the UI and how it can be modified.

    Modifying the UI of the embedded object

    Now that you know how to embed a BRFplus object in your Web Dynpro application, you may find it useful to modify the appearance of the embedded object. By doing so, you can also restrict the user‟s possibilities to interact with the object. For example, it is possible to hide particular buttons or the complete toolbar.

    To accomplish this, there are two different approaches:

    Direct configuration: In this approach (used in release 7.0/7.1 EHP 1), a configuration object is used which is then delivered to the CREATE_OBJECT_MANAGER factory method as a parameter.

    Configuration through a UI mode class: In this approach (recommended way since release 7.0/7.1 EHP 2), a predefined UI class is used for calling the SET_UI_MODE method.

    Direct configuration (7.0/7.1 EHP 1)

    Note: Even though it is possible to modify the UI (and also using the the UI mode approach) in release 7.0 EHP 1, the UI configuration is not fully enabled. To use the whole functionality you need at least release 7.0 with EHP 2 or release 7.1. In EHP1, the configuration concerning the object manager (IF_FDT_WD_OBJM_CONFIGURATION) is available, as well as the setting to disable the table settings in the decision table UI (IF_FDT_WD_CONFIGURATION=> C_PARAM_HIDE_TAB_SETTINGS)

    1. Instantiate a configuration object by calling the GET_CONFIGURATION( ) method of the FDT_FACTORY.

    The object offers different methods for its configuration. See the interface IF_FDT_WD_CONFIGURATION for an overview and a description.

    2. Hand over your configuration object with the next call of the CREATE_OBJECT_MANAGER_COMP() method.

    The following sample code hides the Transport button of the toolbar and the General Data area of the object. If you want to use this snippet, just modify the WDOINIT method of the component controller from the sample application created in the chapters before.

    DATA: ro_configuration TYPE REF TO if_fdt_wd_configuration.

    " 1. get the configuration object

    ro_configuration = cl_fdt_wd_factory=>if_fdt_wd_factory~get_instance( )->

    get_configuration( ).

    " 2. configure the object

    ro_configuration->if_fdt_wd_objm_configuration~set_toolbar_button_visible(

    iv_button_name = if_fdt_wd_objm_configuration=>gc_toolbar_button_transport

    iv_is_visible = abap_false

    ).

    ro_configuration->

    if_fdt_wd_objm_configuration~set_general_data_visible(

    iv_is_visible = abap_false

    ).

    " 3. create a new Object Manager component with your configuration object

    IF lo_usage->has_active_component( ) IS INITIAL.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 10

    cl_fdt_wd_factory=>if_fdt_wd_factory~get_instance( )->

    if_fdt_wd_component_factory~create_object_manager_comp(

    io_usage = lo_usage

    io_configuration = ro_configuration ).

    ENDIF.

    Configuration through a UI mode class (7.0/7.1 EHP2)

    Note: Even though the UI mode infrastructure is available in EHP 1, the user has no possibility to alter the configuration settings via the user settings dialog. Also only some configuration parameters are available (see last chapter).

    Technically, a UI mode is a reference to an IF_FDT_WD_CONFIGURATION object which allows you to set different parameters to modify the UI. The UI mode class combines this configuration object with different metadata like a description and a name of the UI mode. A UI mode can be set by calling the SET_UI_MODE() method of your Object Manager interface with your predefined UI class as a parameter.

    There are already two UI mode classes available, called “Simple Mode” and “Expert Mode”. These two modes differ in various UI options. For example the Simple mode hides technical components like XML export, static method etc while the Expert mode displays these components.

    If you want to customize your own UI, you can inherit your UI mode class from these classes and overwrite the corresponding methods to fit your needs. In the appendix of this document you find a table which lists the different interfaces providing the methods for the configuration of the UI mode. Follow these steps to create your own UI mode class which will be derived from the Simple Mode class:

    1. Create a new class and add the UI mode class CL_FDT_WD_UI_SIMPLE_MODE as its superclass.

    Figure 10 - UI mode class with its superclass

    2. Redefine the inherited method GET_CONFIGURATION( ).

    Figure 11 - Redefinition of GET_CONFIGURATION()

    3. In the redefined method, enter your configuration code. As an example, we hide the Transport button of the toolbar and the General Data area in the following code:

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 11

    " call the superclass to get the configuration object

    CALL METHOD SUPER->IF_FDT_WD_UI_MODE~GET_CONFIGURATION

    RECEIVING

    RO_CONFIGURATION = ro_configuration.

    " configure the object

    ro_configuration-> if_fdt_wd_objm_configuration~set_toolbar_button_visible(

    iv_button_name = if_fdt_wd_objm_configuration=>

    gc_toolbar_button_transport

    iv_is_visible = abap_false

    ).

    ro_configuration->if_fdt_wd_objm_configuration~

    set_general_data_visible( iv_is_visible = abap_false ).

    4. In a last step, you have to set the UI mode of your embedded object to the newly created UI mode class as shown in the following sample code:

    DATA lo_ui_mode TYPE REF TO if_fdt_wd_ui_mode.

    " create an instance of the UI-class

    CREATE OBJECT lo_ui_mode TYPE cl_ui_mode.

    IF wd_this->wd_cpuse_object_manager( )->

    has_active_component( ) IS NOT INITIAL.

    " set the UI-mode

    wd_this->wd_cpifc_object_manager( )->

    set_ui_mode( io_ui_mode = lo_ui_mode ).

    ENDIF.

    Handling exceptions in the object manager

    IMPORTANT: Definition of exceptions in the interface of the object manager in releases 7.0 and 7.1

    In release 7.0, it is not possible to define exceptions for a method in ABAP Web Dynpro. That‟s why it is important to know what type of exceptions could occur by calling a method of the object manager. So it is necessary to have a look into the system.

    In release 7.1 and later, the interface is updated with the exception definitions.

    Note: All exceptions that occur in the backend (with root exception CX_FDT) are converted to the exception type CX_FDT_WD_BACKEND by the UI layer.

    Catching more specific exceptions when calling methods of the object manager

    In some cases it is useful to react in different ways on exceptions. There could be a different procedure in case an object is not editable or the user has insufficient authorizations.

    To accomplish this, we just need to catch more specific exceptions. The package interface of SFDT_WD_INFRASTRUCTURE offers the following exception types:

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 12

    Figure 12 – Exception types offered by package interface

    So far, we have caught the exception type CX_FDT_WD which is the root exception of the Web Dynpro infrastructure. In the following section, we will output a specific message for handling a situation where an object is locked by another user.

    Let's go to the implementation of the EDIT method in the component controller. At this point, it should look like this:

    method EDIT .

    DATA: lx_fdt_wd TYPE REF TO cx_fdt_wd.

    TRY .

    wd_this->wd_cpifc_object_manager( )->

    edit( iv_id = '00145EF41CBA02DD93ADEB45F6CA8A54' ).

    CATCH cx_fdt_wd INTO lx_fdt_wd.

    cl_fdt_wd_service=>report_exception(

    EXPORTING

    io_message_manager = wd_this->wd_get_api( )->get_message_manager( )

    ix_wd_exception = lx_fdt_wd ).

    ENDTRY.

    endmethod.

    Now we insert an additional catch block into this implementation. It should catch the exception type „CX_FDT_WD_OBJECT_LOCKED‟. If a fitting exception occurs the message „Object is locked by another User‟ should be printed.

    The new code should be similar to this:

    METHOD edit .

    DATA: lx_fdt_wd TYPE REF TO cx_fdt_wd.

    TRY .

    wd_this->wd_cpifc_object_manager( )->

    edit( iv_id = '00145EF41CBA02DD93ADEB45F6CA8A54' ).

    CATCH cx_fdt_wd_object_locked INTO lx_fdt_wd.

    DATA: lv_message_text TYPE string.

    lv_message_text = 'Object is locked by another User.'. "#EC NOTEXT

    wd_this->wd_get_api( )->get_message_manager( )->report_message(

    message_text = lv_message_text

    message_type = if_wd_message_manager=>co_type_error ).

    CATCH cx_fdt_wd INTO lx_fdt_wd.

    cl_fdt_wd_service=>report_exception(

    EXPORTING io_message_manager = wd_this->wd_get_api( )->

    get_message_manager( )

    ix_wd_exception = lx_fdt_wd ).

    ENDTRY.

    ENDMETHOD.

    The procedure to handle exceptions of other subtypes is done accordingly.

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 13

    Web Dynpro demo component

    The demo component FDT_WD_DEMO_EMBED_UI shows the sample use of the Object Manager and covers all the aspects dealt with in this tutorial. The code is well documented and you should have a look at it if you need help with the design or the coding of your own component using the Object Manager. The demo component is only available in release 7.0/7.1 EHP2.

    Appendix

    Overview of the Object Manager

    Method Description

    CLOSE Closes object(s). The confirmation Dialog can be suppressed by setting the IV_FORCE_FLAG.

    CREATE Displays a “Create” popup where the user can enter further parameters. Object type and other options can be set to limit the user‟s choices in the popup. May throw exception CX_FDT_WD

    DELETE Deletes the object specified by iv_id. The user has to acknowledge this action. May throw exception CX_FDT_WD

    DISPLAY Displays the object specified by IV_ID. May throw exception CX_FDT_WD

    EDIT Opens the object specified by IV_ID for editing. May throw exception CX_FDT_WD

    GET_DISPLAYED_OBJECT Returns the ID, state, and timestamp of the currently displayed object.

    IS_OBJECT_DISPLAYED Indicates if an object is currently displayed.

    IS_UNSAVED_OBJECT_EXISTING Indicates if an unsaved object exits.

    SAVE_CURRENT_OBJECT Saves the current (visible) object. May throw exception CX_FDT_WD

    SET_UI_MODE Sets the UI Mode. Used to change the appearance of the embedded object.

    Event Description

    NAVIGATE_TO_OBJECT Navigate to object

    STATE_CHANGE Change of UI state (transition)

    STATE_CHANGE_CANCEL Change of UI state is cancelled by user

    Interfaces used to configure the UI-Modes

    Interface Description

    IF_FDT_WD_CONFIGURATION Provides general configuration methods and nests the other interfaces.

    IF_FDT_WD_OBJM_CONFIGURATION Provides the methods and attributes for the configuration of the Object Manager, e.g. hiding the toolbar of the embedded object.

    IF_FDT_WD_REPOSITORY_CONFIG Provides methods and attributes to configure/interact with repository objects, e.g. to mark objects as obsolete. (Only in 7.0/7.1 EHP2)

    IF_FDT_WD_USER_CONFIGURATION Provides methods for user-specific UI configuration, e.g. if you want to display favorites or the repository view. (Only in 7.0/7.1 EHP2)

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 14

    Related Content

    BRFplus

    Carsten Ziegler‟s Blog

    Business Rules Management

    https://www.sdn.sap.com/irj/sdn/nw-rules-management?rid=/webcontent/uuid/d00df7db-c783-2b10-aa97-ccfeacc19fcbhttps://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/11632https://www.sdn.sap.com/irj/sdn/nw-rules-management

  • Embedding a BRFplus Object in an ABAP WebDynpro Application

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com

    © 2009 SAP AG 15

    Copyright

    © Copyright 2009 SAP AG. All rights reserved.

    No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

    Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

    Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

    IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

    Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

    Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

    Oracle is a registered trademark of Oracle Corporation.

    UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

    Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

    HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

    Java is a registered trademark of Sun Microsystems, Inc.

    JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

    SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.

    Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

    All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

    These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.