This blog post covers how to expose an XS OData Service in SAP HANA Service with CRUD operations, consume the same in SAP Cloud Platform Integration iFlow
Introduction
We always get queries on how to connect SAP Cloud Platform Integration service with the SAP HANA service on the SAP Cloud Platform Cloud Foundry environment using Odata approach. We are trying to address that in this Blog post.
In SAP Cloud Platform Integration, You can consume XS Odata services that is exposed from SAP Cloud Platform, SAP HANA Service. In this blog post, I will be creating an XS Odata Service on SAP HANA service and consuming the same from SAP Cloud Platform integration iFlow.
SAP help Documentation of SAP HANA Service:
https://help.sap.com/viewer/cc53ad464a57404b8d453bbadbc81ceb/Cloud/en-US/f70399be7fca4508aa0e33e138d...
SAP help documentation of SAP Cloud Platform integration Service in Neo:
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/e7b1eaa2246641b3a6188233cf2...
Prerequisite
- You need to have SAP HANA Service instance in the Sap Cloud Platform Cloud Foundry environment
- You need to have SAP Web IDE full-stack enabled in the Sap Cloud Platform Neo
- You need to have SAP Cloud Platform integration service Tenant
- You have to know how to model Integration Flows in SAP Cloud Platform integration Service
What this blog doesn’t cover
- How to enable SAP HANA Service , SAP Web IDE full-stack.
Contents
- Create SAP HANA Service database table which we expose as XS Odata Service
- Create new SAP HANA database Application in Web IDE full-stack
- Add Node.js module to the Application
- Create XS Odata service file and expose SAP HANA Service Database table as odata service
- Configure mta.yaml and deploy as SAP Cloud Platform CF application
- Test XS Odata service and Query table metadata/data
- Create Simple Integration flow which write data to XS odata service
- Deploy and monitor the message processing state
- Validate inserted record in the SAP HANA Service Database Table
- Create SAP HANA Service database table which we expose as XS Odata Service
- Open the SAP HANA Database explorer and add your own database from the HDI Containers

- Open the Database and add RESOURCE Table by executing a custom SQL Query

Result is that the RESOURCE table should appear under Tables.
- Create new SAP HANA database Application in Web IDE full-stack
- Open the SAP Cloud Platform Web IDE full-stack application and select he File->New->Project from template option and search for HANA

- Select SAP HANA Database application and click next, provide project name.
For ex: XSOdataDemo
- Click on next and finish to complete the creation of the project

- Add Node.js module to the Application
- Adding new node.js module to the SAP Cloud platform HANA Database application

- Provide name for the module, say XSOdataService and click Next , Select Enable XSJS support and finish it

XSOdataService node.js module would appear in the project structure
- Create XS Odata service file and expose SAP HANA Service Database table as odata service
- Create a resource.xsodata file under lib directory and provide odata service definition as defined below:

Save the project
- Configure mta.yaml and deploy as SAP Cloud Platform CF application
- Edit the mta.yaml in the MTA editor and select XSOdataService Node.js module. Add the resource, module and provider details. Save the project and build it

- Deploy the built MTAR file on to the SAP Cloud Platform CF application runtime

We can see that XSOdataService is deployed and up & running
It also bind to the HANA service
- Test XS Odata service and Query table metadata/data
- Copy the application endpoint from the deployed XS Odata service

- On query of Table metadata from resource.xsodata service , you can see the SAP HANA Service database table structure in XML format

Example url:https://xxxx-xx-xxxpm-xsodataservice.cfapps.eu10.hana.ondemand.com/resource.xsodata/$metadata
- Create Simple Integration flow which write data to XS Odata service
- Create a simple integration flow with timer, Content Modifier and HTTP Request/Reply Components

- Configure Scheduler to run once and provide Content modifier with below configuration for body and headers


- Configure HTTP adapter with XSOdataService endpoint URI with table details
End point URL should include the table name , which we trying update using HTTP Post

Post Request URL, In our case is: https://xxx-xxxx-xx-xsodataservice.cfapps.eu10.hana.ondemand.com/resource.xsodata/MYRESOURCE
Where MYRESOURCE is the alias we defined in the XS Odata service definition
- Deploy and monitor the message processing state
- Deploy the integration flow and monitor message processing state. Status should be completed without any errors

This integration flow would insert record defined in the Content Modifier message body in to the RESOURCE Table defined in the SAP HANA Service database
- Validate inserted record in the SAP HANA Service Database Table
- Open RESOURCE table data in the SAP HANA Database explorer, you will be see the newly inserted record using XS Odata Service

Conclusion
In this Blog Post, we have showcased how easy it is to build a SAP HANA Database application using SAP Web IDE full-stack, where we expose a XS Odata service from a SAP HANA Service database table, consumed the Odata service from SAP Cloud platform Integration service IFlow using HTTP adapter