Simple FPM message / confirmation box
For a simple message or confirmation box in an FPM application (akin to e.g. MessageBox in UI5), the needs confirmation mechanism of the framework provides a simple option. Next best I know of, would be to implement a full blown Dialog Box, there are nice community blogs for that.
This FPM mechanism is described in the docs: FPM Basics > FPM Event Loop > Triggering a Data-Loss Dialog Box in the FPM Event Loop. Beware that the doc sample is about a predifined data loss dialog or overriding that with a custom dialog.
In summary, the FPM event loop provides an option to pause the event processing, display a dialog and then abort or resume the event processing based on the user dialog input. This is exposed by additional interfaces for the GUIBB feeder classes. They are located in package APB_FPM_GUIBB, same as the feeder class interfaces, named like the corresponding feeder class interfaces + …_EXT:
The matching interface must be added to the corresponding feeder class e.g. IF_FPM_GUIBB_FORM_EXT to the form feeder class. The NEEDS_CONFIRMATION method is called in the event loop and you can intercept any event flying around in the loop. The method has an exporting parameter EO_CONFIRMATION_REQUEST. Just create an instance for it and pass the constructor the title, details and button texts. The framework pops up a message box and depending on the user input stops or continues the event processing.
- Choose a logically suitable GUIBB of your FPM application. This needs to be in the FPM event loop when you want to show the message box.
- Pick or choose an event to trigger the message box, e.g. an event on a button.
- Add and implement the …_EXT interface in the GUIBB’s feeder class, e.g. IF_FPM_GUIBB_FORM_EXT
- In the NEEDS_CONFIRMATION method, filter for your event and create the EO_CONFIRMATION_REQUEST parameter object and pass in your desired message, title and button texts. The approve button will proceed the event processing, the reject button will stop it.
The event loop pauses while the “message box” dialog is shown. Very nice to use for Are you really sure and know what you are doing? kind of confirmations…
METHOD if_fpm_guibb_form_ext~needs_confirmation. CASE io_event->mv_event_id. WHEN io_event->gc_event_send. "filter the FPM event to show the message box for CREATE OBJECT eo_confirmation_request "the framework will render this as message box EXPORTING iv_window_title = |Title for the message box window| it_confirmation_text = VALUE #( ( |A string table with detail text to show in the window| ) ( |Multiple lines supported in the message box window| ) ) iv_button_text_approve = |e.g. Save, will proceed the event processing| iv_button_text_reject = |e.g. Cancel, will stop the event processing|. ENDCASE. ENDMETHOD.