This blog post is an article from a series of articles on the book published in December 2019 “Blockchain with SAP” (Rheinwerk publishing, Bonn, ISBN 978-3-8362-6914-8). This blog post concerns the seventh chapter from the book, in which the data from a Hyperledger Fabric blockchain is combined with a SAP HANA database to enable structured queries.
One of the highlights of our book “Blockchain with SAP” is the integration of collected transactional data from a blockchain to a SAP HANA database in order to formulate queries, for example, in SQL or to aggregate the blockchain data with other existing data.
The general process here is that the data exported from a blockchain’s blocks are shown as virtual tables in a SAP HANA database entity from where they can be further processed.
The blockchain Application Enablement service
The basis for the integration of blockchain data in a SAP HANA database is the blockchain Application Enablement service. This offers a standardized interface for querying the data from the blockchain for other applications. In combination with the SAP HANA blockchain, it enables the merging of blockchain data and a SAP HANA database.
The SAP HANA blockchain service consists of two components, the…
- SAP HANA Blockchain Adapter and
- the SAP HANA Integration Service
The SAP HANA Blockchain Adapter is an SDI connector (smart data integration) for the HANA database. It links to the SAP HANA integration service and transfers the data from the blockchain to the HANA database format.
Connecting the data from the blockchain via the blockchain Application Enablement Service, the SAP HANA integration service, the SAP HANA blockchain SDI adapter, and displaying the data as virtual tables in a SAP HANA database entity.
Activation of the Blockchain Application Enablement
The Blockchain Application Enablement service can be selected in the service marketplace.
It is available for various service plans including the blockchain Hana integration.
After creating the new service entity, it needs to be configured – specifically, this is the setup of the message structures. These are the data structures which describe the translation of the data to be read from the blockchain for the SAP HANA target database:
For this, a previously self-defined data model needs to be translated into a message structure that is to be defined. A ProductOffering of the decentralized energy market was therefore defined in the go program code as follows:
type ProductOffering struct { ObjectType string `json:"docType"` //docType is used to distinguish the various types of objects //in state database ProductName string `json:"productName"` Description string `json:"description"` OfferorID string `json:"offerorId"` BuyerID string `json:"buyerId"` Price float32 `json:"price"` Status int `json:"status"` Timestamp string `json:"timestamp,omitempty"` }
Transferred into the world of message structures for the SAP HANA database, this results in:
The individual attribute names have been retained; only its type has been adjusted to the SAP HANA data types.
Connection architecture
SAP HANA Integration
As a final step, the SDI adapter for the blockchain data is linked to the SAP HANA database and incorporated as an external data source:
Via the credentials, or the access token, the database creates a connection to the blockchain via the adapter. A screenshot is below.
The results are virtual tables with the data from the blockchain which can be incorporated under various aspects (pure user data view, only metadata, mixed view). Below is a screenshot of the ProductOfferings table from the blockchain with the data of offered products.
This table can now be queried and evaluated in SAP HANA using SQL.
More articles of this series can be found here:
- Blockchain with SAP: What is Blockchain and How Does It Work?
- Blockchain with SAP: Blockchain-as-a-Service Products from the SAP Cloud Platform
- Blockchain with SAP: Cloud Computing from SAP: The SAP Cloud Platform
- Blockchain with SAP: Business application scenarios for blockchains
- Blockchain with SAP: The First Steps to Having Your Own Blockchain
- Blockchain with SAP: Developing Applications with Hyperledger Fabric
- Blockchain with SAP: Developing Blockchain Applications with Hyperledger Fabric
- Blockchain with SAP: MultiChain Applications
- Blockchain with SAP: MultiChain Applications
- Blockchain with SAP: Hybrid Network Architecture and Camelot Hypertrust Platform
- Blockchain with SAP: Summary and outlook
Would you like to find out more about the possibilities of Hyperledger Fabric for your company? Our book “Blockchain with SAP” gives a detailed explanation of the advantages of the Hyperledger Fabric blockchain integration with SAP HANA. A detailed extract from the book is available online from the publisher.