Skip to Content

Blockchain is a digital technology which establishes a trusted environment to create, store and transfer value.

The advent of Internet allowed people to exchange and share information as a value. In Blockchain, the value could be a Digital currency, Digital Asset (physical items in the real world), Digital Identity, Reputation, Votes, Media, Carbon Credit, Land ownership …

Blockchain deploys a secure and decentralized ecosystem enabling an inalterable record of who owns what and who transacts what.  Value and transactions are then distributed over all the blockchain nodes in a transparent way without needing intermediaries (Peer-to-Peer).

In an environment where the trust and consensus are established, the value is immutable and transactions are fair, computer programs that automatically executes business instructions triggered by external events (Sales Order, Receipt of goods…) is an interesting application.  These automated computer programs running on a Blockchain system are called Smart Contracts.

 

 

The advantages of executing your Business Logic on a Blockchain rather than in a normal system are:

  • Decentralized execution: local copies live on the Blockchain nodes and execution of the contract is guaranteed.
  • Immutability: the business logic is signed by all parties and encrypted in a way that participants cannot change the contract once deployed, unless it’s killed and a new consensus version is instantiated.
  • Fair Information: the blockchain record can be shared among participants in a secure and transparent way.

 

In this Blog I’m going to showcase how a Business Blockchain Smart Contract hosted with Hyperledger Fabric could be integrated with SAP S/4HANA Cloud.

The scenario is:

  • A Blockchain trusted Business Network is established between Customers and Suppliers
  • The Customer launches a Request to the Blockchain Network asking for 10 TG11
  • TG11 is an agreed Digital Asset already created in the blockchain record which corresponds to a physical product in the Suppliers systems.
  • When the transaction is created on the blockchain, an event is triggered and the agreed Smart Contract is executed.
  • The Smart Contract looks for the best supplier in terms of predefined agreements between all parts. (Price, Delivery date, Historical data, Customer satisfaction rates …)
  • Once the Supplier is chosen by the Smart Contract, a Sales Order is sent to the corresponding system (S/4HANA Cloud in this case)
  • The Sales Order information is recorded in the Blockchain transaction and the Customer receives a notification.

Note: please enable subtitles.

 

Where are the benefits? The process is automated, transparent, secure and verifiable by all involved parts. No need for manual verifications, pricing condition search, ERP integrations or reconciliation tasks. The information and the contract are in the blockchain record, ready to be consumed through API’s. Even more, you can make the event triggers based on IoT data, automate payments and involve more processes such as Receipt of Goods and invoicing.

 

The following topics are to be covered in this Blog:

  • Hyperledger Fabric Blockchain for Business
  • Setting-up the Hyperledger Composer Environment
  • Developing Hyperledger Business networks
  • Integrating an Hyperledger Application with SAP S/4HANA Cloud

Note: Neither SAP Leonardo Blockchain nor SAP Cloud Platform Blockchain Service are the subject of this Blog. This would be covered in the future in a separate Blog series.

 

Let’s start! 😊

 

Hyperledger Fabric Blockchain for Business

Blockchain is actually for Business what Internet was for Communication.

Tip: Here you can find the Hyperledger Fabric Explainer.

 

Hyperledger Fabric is a platform for distributed ledger solutions underpinned by a modular architecture delivering high degrees of confidentiality, resiliency, flexibility and scalability. It is designed to support pluggable implementations of different components and accommodate the complexity and intricacies that exist across the economic ecosystem.

Tip: Please refer to the Key Concepts of Hyperledger Fabric.

 

The main characteristics of Hyperledger Fabric are:

  • Opensource: it’s an open blockchain framework implementation and one of the Hyperledger projects hosted by The Linux Foundation.

Note: SAP SE joined Hyperledger Project as Premier Member on March 22th, 2017.

  • Private and Permissioned: Unlike open permissionless blockchains that allow unknown identities to participate in the network, Hyperledger Fabric is private and permissioned. All members of a network enrol through a trusted MSP (Membership Service Provider)
  • Shared Ledger: Everybody in the network has a copy of the world state and transaction log.
  • Smart Contracts: called also “chaincodes”. They are invoked by external applications to interact with the Ledger.
  • Privacy: It supports private “channels” to allow sets of participants to share confidential information.
  • Consensus: it allows by design to choose a consensus mechanism that best represents relationships that exists between participants or sets of participants.
  • Modular, extensible and scalable: it supports plug-and-play components allowing network designers to plug-in their preferred implementations instead of rebuilding it.
  • No mining needed: unlike Bitcoin which incentivises participants to solve complex mathematical problems requiring time, computing power and energy, participants in Hyperledger Fabric as a permissioned blockchain work together around a common goal.

 

Setting-up the Hyperledger Composer Environment

Hyperledger Composer is an extensive, open development toolset and framework to make developing blockchain applications easier. The primary goal is to accelerate Time to value, and make it easier to integrate your blockchain applications with the existing business systems. You can use Composer to rapidly develop use cases and deploy a blockchain solution in weeks rather than months. Composer allows you to model your business network and integrate existing systems and data with your blockchain applications.

The key concepts of Hyperledger Composer are:

  • Blockchain State Storage
  • Connection Profiles
  • Assets
  • Participants
  • Identities and ID cards
  • Transactions
  • Queries
  • Events
  • Access control
  • Historian registry

Tip: Please refer to this Tutorial to learn how to set up an Hyperledger Composer environment.

Note: These are the pre-requisites before you start installing Hyperledger Composer.

 

Developing Hyperledger Fabric Business networks

Developers use Hyperledger Composer to digitize business networks. The business network is accessed by multiple participants in the network, some of which may be responsible for the maintenance (hosting) of the network itself, referred to as maintainers of the network.

A Business network definition are composed of:

  • Model files: define the business domain, the structure and the relationship between model elements: Asset, Participant, Transaction and Event.
  • Logic files: JavaScript files which contain the business logic and the transaction functions such as a Smart Contract.
  • Access control: a set of rules that define the rights of different particpants in the business network.

Tip: Please refer to this Tutorial to learn how to create an Hyperledger Composer Solution.

Note: The model of this Blog’s demo defines 3 assets (Product, PurchaseOrder, SalesOrder), 2 participants (Supplier, Customer), one transaction (ProcessPurchaseOrder) and 2 events (PurchaseOrderEvent, SalesOrderEvent)

namespace boa
asset Product identified by productId {
    o String productId
    o String productDescription
    o Double productStock
    --> Supplier supplier
}

asset PurchaseOrder identified by purchaseOrderId {
    o String purchaseOrderId
    o String description
    o Double quantity
    --> Customer customer 
    --> Product product 
    
}

asset SalesOrder identified by salesOrderId {
    o String salesOrderId
    o String description
    o Double quantity
    --> PurchaseOrder purchaseorder
}

participant Supplier identified by supplierId {
    o String supplierId
    o String supplierName
}

participant Customer identified by customerId {
    o String customerId
    o String customerName
}

transaction ProcessPurchaseOrder {
    --> PurchaseOrder purchaseorder 
    --> Supplier supplier 
}

event PurchaseOrderEvent {
    --> PurchaseOrder purchaseorder 
}

event SalesOrderEvent {
    --> SalesOrder salesorder 
}

 

Integrating an Hyperledger Application with SAP S/4HANA Cloud

You can install a REST server in Hyperledger Composer and generate REST API’s which will allow you to communicate with your Blockchain system from external clients.

Based on your Business Network Model, the generated API’s can be explored with Swagger:

Tip: please check this tutorial to learn how to generate API’s based on your business model.

You can easily create a destination in your SAP Cloud Platform pointing to your Hyperledger Composer Rest sever, consume these API’s and build your apps which interact with the Blockchain system. You can deploy these apps in SAP Cloud Platform or in your S/4HANA Cloud system.

Note: There is an  API delivered by the SAP API Business Hub to work with a Hyperledger Fabric instance provisioned via the SCP Blockchain Service. As I said at the beginning, this Blog is not about this service. The Blog demo is about your own Hyperledger Fabric instance together with the Composer Rest server which enables more integration capabilities.

 

On the other side, you can consume your S/4HANA Cloud API’s from the Hyperledger composer transaction functions. In this Blog’s demo the API_SALES_ORDER_SRV  has been used.

You would need to create a Communication Arrangement in your S/4HANA Cloud system to deploy the standard SAP_COM_0109 Communication Scenario. Smart Contract business logic deployed in Hyperledger will call the corresponding oData to create the Sales Order.

 

I hope you have enjoyed this Blog! Looking forward to sharing more details about Hyperledger Fabric architecture and mechanisms and how can intelligent SAP systems interact with the Blockchain ecosystems.

 

 

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Gregory Misiorek

    Hi Mohamed,

    great blog, but just wanted to confirm my understanding of these 2 points:

    1. you are putting SAP sales order on the fabric’s ledger
    2. the database persistence is on HANA database that runs underneath the fabric.

    can’t wait to try it out in a sandbox,

    thank you,

    greg

    (0) 
  2. Sitakant Tripathy

     

    Hi Mohamed,

    thanks for the blog.

    In my understanding, one of the very basic concerns with calling external from within the blockchain is idempotency. In guess in your scenario there are 2 points wherein this needs to be taken care off:

    • when identifying the source of supply considering this will reside in S/4 HANA for productive business case.
    • when creating the Sales Order in S/4 HANA system.

    Now keeping in view that, every node in the network will execute the same chain code and should have the same result from the API call, couple of questions:

    • How does the chain code know which endpoint to connect to for identify the requisition source and creating the SO.
    • For sales order creation in a multi node blockchain, multiple Sales Order would be created  henceforth rejecting the transaction as SO number would be different everytime unless the business API has a check first and then create logic.

    Please pardon me if these are very basic or detailed for that matter. Any help or pointer is appreciated..

    Regards,

    Sitakant.

    (0) 

Leave a Reply