SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →Reference

SAP-samples/abap-platform-bgpf-appl-log-events-side-effects

A RAP inventory sample that starts a long-running calculation through the background processing framework and pushes the result back to the UI with a side effect on a business event.

Shows how a RAP action can hand a long-running calculation to the background processing framework instead of blocking the request, and how the entity picks the result back up once the job finishes. A local saver class starts the background process after the RAP framework commits, and when the job updates the quantity field it raises a business event; a side effect declared on that event tells the UI to re-read the field, so the change appears without a manual refresh. Event-driven side effects are stated to run only on the SAP BTP ABAP Environment and SAP S/4HANA Cloud Public Edition, with private cloud and on-premise support planned for release 2025.

Facts

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
Async processingABAPAsync processingcapabilityDoing work outside the request that triggered it, with a guarantee that it eventually happens — deferred jobs, retries, and periodic work. Distinct from messaging, which is about telling other systems.

Who is behind it

SAP SamplesSAP SamplesOrganisationMaintains this
In the atlas: maintains 222
@SAP-samples
maintainerAjinkya PatilPersonContributes to this
In the atlas: contributes to 112
@ajinkyapatil8190
Andre FischerPersonContributes to this
In the atlas: contributes to 19, wrote 5
@anfisc
Thomas JungPersonContributes to this
Developer Advocate
In the atlas: contributes to 15, wrote 6
@jung-thomas
Volker DreesPersonContributes to this
In the atlas: contributes to 9
@VolkerDrees
4 contributors

What it declares

Every artifact

Type
Sample
Origin
By SAP
Use as
A reference

As a sample

Form
A reference application

Connections1

SAP-samples/abap-platform-bgpf-appl-log-events-side-effects connectionsSAP-samples/abap-platform-bgpf-appl-log-events-side-effectsPROVIDES→ demonstrates1demonstrates authoredAsync processing

README

quoted from SAP-samples/abap-platform-bgpf-appl-log-events-side-effects under Apache-2.0, read
SAP-samples/abap-platform-bgpf-appl-log-events-side-effects/README.mdOn GitHub

REUSE status

How to use BGPF and events for side effects in ABAP RESTful programming model

Description

In this repository you will find a simple RAP business object that simulates an inventory application. Since the calculation of inventories is a long running process this process is started asynchronously using the background processing framework (BGPF).

In the following animation check out the field Quantitity. When the button of the action that starts the calculation the process to caluclate the inventory of that product the UI is automatically updated after the entity itself has been updated.

Inventory App

So when pressing the button Calculate inventory on the Fiori UI of our RAP application an action reCalculateInventory is being executed which simply updates the field `BgpfStatus.

action reCalculateInventory;

This way we can check in the save_modifed( ) method of our local saver class whether the Calculate Inventory button has been pressed. The asynchronous process is conveniently started within the save_modifed( ) method using a class with a static method that takes the key of the updated entity of our RAP BO as a parameter

 DATA(bgpf_process_name) = zbgpfcl_calc_inventory_006=>run_via_bgpf( i_rap_bo_entity_key = update_inventory-%key ).

The background process is registered and being executed immediatley after the RAP framework has performed the COMMIT WORK statement.

When the background process finishes, it updates the entity of our RAP business objects using an EML call.

      MODIFY ENTITIES OF ZBGPFR_InventoryTP_006  
             ENTITY Inventory  
               UPDATE FIELDS ( Quantity )  
               WITH update  
               REPORTED DATA(reported_ready)  
               FAILED DATA(failed_ready).  
 

Again in the save_modified( ) method we check that the field Quantity has been updated. And if yes this raises the event QuantityUpdated.

       IF -%control-Quantity = if_abap_behv=>mk-on.  
          CLEAR events_to_be_raised.  
          APPEND INITIAL LINE TO events_to_be_raised.  
          events_to_be_raised[ 1 ] = CORRESPONDING #(  ).  
          RAISE ENTITY EVENT zbgpfr_inventorytp_006~QuantityUpdated FROM events_to_be_raised.  
       ENDIF.  

In the behavior definition we only have to specify a side effect for events which will cause a read request for the field Quantity. As a result the field Quantity will be updated in the UI immediately once the long running process that calculates the inventory has finished. The end user is notified via a small popup.

  // side effect events
  event QuantityUpdated for side effects;

  side effects
  {
    event QuantityUpdated affects field ( Quantity );
  } 

To get things working you have to make sure that the event is published via the behavior definition of your projection layer.

The projection behavior has to allow on business object level the use of side effects and on entity level the use of the event itself (and in our case the use of the action as well).

use draft;  
use side effects;  
define behavior for ZBGPFC_InventoryTP_006 alias Inventory  
use etag  

{ 
  use action reCalculateInventory;  
  use event QuantityUpdated;  
  ...   

Requirements

  • BGPF is available for private cloud and on premise SAP S/4HANA Systems as of release 2023
  • Event Driven Side Effects are currently only available in SAP BTP ABAP Environment and SAP S/4HANA public cloud ABAP Environment. We plan to make this available for on premise and private cloud systems as of release 2025

Download and Installation

Check out the following tutorial Import Content from abapGit Repository into the BTP ABAP Environment.

Known Issues

none

How to obtain support

Create an issue in this repository if you find a bug or have questions about the content.

For additional support, ask a question in SAP Community.

Contributing

If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.

License

Copyright (c) 2024-2026 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

Apache-2.0, read

Details

Sources3
Added by handdiscovered herechecked
github.com/SAP-samples/abap-platform-bgpf-appl-log-events-side-effectstree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
discovered viaAdded by hand
first seen in the atlas
ecosystem and domainabap, operations-and-runtime
Contributors4

From the repository’s contributor list, .

History in the atlas1
  1. First seen.
For your agent
Ref
artifact:sap-samples-abap-platform-bgpf-appl-log-events-side-effects
JSON
/artifacts/sap-samples-abap-platform-bgpf-appl-log-events-side-effects.json
MCP
Connecting an agent