SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

How to Create RAP Business Events in an On-Premise system

Create and exposure of business events in an On-Premise system

Overview

🎓 beginner 45 min. ABAP DevelopmentBeginner

You will learn

  • โœ”How to create Business Events with RAP in an On-Premise system
  • โœ”How to set up a channel to connect to SAP Event Mesh
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

Steps

Intro

Always replace #### with your initials or group number.

The ABAP RESTful Application Programming Model (RAP) now supports the native consumption and exposure of business events from release 2022. For exposure, an event can be defined and raised in a RAP business object or in the behavior extension and then published via Event Bindings.

Step 1 Create database table
โ€”

To produce and raise an event you need first to define your RAP Business Object which produce the event. For this, you will create a booking application. The event will be sent whenever a booking flight is cancelled.

  1. Open ADT and open your system.

  2. If you do not have an ABAP Package create a new one. Please be sure if your package name is started with Z like

- Name: `ZEVENT_BOOKING_####`
- Description: `define a RAP event`

![new](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-environment-create-s4hana-rap-business-events/1-1.png)
  1. Right-click on your package and create a new database table
- Name: `ZBOOKING_####`
- Description: `DB for booking`

![database](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-environment-create-s4hana-rap-business-events/1-2.png)

![database](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-environment-create-s4hana-rap-business-events/1-3.png)
  1. Replace the default code with the code snippet provided below and replace all placeholder #### with your group ID using the Replace All function Ctrl+F.
```ZBOOKING_####
@EndUserText.label : 'DB for booking'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zbooking_#### {
key client            : abap.clnt not null;
key travel_id         : /dmo/travel_id not null;
agency_id             : /dmo/agency_id;
customer_id           : /dmo/customer_id;
begin_date            : /dmo/begin_date;
end_date              : /dmo/end_date;
@Semantics.amount.currencyCode : 'zbooking_####.currency_code'
booking_fee           : /dmo/booking_fee;
@Semantics.amount.currencyCode : 'zbooking_####.currency_code'
total_price           : /dmo/total_price;
currency_code         : /dmo/currency_code;
description           : /dmo/description;
overall_status        : /dmo/overall_status;
attachment            : /dmo/attachment;
mime_type             : /dmo/mime_type;
file_name             : /dmo/filename;
created_by            : abp_creation_user;
created_at            : abp_creation_tstmpl;
last_changed_by       : abp_locinst_lastchange_user;
last_changed_at       : abp_locinst_lastchange_tstmpl;
local_last_changed_at : abp_lastchange_tstmpl;
}  

```
  1. Save and activate your table.
![database](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-environment-create-s4hana-rap-business-events/1-4.png)
Step 2 Create data generator class
+
Step 3 Generate the transactional UI services
+
Step 4 Publish the Service and Preview the Booking App
+
Step 5 Create an Event in Behaviour Definition
+
Step 6 Creation of an Event Binding for the Business Event
+
Step 7 Edit behavior implementation class
+
Step 8 Creating a channel using a service key
+
Step 9 Configure outbound bindings
+
Step 10 Create queue
+
Step 11 Create a Message in Application
+
Step 12 Test yourself
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 12
1. Create database table 2. Create data generator class 3. Generate the transactional UI services 4. Publish the Service and Preview the Booking App 5. Create an Event in Behaviour Definition 6. Creation of an Event Binding for the Business Event 7. Edit behavior implementation class 8. Creating a channel using a service key 9. Configure outbound bindings 10. Create queue 11. Create a Message in Application 12. Test yourself

Learn more →