Guides implementation of event-driven patterns with RAP business events and SAP Event Mesh in ABAP Cloud, including event definitions, raising events, bindings, and consumption.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sap-fiori-url-generator:rap-business-eventsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide for implementing event-driven patterns using RAP business events and SAP Event Mesh in ABAP Cloud.
Guide for implementing event-driven patterns using RAP business events and SAP Event Mesh in ABAP Cloud.
Determine the user's goal:
Identify the scenario:
Guide implementation following RAP eventing patterns
| Concept | Description |
|---|---|
| Business Event | Declared in BDEF; raised when something significant happens |
| Event Definition | Formal declaration with parameters in the behavior definition |
| Event Raising | Triggered in handler/saver methods via RAISE ENTITY EVENT |
| Event Binding | Maps RAP event to an enterprise event topic for external delivery |
| Event Consumption | External systems subscribe and react to published events |
managed implementation in class zbp_r_travel unique;
strict ( 2 );
define behavior for ZR_Travel alias Travel
persistent table ztravel_tab
lock master
authorization master ( instance )
etag master LocalLastChangedAt
{
create;
update;
delete;
"Define business events
event travel_created parameter ZD_TravelCreatedEvt;
event travel_accepted;
event travel_rejected;
}
Define a CDS abstract entity for the event payload:
@EndUserText.label: 'Travel Created Event'
define abstract entity ZD_TravelCreatedEvt
{
travel_id : /dmo/travel_id;
agency_id : /dmo/agency_id;
customer_id : /dmo/customer_id;
description : /dmo/description;
total_price : /dmo/total_price;
currency : /dmo/currency_code;
}
Events without the parameter addition have no payload.
METHOD on_travel_accept.
"Read travel data
READ ENTITIES OF zr_travel IN LOCAL MODE
ENTITY Travel
ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT DATA(lt_travels).
"Update status
MODIFY ENTITIES OF zr_travel IN LOCAL MODE
ENTITY Travel
UPDATE FIELDS ( status )
WITH VALUE #( FOR travel IN lt_travels
( %tky = travel-%tky
status = 'A' ) )
REPORTED DATA(lt_reported).
"Raise event for each accepted travel
RAISE ENTITY EVENT zr_travel~travel_accepted
FROM VALUE #( FOR travel IN lt_travels
( %key = travel-%key ) ).
ENDMETHOD.
METHOD on_travel_create.
"After successful creation
RAISE ENTITY EVENT zr_travel~travel_created
FROM VALUE #( FOR travel IN lt_created_travels
( %key = travel-%key
%param = VALUE #(
travel_id = travel-travel_id
agency_id = travel-agency_id
customer_id = travel-customer_id
description = travel-description
total_price = travel-total_price
currency = travel-currency_code ) ) ).
ENDMETHOD.
METHOD save_modified.
"Raise events in the save phase for committed data
IF create-travel IS NOT INITIAL.
RAISE ENTITY EVENT zr_travel~travel_created
FROM VALUE #( FOR travel IN create-travel
( %key = travel-%key
%param = VALUE #(
travel_id = travel-travel_id ) ) ).
ENDIF.
ENDMETHOD.
1. User action triggers RAP operation
2. Handler method executes business logic
3. RAISE ENTITY EVENT queues the event
4. RAP framework commits the transaction
5. After successful COMMIT:
a. Local event handlers are called
b. Enterprise events are published to Event Mesh
To publish RAP events externally, create an event binding:
ADT: New → Other → Event Binding
Name: Z_EVT_BIND_TRAVEL
Event binding maps RAP events to enterprise event topics:
| Property | Value |
|---|---|
| Namespace | sap.s4.beh or custom namespace |
| Business Object | ZR_Travel |
| Event | travel_created |
| Topic | sap/s4/beh/travel/created/v1 |
<namespace>/<business-object>/<event-name>/<version>
Example: z.custom/travel/created/v1
SAP_COM_0092 (Enterprise Event Enablement)Register an event handler class:
CLASS zcl_travel_event_handler DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
"Event handler method
METHODS on_travel_created
FOR ENTITY EVENT
travel_created FOR Travel~travel_created.
ENDCLASS.
CLASS zcl_travel_event_handler IMPLEMENTATION.
METHOD on_travel_created.
"React to travel creation
LOOP AT travel_created INTO DATA(ls_event).
"Process event data
DATA(lv_travel_id) = ls_event-travel_id.
"e.g., send notification, update related records
ENDLOOP.
ENDMETHOD.
ENDCLASS.
External systems subscribe to topics via:
"Using the event consumption model
"1. Create event consumption model in ADT
" (imports AsyncAPI spec or defines events manually)
"2. Implement the event handler
CLASS zcl_ext_event_handler DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_event_handler.
ENDCLASS.
CLASS zcl_ext_event_handler IMPLEMENTATION.
METHOD if_event_handler~handle.
"Parse event payload
DATA(lv_payload) = io_event->get_text( ).
"Process the event
ENDMETHOD.
ENDCLASS.
Producer raises event → Event Mesh delivers → Consumer processes independently
Include full entity data in event payload so consumers don't need to call back:
RAISE ENTITY EVENT zr_travel~travel_created
FROM VALUE #( ( %key = ls_travel-%key
%param = CORRESPONDING #( ls_travel ) ) ).
Record every state change as an event for full audit trail.
/v1, /v2)When helping with eventing topics, structure responses as:
## RAP Business Event Guidance
### Scenario
- Type: [Local event / Enterprise event]
- Role: [Producer / Consumer]
### Implementation
[Event definition, raising, and consumption code]
### Configuration
[Event binding and communication arrangement setup]
npx claudepluginhub likweitan/abap-skills --plugin sap-fiori-url-generatorGuides RAP (RESTful ABAP Programming Model) development: behavior definitions, EML, managed/unmanaged BOs, draft, actions, validations, determinations, side effects, and business events for ABAP Cloud Fiori apps.
Generates a complete RAP OData UI service stack from a natural-language business object description — table, CDS views, behavior definitions, metadata extension, service definition, and behavior pool class.
Guides development of business apps on SAP BTP using CAP (Node.js/Java) or ABAP Cloud, for Cloud Foundry/Kyma deployments, HANA integration, Fiori UIs, CI/CD pipelines, and observability.