DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Decoupling a Data Pipeline From the Tables It Was Never Supposed to Depend On
  • Share Delta Lake Tables Between Databricks and Snowflake
  • Why Vulnerability Management Fails Without Reliable Asset Data
  • Engineering Audit-Ready Data Pipelines for Regulatory Reporting

Trending

  • AI Agents for Software Engineering and Autonomous Development Workflows
  • Agentic Test Creation: From Plain-Language Requirements to End-to-End Test Cases
  • AI-Driven Integration in Large-Scale Agile Environments
  • The Context Window Trap: Why More Context Doesn’t Mean Better AI

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Data
  4. Integrating SAP With Serverless Camel

Integrating SAP With Serverless Camel

Camel in RHI allows you to connect to any preferred protocol. Developers can configure to connect to the endpoints with their address, credential, or SSL settings.

By 
Christina Lin
DZone Core CORE ·
Mar. 07, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

SAP is the world's leading enterprise business processing solution. There is always going to be a need to connect an organization's core to other SaaS offerings, partners, or even another SAP solution.  Red Hat Integration (RHI) offers flexibility, adaptability, and the ability to move quickly with framework and software to build the event-driven integration architecture. Not just connect, but also maintain data consistency across platforms. 

SAP offers interfaces such as OData v4, OData v2, RESTful API, and SOAP as the HTTP-based one, or you can also use the classic RFC(remote procedure call) and iDoc Messages. And there is a recent event enablement add-on that offers AMQP and MQTT protocol. Camel in RHI allows you to seamlessly connect to any of your preferred protocols. Developers can simply configure to connect to the endpoints with their address, credential, and/or SSL settings.

Here is a quick demo on how to Integrate SAP with 3rd party services. Using Camel K with Knative Eventing.

This demo uses the Classic Enterprise Procurement module in the Central Component of SAP ERP (SAP ECC) and gets the sales order details using Telegram Messenger. An employee enters the order ID into the chatbot on Telegram, it will immediately receive the order result back in the same conversation screen.

To build this true event-driven integration platform in the middle and available on multiple cloud vendors,  this time, I have Red Hat OpenShift installed on AWS and installed the Red Hat Serverless on to it.

To decouple the functions/services, I created two channels (event delivery mechanism that can fan-out received events, through subscriptions, to multiple destinations, or sinks). And have a Camel (Part of Red Hat Integration) application subscribe to the query events in the channel. This ABAP function was exposed as an OData V4 endpoint via the 'SAP Netweaver Gateway,' therefore I can simply use the Olingo4 components. 

Java
 




xxxxxxxxxx
1
53


 
1
import org.apache.camel.builder.RouteBuilder;
2

          
3
import java.util.Map;
4
import java.util.HashMap;
5

          
6
public class SapOdata extends RouteBuilder {
7

          
8
  Map<String, String> tempMap = new HashMap<String, String>();
9
    
10

          
11
  @Override
12
  public void configure() throws Exception {
13

          
14
  from("knative:channel/ordercheck")
15
    .unmarshal().json()
16
    .setHeader("CamelOlingo4.keyPredicate", simple("'${body[text]}'"))
17
    .bean(this, "create(\"${body[text]}\",\"${body[chat][id]}\")")
18
    .to("olingo4://read/SalesOrder")
19
    .split(simple("${body.properties}"))
20
      .choice()
21
        .when(simple("${body.name} == 'Customer' "))
22
          .bean(this, "aggregate(\"CUSTOMER\",'${body.value}')")
23
        .when(simple("${body.name} == 'Transactioncurrency' "))
24
          .bean(this, "aggregate(\"CURRENCY\",'${body.value}')")
25
        .when(simple("${body.name} == 'Grossamountintransaccurrency' "))
26
          .bean(this, "aggregate(\"SUM\",'${body.value}')")
27
        .when(simple("${body.name} == 'Taxamountintransactioncurrency' "))
28
          .bean(this, "aggregate(\"PRICE\",'${body.value}')")
29
      .end()
30
    .end()
31
    .setBody(method(this, "getSalesOrder()"))
32
    .marshal().json()
33
    .log("${body}")
34
    .to("knative://channel/returntxt")
35
  ;
36
  
37
  public void create(String salesorder, String chatid) {
38
    tempMap= new HashMap<String, String>();
39
    tempMap.put("SALESORDER", salesorder);
40
    tempMap.put("CHATID", chatid);
41
  }
42
    
43
  public void aggregate(String name, String value) {
44
    tempMap.put(name, value);
45
  }
46

          
47
  public Map<String, String> getSalesOrder() {
48
    
49
    return tempMap;
50
  }
51
  
52
}



The above camel route simply subscribes to one of the channels called order to check and query SAP using Olingo4 components. I have placed the configuration separately in a configuration file when there is a need to change for different circumstances. 

Properties files
 




xxxxxxxxxx
1


 
1
camel.component.olingo4.configuration.serviceUri=https://xxx/sap/opu/odata4/sap/mmm/default/sap/yyy_salesorder/zzzz/
2
camel.component.olingo4.configuration.httpHeaders[Authorization]=Basic oooooo



OData v4, RESTful API, and Events protocols are better suited for Serverless. As OData v4 has significant performance over the older version and support for the analytical application. Whereas OData v2, RFC, and iDoc are better used in traditional Camel Project. 

What Components to use for SAP endpoints.

  

Serverless

Camel K/Camel Quarkus

Camel

OData V4

✓

✓

OData V2

✕

✓

Restful API

✓

✓

SOAP

O

✓

RFC/IDoc

✕

✓

Events

✓

✓

Camel can then use the built-in data format components to transform the payloads. In the serverless case, data is mostly in the form of JSON.  By marshaling and unmarshaling incoming payload, we can easily access and retrieve the content value we needed.

Once complete, we can simply deploy this route to the cloud using Camel K cli or extensions in VS Code.  Camel K will deploy it as a serverless application.

Shell
 




xxxxxxxxxx
1


 
1
kamel run SapOdata.java



We also use Kamelets — a simplified set of templates for connecting source and sink for all the functions.  You can have it pre-built by integration developers (or camel developers). And other function developers to use it as a tool to connect. Therefore eliminate time-consuming "EventSource" development every single time. We want to grow our lists of Kamelets!!! Apache Camel community would love your contribution!! https://camel.apache.org/camel-kamelets/latest/Event Sources graphic

In the demo, we used the Telegram Kamelet, and bind it to my demo telegram bot. Queries from users are then passed through the Kamelet Binding, gets converted to standard CNCF CloudEvents, and becomes the events that will trigger the subscribed functions. 

Application

Summary: Architectural Overview 

This is how Red Hat Integration can help to achieve modernized integration with SAP. 

SAP exposes business functionality through the Netweaver Gateway. Camel K or Camel in RHI can be used by developers to integrate(bi-directional) these functionalities. Camel K/Camel not only connects the dot but also provides a set of built-in patterns and data transformations components making customized integration easy. They can be deployed in the form of a serverless function, serverless source/sink, or a long-running microservice. 

At the time of writing, I don’t see complete support from SAP event enhancements, developers do still require to retrieve real data via other methods such as OData and APIs. To implement a true event-driven architecture, AMQ Streams (Kafka) can be used as the event stream store to handle streaming of events, for reducing decoupling and achieving near real-time latency. 

Since the system is based on events, we can also capture changes of data state in Databases using Debezium. Keeping all data consistent by passing the updated state back to SAP. 

When there is a need to expose any functions or services as API endpoints, we can easily implement it with Camel using the OpenAPI Standard Specification. And have the API managed and secured by the 3scale API management platform. 

Openshift is the platform that can run on major cloud vendors and on-prem, so it’s truly cloud-agnostic. It provides a serverless platform to deploy and manage all functions. And with Interconnect we will be able to broadcast events, to the closest data center to optimize traffic control. 

As a result,  it is now ready to connect to endless 3rd party and partner services, streaming large amounts of edge signals and providing real-time processing from edge devices. Legacy, mainframe systems can also be part of the ecosystem. Lastly, this is a good tool for SAP to SAP integration too. 

Graphic Flowchart

See more on Red Hat Integration.

Data (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Decoupling a Data Pipeline From the Tables It Was Never Supposed to Depend On
  • Share Delta Lake Tables Between Databricks and Snowflake
  • Why Vulnerability Management Fails Without Reliable Asset Data
  • Engineering Audit-Ready Data Pipelines for Regulatory Reporting

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook