Skip to Content
Technical Articles

OData with SAP HANA Cloud | Hands-on Video Tutorials

With this blog series we provide an update with the latest information on getting started with SAP HANA Cloud on the SAP Cloud Platform.

  1. About SAP HANA Cloud
  2. SAP HANA Cloud Getting Started
  3. Connecting SAP Analytics Cloud using the HANA Analytics Adapter
  4. Cloud Foundry Advanced (space travel, multiple instances, defining schema names)
  5. Data masking and data anonymization
  6. Predictive Analysis Library (PAL) and Automated Predictive Library (APL)
  7. Remote data sources and virtual tables
  8. SAP Web IDE for HANA Development, SAP Cloud Platform Cloud Foundry environment
  9. SAP HANA Cloud and Smart Data Integration
  10. OData with SAP HANA Cloud

For more information about the free trial, see

Questions? Post as comment.

Useful? Give a like and share on social media. Thanks!

/wp-content/uploads/2016/02/sapnwabline_885687.png

Hands-On Video Tutorials

Philip MUGGLESTONE just added another video tutorial to the SAP HANA Cloud series. In this blog, you will find the video embedded with some additional information and resources. Following along in the patented zero-to-hero format, you will be ready to start working with OData with minimal effort and no time wasted.

You can watch the video tutorial in a little under 10 minutes. What you learn is

  • How to use a Yeoman app generator to create a sample multi-target app (MTA) which automatically creates the OData services for a chosen schema in SAP HANA Cloud
  • How the code works and what apps, services, and database catalog objects get created
  • How to use Postman to GET, POST, and DELETE data using the OData Services

As development environment we use the SAP Business Application Studio and the free 90-day SAP Cloud Platform trial environment for which you can sign up here:

To follow along you will need some basic understanding of the SAP Cloud Platform concepts and be familiar with global and subaccounts, Cloud Foundry, destinations, subscriptions, identity provider, SAP HANA Cloud, and HDI. In case you are new to the SAP Cloud Platform or could use an update, please first join our onboarding program:

As we know your time is precious, this will be a low-code affair as we will be using Yeoman to provide the scaffolding for our app supplemented with sample code from SAP HANA Academy GitHub repository:

Ready? Let’s make some REST calls!

/wp-content/uploads/2016/02/sapnwabline_885687.png

What Exactly is OData (again)? 

According to Microsoft (where the technology is coming from), as documented in Welcome to OData

OData (Open Data Protocol) is an ISO/IEC approved, OASIS standard that defines a set of best practices for building and consuming REST APIs. It enables creation of REST-based services which allow resources identified using Uniform Resource Locators (URLs) and defined in a data model, to be published and edited by Web clients using simple HTTP messages.

In more digestible terms, it is a way to interact with data sources over the web.

See Understanding OData in 6 steps for a bit more background from odata.org or (when you have bit more time), see blog series

 

/wp-content/uploads/2016/02/sapnwabline_885687.png

How Hard Can It Be? 

Working with OData using the SAP HANA XS classic model is not that difficult.

Create a file with the .xsodata file extension in your favourite IDE, say SAP HANA Web-based Development Workbench, and enter the service definition.

As documented,

However, this technology is deprecated and no longer available for SAP HANA Cloud.

service namespace "my.namespace" {
         "sample.odata::table" as "MyTable";
}

 

Working with OData using SAP HANA XS Advanced model and the SAP Cloud Platform Cloud Foundry environment for SAP HANA Cloud is a bit more challenging in particular when you need the current OData v4 version or have a larger selection of tables and views to configure. Let’s say this approach has some limitations.

An alternative and more recent approach involves the Cloud Application Programming (CAP) model but this provides a bit of a learning curve as it assumes a certain familiarity with CAP, Core Data and Services (CDS), Cloud Foundry, SAP HANA HDI, and OData.

/wp-content/uploads/2016/02/sapnwabline_885687.png

In Comes Yeoman

What if we would have a generator that writes the entire project including the CAP CDS modeling and also performs the SAP HANA configuration – so you can have OData up and running on all the tables and views of a given classical SAP HANA schema in about 5 minutes?

For free?

yo Saphanaacademy Odata

/wp-content/uploads/2016/02/sapnwabline_885687.png

OData on a Classical Schema

In this video tutorial, we install the yeoman OData generator and run it to scaffold the project. We can choose to include support for OData v2 (in addition to v4), add authentication and authorization, and directly build and deploy the app. After adding a role collection and inspecting the apps and services in SAP Cloud Platform cockpit, we interact with some of the OData services using Postman. The tutorial ends with a code walkthrough.

0:00 – Introduction

0:30 – SAP HANA Cloud > Advanced Settings: Allowed connections: Allow all IP addresses

0:45 – SAP HANA database explorer and execute sample schema, table, and view (source: travel_OData.sql)

1:30 – SAP Business Application Studio, create SAP Cloud Business Application dev space, and connect to the Cloud Foundry environment (trial org and space)

2:00 – open Terminal and install a Yeoman generator

npm i -g generator-saphanaacademy-odata

2:30 – Run the yo command and select Saphanaacademy Odata template: enter the app name, SAP HANA Cloud endpoint, database user, password, schema, OData v2 support, authentication and authorization, build and deploy.

3:45 Go to SAP Cloud Platform cockpit > subaccount Security > Trust Configuration: <e-mail> and assign the desired role collection

  • myappodata_read
  • myappodata_write

4:00 Run the application (app router) and the OData service is displayed with all tables and views.

4:45 – for OData v2 append /v2 to the URL, e.g. /v2/srv/Customers

5:00 – Open Postman

5:30 – Authorization: OAuth 2.0 > Get New Access Token:

grant type = password credentials

username = <e-mail trial account)

clientid, clientsecret, and url are defined as environment variables for the app router.

cf env myappodata-app

6:50 – Change URL to srv (instead of app)

7:00 – Use HTTP POST to insert data using JSON format specifying in the header

Content-Type = application/json/IEEE754Compatible=true

7:55 – Code walkthrough

Running travel_OData.sql script in SAP HANA database explorer

Running Yeoman generator in SAP Business Application Studio

Assigning role collection using SAP Cloud Platform cockpit.

 

Postman access token configuration

/wp-content/uploads/2016/02/sapnwabline_885687.png

Share and Connect 

Questions? Post as comment.

Useful? Give a like and share on social media. Thanks!

If you would like to receive updates, connect with me on

/wp-content/uploads/2016/02/sapnwabline_885687.png

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