Skip to Content
Technical Articles

Integrating the Business Core with the Blockchain (SAP S/4HANA -To- Blockchain)

The Opportunity :

 

With the increasing focus in adoption of SAP S/4HANA Cloud, comes the huge opportunity to integrate our business core with the forefront of technology, namely blockchain in order to solve some of the enterprise business problems [Eg., improving transparency, trust and traceability in systems such as logistics, shipping and asset verification].

Since data written to blockchain is immutable and every single transaction is recorded across distributed ledgers , enterprises can easily fit the use case of bringing the critical product information right from source(manufacturing plant) all the way to the blockchain for traceability and trust, leveraging our SAP Cloud Platform for integration.

Here we will share our experience of actually testing the concept of integrating SAP S/4 HANA Cloud with our Hyperledger Fabric based blockchain network (based on Canary/testnet).

End to End Integration Architecture

[SAP S/4HANA – To – Blockchain] :

After we had our initial blockchain use case implemented using Hyperledger Fabric architecture and also could test the data privacy implementation for the enterprise scenario,  we found ourselves aiming at extending the integration all the way to the SAP S/4HANA core.

Ref: Previous article about implementing Data Privacy in Hyperledger Fabric using Private Collections.

Our use case was to implement the transparency and trust of products (and its sub components) across the parties involved right from manufacture to assembly to  shipment to distribution.  To accomplish this, we had developed and tested custom smart contract API’s that can be leveraged directly by parties that what to be part of the trust network and interact with the blockchain.

But in this blog, the focus is to share our experience and design architecture  of how the SAP S/4HANA integration was made to fit in our overall use case .  [And we have interspersed it subtly with the challenges overcome and lessons learned along the way too !].

The Architecture :

In short, we configured SAP S/4HANA to propagate the Business event messages to a Queue in SAP Cloud Platform (Enterprise messaging service) , from where we consumed and recorded the critical info in our Blockchain network. 

Components and Technologies :

 

  • SAP Cloud Platform :

The SAP Cloud Platform forms the backbone of the whole integration. the SAP Blockchain services are instantiated and accessed via the SAP Cloud Platform that provides an easy to visualize Node and Channel Dashboards. The list of other services that are described below are all instantiated as part of the EU/10 Canary landscape (Frankfut). SAP S/4HANA Cloud integrates seamlessly with the Canary landscape.

  • SAP Blockchain Hyperledger Fabric Service and custom Chain code APIs :

The testnet based Hyperledger Fabric Nodes,  Channels and Private Collections we implemented are all part of the EU10 Canary landscape SAP Blockchain services.  Quota allocation and entitlement are handled the same way it is done for any other SAP Cloud Platform service. 

We wrote custom chaincodes to handle Data Privacy using Private collections and fine tuned Search operations.

We exposed the chaincode API’s via genetic Invoke API’s that can be integrated for doing the blockchain transactions.

For eg:

POST https://hyperledger-fabric.cfapps.sap.hana.ondemand.com/api/v1/chaincodes/com-sap-icn-sce-trackchain-pd/latest/invoke
Authorization: Bearer <token>
{
       "function": "getAsset",
       "transient": { "asset_id": "INT3333CHP"}
}
  • S/4 HANA System:

Though our use case can be practically extended to fit “any” kind of SAP S/4HANA system (on Premise, Hybrid etc), we learnt it the hard way after multiple attempts trying to procure and configure SAP S/4HANA backends,  cloud connectors and eventing configurations that the exact kind of system that would work for our scenario and integrate seamlessly with Canary(Dev) Landscape of SAP Cloud Platform with ease is the SAP S/4HANA Cloud Edition 1905 SP00 and higher.  On premise SAP S/4HANA should also work the same way if you know exactly how to configure cloud connectors and make the Business eventing propagate events successfully to Canary landscape.

In our case, the component that we were integrating with, was the Product/Material Master and we were integrating with the events from Task Object Type: Product. In some of our attempts, after configuring the whole integration with a backend system version, we would be blocked at end , puzzled as to why events won’t get propagated only to find (after trying to reach out to several teams via multiple message threads) that Only the Product Object Eventing had some issues while every other Object (BusinessPartner, PurchaseOrder, SalesOrder) would propagate just fine. This we heard was fixed in 1905 systems.

So, if you are quickly testing an integration of Eventing from SAP S/4HANA with SAP Cloud Platform/Canary landscape (skipping cloud connectors etc) ,  look for a 1905 or later SAP S/4HANA Cloud tenant systems !

  • Enterprise Messaging Service : 

This is a Pub/Sub Message Queueing Service thats available in SAP Cloud Platform . Its pretty straightforward and thanks to these blogs that helped save time configuring SAP S/4HANA eventing with EMS ! :

https://blogs.sap.com/2019/02/14/hands-on-video-tutorials-for-sap-cloud-platform-enterprise-messaging/

https://blogs.sap.com/2018/10/07/getting-started-with-sap-enterprise-messaging/

https://blogs.sap.com/2018/12/18/sap-cloud-platform-enterprise-messaging-making-s4hana-event-notification-easy/

Quick run down on configuring eventing propagation in SAP S/4HANA Cloud :

  1. Make sure , in the Business Event Subscription application of SAP S/4HANA, Enterprise Eventing is activated for the Object you are interested in.
  2. Configure Communication System, Arrangement(for Eventing Scenario) and Communication User to configure connectivity with EMS on Canary. This also activates the Communication channel.
  3. Go to Manage Your Solution App in SAP S/4HANA to configure Eventing Channel subscription for the activated channel with all events you are interested in (PO.changed, Product.Created etc)
  • The NodeJS Client Application :

We had a simple NodeJS client application that bound/subscribed to the EMS and consumed messages as they arrived in its Queue from SAP S/4HANA. We originally tried Functions which is a SAP CP Service (serverless functions) upon suggestion by Dominik‘s team, but it was in beta when we tried and we hit some issue and were in time crunch so we ended up with NodeJS client. I think for production scenario, Functions may be a  better choice (for cost purposes).

On message consumption, we needed to go back to SAP S/4HANA to bring back more details about the Master product data . Hence we integrated the OData APIs available in the SAP Hub : https://api.sap.com/api/API_PRODUCT_SRV/resource

Please note that you have to configure the corresponding API integration Communication Scenario similar to the Eventing scenario we did earlier, so the oData can be successfully called.

Upon Assembling required critical info for blockchain transaction, we called the BC chaincode API’s that we mentioned earlier.

We now had our complete end-end working scenario, For eg:

A product gets created or updated in product master, the blockchain ledger now holds a transaction reflecting the creation or change of the asset, thus maintaining transparent and traceability of a product among the trusted members of the blockchain network.

Thank you.

Credits: Mario Ponce , Sivakumar N

Be the first to leave a comment
You must be Logged on to comment or reply to a post.