Post

Real-Time UI Updates in RAP Using Event-Driven Side Effects

Learn how to implement event-driven side effects in ABAP RAP to automatically update the Fiori UI when backend data changes in real time.

Real-Time UI Updates in RAP Using Event-Driven Side Effects

Have you ever had a scenario where something changes in the backend and you want those updates to automatically reflect in the UI — without manually refreshing the page?

This is possible using Event-Driven Side Effects in RAP. Useful when:

  • A background job updates data and users should see the change in real time
  • Multiple users are working on the same data simultaneously

Step 1 — BDEF Configuration

Define an event and specify which fields it affects as side effects:

1
2
3
4
5
6
7
8
9
10
11
define behavior for ZI_Travel alias Travel
...
{
  event StatusChanged;

  side effects
  {
    event StatusChanged affects field OverallStatus, field Description;
  }
  ...
}

Step 2 — Projection BDEF

Expose the event in the projection layer:

1
2
3
4
5
6
define behavior for ZC_Travel alias Travel
...
{
  use event StatusChanged;
  ...
}

Step 3 — Raise the Event in save_modified

Raise the event in the behavior saver class, triggered only when the relevant field changes:

1
2
3
4
5
6
7
8
METHOD save_modified.
  LOOP AT update-travel ASSIGNING FIELD-SYMBOL(<travel>).
    IF <travel>-%control-OverallStatus = if_abap_behv=>mk-on.
      RAISE ENTITY EVENT ZI_Travel~StatusChanged
        FROM VALUE #( ( %key = <travel>-%key ) ).
    ENDIF.
  ENDLOOP.
ENDMETHOD.

When the status is updated via EML from a background job, the event is raised automatically and the UI refreshes the affected fields without a manual page reload.

Availability: SAP BTP ABAP Environment and SAP S/4HANA Public Cloud, and from release 2025 also in on-premise and private cloud systems.

This post is licensed under CC BY 4.0 by the author.