AWS for SAP

Event-Driven Architectures with the AWS SDK for SAP ABAP

Omnichannel strategies have become the norm for organizations across industries. In this environment, businesses often face the challenge of integrating different systems to ensure seamless data flow and near real-time updates. Especially in e-commerce businesses, showing up-to-date inventory of a product that customers want to buy is extremely critical. Lack of access to accurate inventory data can lead to stock-out situations where you run the risk of losing customers because you cannot ship what they ordered. Whenever there is an action that changes the stock level like product manufacturing, product purchase, etc., the inventory quantity is updated immediately in the SAP ERP system. These inventory updates in SAP ERP system related to the product in the storage locations/warehouses have to be sent to the e-commerce website in near real-time.

Achieving this near real-time view of inventory data is a challenge, especially for organizations looking to avoid hard dependencies between systems. Using decoupled or event driven architectures can help solve both issues in an efficient way.

The AWS SDK for SAP ABAP can help SAP customers address these challenges and achieve near-real time data updates in a secure, reliable, and predictable manner. This enables organizations keep backend SAP systems and e-commerce systems in sync, even in the face of rapidly changing market demand. In turn, they can avoid stockouts and other issues that lead to negative customer experience and potential loss of revenue. In this blog post, we will explore how the AWS SDK for SAP ABAP, Amazon Simple Queue Service (SQS) and AWS Lambda can be used to enable efficient, scalable, and near-real time communication between an SAP ERP system and an e-commerce website.

Scenario Overview

Let’s consider a simplified scenario where the SAP ERP system acts as the system of record for product and inventory data. An e-commerce website needs to be promptly updated with any changes made in the SAP ERP system, to ensure accurate product information and available inventory for optimal customer experience. Also, every time a customer places an order in the e-commerce website, the respective sales order must be created in the SAP ERP, to continue with the delivery process.

Traditionally, this integration requires a third-party solution which comes with operational overhead and incremental costs. With the AWS SDK for SAP ABAP, you can seamlessly connect with AWS services like Amazon SQS and AWS Lambda natively from SAP ERP and implement an event-driven architecture.

Event-driven architecture using AWS SDK for SAP ABAP and Amazon SQSFigure 1: Event-driven architecture using AWS SDK for SAP ABAP and Amazon SQS

Walkthrough

Creating an event-driven architecture to integrate an SAP ERP system and an e-commerce website using AWS SDK for SAP ABAP involves the following steps:

  • Publishing inventory availability updates from SAP ERP system to Amazon SQS.

When an existing product’s stock inventory is changed (for example, in standard transaction MIGO) in the SAP ERP system, an enhancement developed using the classes or methods provided by the AWS SDK for SAP ABAP can be triggered. Here’s an example, where the AWS SDK for SAP ABAP code is included in the SAP ERP Enhancement MBCF0002 within MIGO transaction:

Enhancement MBCF0002 with the code to send inventory data changes to Amazon SQS using AWS SDK for SAP ABAPFigure 2: Enhancement MBCF0002 with the code to send inventory data changes to Amazon SQS using AWS SDK for SAP ABAP

This simple SAP ABAP code shown in Figure 2, sends the inventory data update, in JSON format, to an Amazon SQS queue in near real-time. Using Amazon SQS ensures that the SAP ERP system is decoupled from the e-commerce website’s processing, while the ABAP SDK makes it easy to interact with AWS services without the need for manually creating complex integrations, while maintaining a strong security posture at SAP and AWS levels.

Let’s begin with a product where inventory is running out-of-stock. We can see how the quantities are synchronized in both systems as shown in figure 3.

Product availability in SAP ERP System (transaction MMBE) and the e-commerce Shop siteFigure 3: Product availability in SAP ERP System (transaction MMBE) and the e-commerce Shop site

After implementing the enhancement, when a Goods Receipt is posted in the SAP ERP System, as shown in the screenshot below (figure 4), the change in inventory data is sent to an Amazon SQS queue in near real-time.

Posting an update in inventory (receive 7 units) for material code AWS-STICKERS-SET in MIGO transaction, and data available in the Amazon SQS QueueFigure 4: Posting an update in inventory (receive 7 units) for material code AWS-STICKERS-SET in MIGO transaction, and data available in the Amazon SQS Queue

  • Update the e-Commerce via AWS Lambda

A Lambda function triggered automatically by the arrival of messages in the Amazon SQS queue, can process the inventory updates in different ways depending on the e-Commerce application architecture. This can be via API, via direct database update or by notifying the application to pick up the information from the Amazon SQS queue.

Product availability in SAP ERP System (transaction MMBE) and the e-commerce Shop siteFigure 5: Product availability in SAP ERP System (transaction MMBE) and the e-commerce Shop site

By leveraging AWS Lambda, you can achieve scalable and serverless processing of the product inventory update events, ensuring high availability and flexibility in your architecture, as detailed in this blog.

  • Notify SAP ERP of new sales orders from e-commerce site

When a new sales order is placed in the e-commerce site, the information needs to be sent to another Amazon SQS queue (see Figure 6). Different mechanisms can be used to automatically create the sales order in the SAP ERP system based on the messages in the SQS queue, including:

  1. Scheduled job polling the new Amazon SQS messages from the queue.
  2. Leveraging AWS Lamdba and SAP BTP Event Mesh service to notify the SAP ERP system to pick up the new Amazon SQS message. See detailed information on how to integrate BTP Event Mesh with SAP ERP in this blog.
  3. Orchestrating a solution to push the information to SAP ERP using the Amazon Appflow for SAP Odata write-back capabilities, as detailed in this blog.

Figure 6: New order placed in the e-Commerce site; data is available in the Amazon SQS queueFigure 6: New order placed in the e-Commerce site; data is available in the Amazon SQS queue

In the first 2 mechanisms mentioned above, a custom program enhanced with the AWS SDK for SAP ABAP, will read the Amazon SQS messages to create the sales orders. Here’s an example code (see Figure 7) that demonstrates how to read the SQS queue from within SAP ERP system using the AWS SDK for SAP ABAP:

Custom program using AWS SDK for SAP ABAP to read data from Amazon SQS queueFigure 7: Custom program using AWS SDK for SAP ABAP to read data from Amazon SQS queue.

Once the data is available in a structured ABAP object, you can easily use the SAP standard BAPIs for processing the sales order within the SAP ERP system.

Figure 8: Sales Order Document created in the SAP ERP SystemFigure 8: Sales Order Document created in the SAP ERP System.

You can enhance the architecture discussed above by including AWS services like Amazon SNS to notify the business teams about any errors in the process flow. You can also include Amazon EventBridge Event Bus into the architecture to receive the data from SAP ERP system, which then can fan out the data to multiple Amazon SQS queues, and also feeds AWS Datalakes in near real-time.

Benefits of using event-driven architectures for SAP business processes

Event-driven architectures offer several advantages for system integration and communication. Some of the key benefits include:

  1. Scalability: By decoupling systems through event-driven communication, you can easily scale individual components based on demand without impacting other parts of the architecture. This also provides ability to handle unpredictable traffic which is usually the case for e-commerce websites.
  2. Real-time Updates: Event-driven architectures enable near real-time updates, ensuring that changes made in one system are promptly propagated to other systems, resulting in synchronized data and improved user experience.
  3. Loose Coupling: Systems are loosely coupled, allowing them to evolve independently without significant dependencies. This enhances agility by enabling faster development and deployment cycles.
  4. Flexibility: Event-driven architectures provide the flexibility to add or remove components as needed, allowing you to adapt and evolve your system architecture over time.

We can also leverage event-driven architecture to improve other SAP-based business processes, including:

  • Integration with non-SAP customer relationship management (CRM) System: In this scenario, events triggered within the SAP ERP system such as changes in customer data or sales orders, can be published to an event stream or queue. The CRM system, subscribed to these events, can consume them and update customer records, sales pipelines, or other relevant information. This enables real-time synchronization between the two systems, ensuring consistent and up-to-date customer data across the organization.
  • Integration with Enterprise Content Management (ECM) System: SAP ERP systems can publish events related to document creation, modification, or archiving to an event stream or queue. The ECM system can consume these events, automatically capture and manage relevant documents, and associate them with corresponding transactions or records in the SAP ERP system. This ensures a centralized and consistent management of critical business documents across the environment.
  • Integration with a Courier Application: SAP ERP systems will publish messages on products ready to be picked for delivery, the Courier App will poll the message and determine the route and delivery date, sending messages back to SAP on the status, until final delivery to customer to close the loop.

Conclusion

Event-driven architectures provide an efficient and scalable approach to integrate SAP systems with other key enterprise applications to enable near real-time data synchronization. By providing access to 200+ AWS services natively using SAP ABAP language, the AWS SDK for SAP ABAP makes it possible to implement event-driven architectures to easily integrate SAP and non-SAP systems. Along with the SDK, you can leverage AWS services like Amazon SQS and AWS Lambda to achieve seamless communication and synchronization between different systems like SAP ERP and e-commerce websites. This addresses the challenge of lack of accurate inventory data in e-commerce and provides improved customer experience and better operational efficiency for organizations. The AWS SDK for SAP ABAP is available to you at no cost. You only pay for the AWS services that you access using the SDK. Please note that updating business data in SAP systems via third-party applications may be deemed as ‘Indirect Access’ and you need to comply with SAP license agreements for such a use of SAP systems.

Getting Started

To get started with the AWS SDK for SAP ABAP, visit our Getting Started Guide. You’ll also find links to product documentation, the API Reference Guide, and code examples to get you started.

To learn more about Event-Driven Architectures, read other AWS blog posts: