Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member182680
Active Participant

Confirmation boxes vs. Dialog boxes

In FPM, there is a concept called "Dialog Boxes" which allows you to embed any FPM component configuration in popups. Usually, this is overkill for simple confirmation boxes as you usually want to display a warning message there. Depending on the user decision "Yes" or "No" there is be some further backend logic to be invoked. This blog post deals with the question how showing these confirmation boxes can be achieved with quite few effort in a clear, transparent way.

Standard approach (FPM)

Use the FPM Interfaces for GUIBBs whenever possible. These interfaces are called IF_FPM_*_EXT*. These interfaces each provide a method called NEEDS_CONFIRMATION which allows you to intercept and defer event processing.

For freestyle UIBBs, there is also a method IF_FPM_UI_BUILDING_BLOCK~NEEDS_CONFIRMATION.

You can specify a warning message by using the exporting parameter EO_CONFIRMATION_REQUEST. It allows you to specify title, message and which button texts should be displayed. In case the user confirmed the warning message, the PROCESS_EVENT is called.

Whenever possible, use this standard approach.

Individual approach (custom developed)

However, this approach has its drawbacks. One of the drawbacks is that multiple message lines do not look that good as you need to concatenate the texts. Also, mixing success and warning or even error messages (which is not recommended to use in confirmations) is not possible. Last but not least, the width of the popup cannot be changed.

So this chapter is about how you can define your own popup windows in FPM.

The first step starts with raising an FPM event in the GUIBB feeder class / freestyle UIBB and attaching a message table like BAPIRET2_TAB and a self-defined callback object. I do not further describe how the callback object could work. Please see this blog post for further details to get an idea how such a callback could work.

There will be another UIBB to handle this event and show the popup with the messages that are defined in the message table attached to the event.



DATA lo_event TYPE REF TO cl_fpm_event.
lo_event = cl_fpm_event=>create_by_id( iv_event_id = ‘OPEN_CONFIRMATION_POPUP’ ).
lo_event->mo_event_data->set_value( iv_key = ‘MESSAGES’iv_value = lt_bapiret2 ).
lo_event->mo_event_data->set_value( iv_key = ‘CALLBACK’ iv_value = lo_callback_activity_complete ).
mo_fpm->raise_event( lo_event ).


Create a webdynpro component with an empty main window and empty view V_POPUP_EMBEDDER which implements IF_FPM_UI_BUILDING_BLOCK. This allows you to embed this webdynpro component into your FPM application. As this component only needs to be visible, when a popup needs to be shown, you can embed an empty window with an empty view V_POPUP_EMBEDDER to your FPM application. It is crucial that the component takes part in every event loop so the empty view should not be in a tab, rather at a position which is always displayed.

Create an event POPUP_WITH_CALLBACK with the IMPORTING parameters to cover both the callback object type and BAPIRET2-table type.

Create a webdynpro component with an empty main window and empty view V_POPUP_EMBEDDER which implements IF_FPM_UI_BUILDING_BLOCK. This allows you to embed this webdynpro component into your FPM application. As this component only needs to be visible, when a popup needs to be shown, you can embed an empty window with an empty view V_POPUP_EMBEDDER to your FPM application. It is crucial that the component takes part in every event loop so the empty view should not be in a tab, rather at a position which is always displayed.

Create an event POPUP_WITH_CALLBACK with the IMPORTING parameters to cover both the callback object type and BAPIRET2-table type.

The process event method retrieves the attached event parameters and raises the internally used webdynpro event:


METHOD process_event.
DATA lv_title TYPE string.
DATA lt_message TYPE string_table.
DATA lr_event TYPE REF TO data.
FIELD-SYMBOLS <lo_event> TYPE REF TO cl_fpm_event.

FIELD-SYMBOLS <lv_key> LIKE LINE OF lt_keys.
FIELD-SYMBOLS <lv_any> TYPE any.
DATA lr_data TYPE REF TO data.
DATA lo_object TYPE REF TO object.

CASE io_event->mv_event_id.
WHEN ‘OPEN_CONFIRMATION_POPUP’.
io_event->mo_event_data->get_value(
EXPORTING
iv_key =  ‘MESSAGES’
IMPORTING
ev_value = lt_bapiret2 ).
io_event->mo_event_data->get_value(
EXPORTING
iv_key =  ‘CALLBACK’
IMPORTING
ev_value = lo_callback ).
      wd_this->fire_popup_with_callback_evt(
io_callback = lo_callback
it_bapiret2 = lt_bapiret2
).
ENDCASE.ENDMETHOD.

Create the component controller’s event handler in the empty view.


METHOD open_popup_with_callback.
”store callback object in view’s attributes
wd_this->mo_callback = io_callback.
DATA lo_comp_api TYPE REF TO if_wd_component.
DATA lo_controller_api TYPE REF TO if_wd_controller.
DATA ls_config TYPE wdr_popup_to_confirm.
DATA: lt_text_table TYPE string_table,
lv_text_table TYPE string,
lv_title TYPE string.

ls_config-button_cancel-enabled = abap_false.

lo_controller_api = wd_this->wd_get_api( ).
lo_comp_api = wd_comp_controller->wd_get_api( ).
lv_title = ‘Sure?’

DATA: l_api_component  TYPE REF TO if_wd_component,
l_window_manager TYPE REF TO if_wd_window_manager,
l_api_view       TYPE REF TO if_wd_view_controller.


l_api_component = wd_comp_controller->wd_get_api( ).
l_window_manager = l_api_component->get_window_manager( ).

wd_this->mo_window = l_window_manager->create_window(
window_name = 'W_POPUP'
title = iv_title
button_kind = if_wd_window=>co_buttons_yesno ).

wd_this->mo_window->open( ).

l_api_view = wd_this->wd_get_api( ).

wd_this->mo_window->set_on_close_action(
view        = l_api_view
action_name = 'CLOSE_POPUP' ).
wd_this->mo_window->subscribe_to_button_event(
button      = if_wd_window=>co_button_yes
action_name = 'CONFIRM_POPUP'
action_view = l_api_view ).
wd_this->mo_window->subscribe_to_button_event(
button      = if_wd_window=>co_button_no
action_name = 'CLOSE_POPUP'
action_view = l_api_view ).
ENDMETHOD.


Create the actions CLOSE_POPUP and CONFIRM_POPUP in the view. CONFIRM_POPUP should execute the callback object’s callback method, like



IF wd_this->mo_callback IS NOT INITIAL.
wd_this->mo_callback->callback( ).
CLEAR: wd_this->mo_callback.
ENDIF.

Create the window W_POPUP with its own view V_POPUP. Show the content of the message table that came with the FPM event e.g. in a message area.

The popup will look like this. The screenshot shows only one warning message, so there is no benefit yet compared to the standard approach provided by the FPM runtime. But it is capable of showing multiple warnings and even different message types.

11 Comments
Labels in this area