Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
RavdeepSingh
Explorer
13,838

From User Exits to RAP: Adopting a Clean Core Approach in S/4HANA

Welcome to our SAP blog! In this blog we’re diving into the world of Clean Core in S/4HANA and how you can achieve it using the ABAP RESTful Application Programming Model (RAP). If you’re looking to future-proof your SAP system while extending its functionalities seamlessly, you’re in the right place. Let’s explore how RAP can help you maintain a cloud-ready, upgrade-safe system without compromising on flexibility.

 

Why Clean Core Matters

In today’s fast-paced digital landscape, businesses need agile and scalable systems. Clean Core is all about keeping your SAP system lean, efficient, and ready for the cloud. It ensures that your customizations don’t interfere with SAP’s standard processes, making upgrades smoother and reducing technical debt.

But here’s the challenge: How do you extend standard functionalities without breaking the core? Traditional methods like User Exits and BAdIs have served us well, but they’re not always cloud-compliant. Enter RAP a modern, event-driven approach to building and extending applications in S/4HANA starting from 2022.

 

Real-World Insights: The Shift to RAP

Through numerous customer engagements, my colleague Balaji @Balaji_Guptha  and I have seen firsthand the challenges of implementing Clean Core. Whether it’s a Brownfield migration or a Greenfield implementation, the goal remains the same: extend without breaking.

While traditional enhancements like User Exits are familiar, they often lead to upgrade headaches. RAP, on the other hand, offers a fresh perspective. It allows you to extend standard processes without modifying the core, ensuring compatibility with future upgrades.

 

The Power of Event-Driven Architecture

At the heart of RAP lies Event-Driven Architecture (EDA). This approach enables systems to react to changes in real-time, making it ideal for modern business processes. With RAP, you can leverage business events to trigger actions, integrate systems, and automate workflows—all while keeping your core clean.

Key Use Cases for RAP Events:

  • Real-Time Notifications: Automatically notify external systems about critical changes, like a new Sales Order or a status update.
  • Seamless System Integration: Enable third-party applications to react to business events without constant polling or synchronous API calls.

RAP Business Event Consumption

SAP provides two approaches to consuming RAP business events:

  1. Remote Event Consumption: Events consumed by external systems (e.g., SAP Event Mesh).
  2. Local Event Consumption: Events handled within the same RAP-based application without external dependencies.

This blog focuses on Local Event Consumption, which enhances system responsiveness and automation within an S/4HANA system.

Local Event Consumption: A Game-Changer

One of the most powerful features of RAP is Local Event Consumption. This allows you to handle events within the same RAP-based application, eliminating the need for external middleware. It’s perfect for scenarios where immediate follow-up actions are required.

How It Works:

  1. Event is Triggered: A change occurs in a RAP business object (e.g., Sales Order creation).
  2. Local Event Handling: An event handler class within the same application processes the event.
  3. Business Logic Execution: The handler class executes predefined logic, such as updating related entities or triggering validations.

Identifying the Standard RAP BO for Business Events

Before implementing local event consumption, identifying the correct RAP Business Object (BO) Root Entity is essential. Follow these steps:

 

  • Select your SAP product (e.g., S/4HANA Cloud, Private Edition)RavdeepSingh_1-1738847877038.png

 

  • Locate On-Stack Extensibility → Business Object InterfaceRavdeepSingh_2-1738847925047.png

 

  • Search for the relevant Business Object, e.g., Sales OrderRavdeepSingh_3-1738847925055.png

     

    RavdeepSingh_4-1738847925067.png

     

  • Once the Business Object (BO) Interface Name is identified, the next step is to navigate to Eclipse ADT (ABAP Development Tools) to determine the Event Binding and Root View Entity Name required for implementing local event consumption in RAP.
  • In Eclipse open the behavior definition for the Business Object interface I_SALESORDERTP.

    RavdeepSingh_5-1738847925081.png

     

  • In the ABAP repository tree navigate to Business Service Folder to get the Event binding name for the Business Object Interface I_SALESORDERTP.RavdeepSingh_6-1738847925090.png

     

  • Select the required business event, in our case it is Sales Order Created event.

    In the event binding we can find the standard RAP business object with events, R_SALESORDERTP.

    RavdeepSingh_7-1738847925102.png

     

  • Next navigate to the behavior definition of R_SALESORDERTP business object to check the events enabled for the RAP BO.RavdeepSingh_8-1738847925123.png

     

Identifying Business Events

SAP Provides a standardized way to explore and utilize business events through the SAP Business Accelerator Hub. This platform allows developers and architects to identify events relevant to their business processes and integrate them into an event-driven architecture.

To find the required business event, follow these steps:

  1. Navigate to SAP Business Accelerator Hub 
  2. Select the relevant SAP product (e.g., SAP S/4HANA Cloud, SAP S/4HANA Cloud Private Edition) based on the system you are working with.RavdeepSingh_3-1738852206372.png
  3. Once the product is selected, navigate to the "Events" tab. This section provides a list of all available events that the selected SAP solution can trigger. Search for the business process or required event in the search bar. In this example we have considered Sales Order EventsRavdeepSingh_4-1738852285924.png
  4. Select the event and click on it to view the detailed information.RavdeepSingh_5-1738852408142.png

Use Case: Automating Delivery Block in Sales Orders

Let’s look at a real-world scenario where RAP’s Local Event Consumption shines.

Business RequirementWhen a Sales Order is created, the system should automatically apply a delivery block if certain conditions are met. These conditions are based on predefined rules stored in a custom table.

Traditional ApproachIn the past, this would be implemented using a User Exit (MV45AFZZ). However, this approach is not cloud-compliant and can lead to upgrade challenges.

Clean Core Approach with RAPUsing RAP’s Local Event Consumption, we can achieve the same functionality without modifying the core. Here’s how:

Creating an Event Handler Class
  1. Define a global class that listens for events from the Sales Order business object.
  2. Use the keyword FOR EVENTS OF to specify the behavior definition.RavdeepSingh_0-1738849311476.png
Inherit from the Event Handler Superclass
  1. In the local class, inherit from CL_ABAP_BEHAVIOR_EVENT_HANDLER to access event-handling capabilities.RavdeepSingh_1-1738849311480.png
Define Event Handling Methods
  1. Create methods to handle specific events, such as SalesOrder.Created.RavdeepSingh_2-1738849311486.png
  2. Category of the custom class created will be ‘Event Handler for Entity Events’.RavdeepSingh_3-1738849311497.png
Implement Business Logic
  1. Logic to enable the delivery block at sales order header level.
  2. In this implementation, the Enablement of the Delivery Block in the sales order is achieved using Entity Manipulation Language (EML) instead of traditional BAPIs. 
  3. Refer to the SAP Help Portal at the following link: https://help.sap.com/docs/abap-cloud/abap-rap/entity-manipulation-language-eml . This resource provides the syntax and detailed explanation for EML.RavdeepSingh_4-1738849311506.png

By implementing this, we successfully automated the application of a delivery block in a cloud-compliant manner, ensuring minimal technical debt and future-proof extensibility. This approach not only aligns with SAP’s Clean Core principles but also enhances system agility and maintainability.

 

Why This Matters

By adopting RAP’s Local Event Consumption, you’re not just solving a business problem—you’re future-proofing your SAP system. This approach ensures that your customizations are cloud-compliant, upgrade-safe, and scalable.

 

Final Thoughts

RAP is more than just a programming model—it’s a mindset shift. It encourages us to rethink how we extend SAP systems, moving away from traditional methods and embracing modern, event-driven architectures. Whether you’re dealing with Sales Orders, Purchase Orders, or any other business process, RAP provides the tools you need to keep your core clean and your business agile. So, what are you waiting for? Start exploring RAP today and unlock the full potential of your S/4HANA system!

Stay tuned for more insights on Clean Core strategies in S/4HANA!

Feel free to ask for any clarifications or share your suggestions!

Regards,

Ravdeep Singh 

21 Comments
Labels in this area