Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

[Update: April 5th, 2016 -  The Live3 on HCP tutorial series was created using the SAP HANA Cloud Platform free developer trial landscape in January 2015. The HCP landscape has significantly evolved over the past year. Therefore one may encounter many issues while following along with the series using the most recent version of the free developer trail edition of HCP.]


In the next installment of the Live3 on HCP course the SAP HANA Academy’s philip.mugglestone introduces OData and shows how to set up an OData service for the live3 web services project so you can access tables and views on the web. Check out Philip’s video below.

(0:12 – 1:05) Introduction to OData

OData is short for open database protocol. OData is rest services that allow you to access the data in databases via URLs. You can liken it to ODBC for the web. SAP HANA supports rest services through OData, so there is nothing to setup and install. Therefore you can simple activate OData against your tables and views. For more information about OData visit odata.org.

(1:05 – 6:30) Configuring and Examining the services.xsodata File

With the live3 project selected in the SAP HANA Web-based Development Workbench drag the services.xsodata file from the services folder in the Live3 Github code repository and drop it into the Multi-File Drop Zone.

The powerful code in the services.xsodata file will reference data from the application schema so you must run a global replace to insert your personal schema name. After clicking the save button you will have activated the OData service.

The code makes a reference in the service to the name of a table or view to access the data across the web. The code specifies the name of the table or view with the schema and gives a name for an entity because OData works with entities and properties as opposed to tables and columns. The first part of the code references the Tweets table and makes it so that the entity Tweets will be available through the OData format. The create, update and delete functions will be forbidden as we only want to read the data on the web.

A similar process is done for the Tweeters view. However, its slightly different as OData requires a key and views don’t have primary keys. So you must specify the name of the column, in this case user, which will then be the primary key.

The next section of code is for the TweetersClustered data and has a key of user. This piece of code is slightly different than the prior two sections of code as we want to make a navigation to associate it with another table. This is similar to a SQL join.

The 4th part of the code setups the OData service for the Clusters view with ClusterNumber as the primary key and a navigation to setup a association.

(6:30 – 9:00) How Associations Work

The final two sections of the code are association statements that setup the associations’ definitions between pairs of entities. In the first statement the principle is the Clusters entity with ClusterNumber as the key. For each ClusterNumber there may be multiple people in that cluster. So the dependent entity is the TweetersClustered entity with ClusterNumber as the key and a multiplicity of many (*). This is effectively equivalent to an inner join where data is read from the Clusters table and joined with the data read from the TwettersClustered table in order to get all of the Tweeters.

Names are given in order to reference the associations. For example in the Clusters2Tweeters association a property is inside the association that contains the name for each individual Tweeter. This same one to many type of relationship is created for all of the Tweeters that have been clustered so we can see their individual tweets. So the Tweeters2Tweets association will be referred to as Tweets.

Hitting the execute button with services.xsodata selected will setup a working OData service. It will generate the XML file pictured below on the web.

Follow along with the Live3 on HCP course here.


SAP HANA Academy over 900 free tutorial videos on using SAP HANA and SAP HANA Cloud Platform.


Follow @saphanaacademy

1 Comment
Labels in this area