• No results found

Adding a new Action to the main tool bar

5.4 Enhancing the User Interface

5.4.4 Adding a new Action to the main tool bar

Adding a new action to the main tool bar of an FPM application works slightly different than adding an action to a component tool bar as shown in section 5.4.2.

For the following first example let’s assume we have already added an enhancement action ZENH_MAINTOOLBAR_ACTION on the ROOT node of the Freight Order BO (TOR) that we would like to trigger from the main tool bar of the Freight Order UI. The coding for this action implementation could look as follows:

METHOD /bobf/if_frw_action~execute. DATA: lv_temp TYPE c.

MESSAGE i008(/scmtms/ui_messages) INTO lv_temp.

CALL METHOD /scmtms/cl_common_helper=>msg_helper_add_symsg EXPORTING

iv_key = /scmtms/if_tor_c=>sc_bo_key " Instance Key

iv_node_key = /scmtms/if_tor_c=>sc_node-root " BO Key

CHANGING

co_message = eo_message. " Current message object ENDMETHOD.

1) Start the UI for displaying Freight Orders from e.g. the SAP user menu, set the customizing mode in the URL for the UI as described in section 5.3 and display an example Freight Order.

Picture: The Main Toolbar of the Freight Order Display UI with its buttons.

2) The component configuration /SCMTMS/WDCC_FRE_ORDER will be customized to add the new main toolbar action. If this component configuration has not yet been customized you first of all create a corresponding component customizing (see picture below) and then continue.

Picture: Component Customizing for Configuration /SCMTMS/WDCC_FRE_ORDER. 3) In the Configuration Editor first of all navigate to the Main Page and then on the right side

of the Configuration Editor display the Toolbar Schema. In the table content of the Toolbar Schema you can find the Global Toolbar which contains the buttons and actions that you can see in the Main Toolbar of the Freight Order UI. Mark the Global Toolbar in the list.

Picture: Adding a button on the Global Toolbar of the Main Page.

4) Now click on button Toolbar Element to add a new toolbar element. The popup that is displayed allows you to add our new button by clicking on the application-specific Function Button. Then click on button OK.

Picture: Adding a new button.

Here you could also add standard functions like Save, Cancel and Edit, Button Choices, Toggle Buttons, Dropdown List Boxes and Links.

5) The new button will now be available in the Toolbar Schema. Mark the new entry in the list so that you can start specifying the attributes of the new button. Specify the following attribute values:

Attribute Value

Text Enhancement Main Toolbar Button

Tool Tip An Enhancement Action on the main toolbar

FPM Event ID ZENH_MAINTOOLBAR_ACTION

Action Type Standard

Moreover maintain the following Event Parameter:

Parameter Name Parameter Value

FBI_RAISED_BY_TOOLBAR X

6) Save your configuration. The new button is now ready to be used on the Freight Order UI via its main tool bar.

With this first example the enhancement action will be triggered by the additional button on the Main Toolbar. As we have chosen the FPM Event ID to be identical with the action name, the execution of the action will be handled generically without any further coding required. In case you don’t want to relate the button to a BO action as shown in the first example, you can follow the second approach which allows you to implement arbitrary coding to be executed when clicking the related button on the UI. This works as follows:

For each application configuration (e.g. /SCMTMS/FRE_ORDER) there is a FBI View available that follows the naming convention [application configuration name]_HTLB. For the example this is FBI View /SCMTMS/FRE_ORDER_HTLB. It is defined to handle the Toolbar of the application and the Exit Class defined there is called automatically.

Instead of providing an action name as the FPM Event ID (see step 4 above) you can provide an arbitrary FPM Event ID (e.g. MyEventID) that will be handled by the Exit Class of the HTLB FBI View. In the Exit Class you can add coding to method ADAPT_EVENT to react on and handle the event. You can identify the corresponding Exit Class as follows:

1) Start the UI for displaying Freight Orders from e.g. the SAP user menu and display the technical help as described in section 5.3. On the technical help you can identify the application configuration, in our example /SCMTMS/ FRE_ORDER.

2) Start transaction SE84 and follow the path Repository Information System → Web Dynpro → Component Configuration. Enter Component Configuration name /SCMTMS/FRE_ORDER_HTLB in the input field Component Configuration on the right side.

3) Press F8 to start the selection and then double click on the found entry. On the right side you can now see the general attributes of FBI View /SCMTMS/FRE_ORDER_HTLB. Click on button Display Configuration to display the details of the FBI View.

4) On tab strip Header you can see the name of the relevant exit class in field Exit Interface Class. For the example this is class /SCMTMS/CL_UI_VIEWEXIT_TOR.

In the standard implementation of the identified Exit Class method ADAPT_EVENT you can see how to react on your own FPM Event IDs. The FPM Event ID that was configured for the new button on the main tool bar will be available at runtime in method parameter IV_EVENTID. The coding can then e.g. look as follows:

CASE iv_eventid.

WHEN /scmtms/if_ui_cmn_c=>sc_action-cmn-show_plan_blkdet OR

/scmtms/if_ui_cmn_c=>sc_action-cmn-show_exec_blkdet OR

/scmtms/if_ui_cmn_c=>sc_action-cmn-show_inv_blkdet. handle_show_blkdet( EXPORTING iv_eventid = iv_eventid ir_event_data = ir_event_data it_selected_rows = it_selected_rows CHANGING cv_failed = cv_failed ).

* React on your own Event ID here.

WHEN MyEventId.

" The coding that handles the event should be placed " in a separate method of e.g. a local class (in case " of customer extensions).

CALL METHOD MyEventIdHandler(). WHEN OTHERS.