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.

    

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Vivek Priyadarshi

    Hi Christian,

    I am trying to use notification services in my project. However i can hardly find any documentation or sample code on sdn. Can you share some resources which can provide move information for the same.

    Coming to your sample code above. I dont see register_asynchronous_event in IF_FPM interface. I am on NW 7.31,SP 6.

    Is there another way to register the notification service to FPM?

    Regards,

    Vivek

    (0) 
    1. Christian Guenther Post author

      Hello Vivek,

      regarding the WebDynpro ABAP notification service you can find all available documentation in the system as class documentation for class CL_WD_NOTIFICATION_SERVICE. With freestyle UIBBs you can make use of this funtionality already in NW 7.31 SP 6 – with generic UIBBs there is possibility on your SP level.

      The integration into the FPM framework is only available with NW 7.31 SP 7.  So you have to upgrade to the next SP to get this feature.

      Best regards,

        Christian

      (0) 
      1. B. Meijs

        Hello Christian,

        We are on EHP6 FOR SAP ERP 6.0 (was731) and sap_basis level 0004. Is there a possiblity to use the asynchronous_event there, for example by implementing an Oss Note? We have seen that we are missing the needed method in IF_FPM.

        Thanks in advance,

        Ben Meijs

        (0) 
        1. Christian Guenther Post author

          Hello Ben,

          unfortunately there is no way to downport this. You have to upgrade to SP 7 in order to get this integration.

          Best regards,

            Christian

          (0) 
          1. B. Meijs

            Hello Christian,

            Thanks for your reply. I’m going to try to persuade them (“make them an offer they can’t refuse 😉 “) to upgrade.

            Regards,

            Ben

            (0) 
      2. Vivek Priyadarshi

        Hi Christian,

        I was curious if for EHP6( NW 7.31) since the notification is being attached to the view controller can it be an issue when used with OIF FPM. Depening on the setting of the view in UIBB it might be deleted when the view is not visible?

        I have tried this in my test OIF FPM application but it works despite the view being set to ‘Only visble’ . Do you know if this is a limitation?

        Regards,

        Vivek

        (0) 

Leave a Reply