Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member193369
Active Participant

If you have to start a backend process from your FPM application, which takes longer than one second you have two options:

  1. Block the UI and show a waiting cursor as long as the backend needs to fulfill the task
  2. Start the process in a seperate asynchronous task, allowing the user to continue to work with the application

The first option causes a bad user experience, the 2nd a usability issue: When the task is completed, how do you inform the user? You could add a 'refresh' button to your application allowing the user to request the current status of the background task. Or you could simply check the status with every subsequent roundtrip. Or you can trigger recurring roundtrips simply for status checking by using a timed trigger.

Of course the appropriate option depends on the use-case.

Since Netweaver 7.31 SP07 FPM now offers asynchronous events, which offers a better solution for this issue. You can simply trigger an FPM event when the task is done.


To do this you have to do the following steps:

  • Register the FPM event with IF_FPM. It will return a notification ID

data: lv_id type wdr_notification_id.
      lv_id = mo_fpm->register_asynchronous_event( lo_event ).

  • Start your asynchronous task and pass it the notification ID

       call function 'MY_ASYNCHRONOUS_TASK' starting new task mytask
        exporting
          iv_notification_id = lv_id
          ...

  • When the asynchronous task completes trigger the FPM event by calling

  cl_wd_notification_service=>update_event_status(
    exporting
      event_id     =     iv_notification_id
      event_status =     cl_wd_notification_service=>c_status_done ).

That's it.

If the functionality is available in your system you can also have a look at the test application FPM_TEST_ASYNCHRONOUS_EVENT which shows this feature in a very simple application.

    

6 Comments