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

Create a RAP Business Event in SAP BTP ABAP Environment

Create a RAP business event in SAP BTP ABAP Environment and test it using a local event handler

Overview

🎓 intermediate 45 min. SAP BTP ABAP EnvironmentIntermediateABAP DevelopmentSAP Business Technology Platform

You will learn

  • โœ”How to create a RAP Business Event inSAP BTP ABAP Environment
  • โœ”How to create a local event handler class for local consumption of the event created
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

  • You have access to a SAP BTP ABAP environment system, either free-tier or you have a license.

For more information, see:

Steps

Introduction

The ABAP RESTful Application Programming Model (RAP) now supports the native consumption and exposure of business events. 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.

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


Step 1 Create package and database table for RAP business object
โ€”

To produce and raise an event you need first to define your RAP Business Object (BO) that produces the event. For this, you will create a simple online shop application. The event will be sent whenever a new order is created.

  1. In ADT, open your SAP BTP ABAP environment system and create a new package for this tutorial, by choosing New > ABAP Package.

    step1a-new-package
    step1a-new-package

  2. Enter the following, then follow the wizard, choosing a new transport request:

    • Name: Z_BUSINESS_EVENT_###

    • Description Define a Business Event

      step1b-create-package
      step1b-create-package
      step1c-new-tr
      step1c-new-tr

  3. Select your package and choose New > Other Repository object > Database table from the context menu. Enter the following.

    • Name: ZONLINESHOP_###
    • Description: Database table for Online Shop

    step1d-create-db-table
    step1d-create-db-table

  4. Copy the code below to the Database and replace ### with your number.

You need the Admin field(s) for local_last_changed and last_changed in the table, in order to use the ABAP Repository Objects Generator later. These fields are used to provide optimistic concurrency control, using ETags. For more information, see: ETag Definition | SAP Help

  ```ABAP

  define table zonlineshop_### {
  key client     : abap.clnt not null;
  key order_uuid : sysuuid_x16 not null;
  order_id       : abap.char(10) not null;
  ordereditem    : abap.char(10) not null;
  deliverydate   : abap.dats;
  creationdate   : abap.dats;
  local_created_by      : abp_creation_user;
  local_created_at      : abp_creation_tstmpl;
  local_last_changed_by : abp_locinst_lastchange_user;
  local_last_changed_at : abp_locinst_lastchange_tstmpl;
  last_changed_at       : abp_lastchange_tstmpl;

  }

```
  1. Format, save, and activate your table ( Shift+F1, Ctrl+S, Ctrl+F3 ).
Step 2 Generate RAP BO and UI service from table
+
Step 3 Define business event in behavior definition
+
Step 4 Raise business event in behavior implementation class
+
Step 5 Create local event handler
+
Step 6 Test the Enhanced App
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 7
1. Create package and database table for RAP business object 2. Generate RAP BO and UI service from table 3. Define business event in behavior definition 4. Raise business event in behavior implementation class 5. Create local event handler 6. Test the Enhanced App 7. Test yourself

Learn more →