6
Hi, my name is Denys van Kempen, SAP HANA Academy.
You are watching a video tutorial that is part of a series about SAP Business Technology
Platform certifications, part of the playlist SAP Certified Development Associate - SAP
HANA Cloud
This tutorial covers the topic area Expose Data as OData Services
This video was recorded in September 2022.
For the latest tutorials on the topic, please check the playlist.
Like the previous topic area, Expose Data as OData Services and Create and Integrate
the UI has an 18% weight, about 14 questions
In this tutorial, we are only going to discuss OData, creating the UI will be covered in
the next video
OData, short for the open data protocol, is a standard for building and consuming, or
creating and using if you prefer, RESTful APIs,
another standard, which comes from a PhD dissertation in information and computer science
but we are not expected to have mastered the theory
just retain that OData enables us to interact with data over the internet, using HTTP
as apposed to using ODBC / JDBC in a client-server environment on-premises
If you are completely new to OData and REST,
there is a tutorial, understand OData in 6 steps, which overs the basic,
how to make an HTTP request, or perform the same action using code,
queries,
creating new resources.
Also recommended, a more complete coverage of the topic, still at the basic level
requesting data
querying data, explaining how we can filter the data returned
and how we can modify data
create an entiti
using a POST request, instead of get, with a body
and to make this a bit more tangible,
there is another tutorial
which uses the Postman client,
this starts with a simple GET request to the service root
we get some data back, typically in JSON format, JavaScript Object Notation
we get a response code 200 OK
there are different responses we can expect,
404 not found, might be familar=
we can read the service metadata,
here with a $metadata at the end of the URL
this returns a response in XML format
explaining what type of data the service provides,
metadata, data about the data
read an entity set
filter a collection, with a $filter in the URL
postman makes this easier to set query params
we can sort a collection,
with $orderby
client-side paging: $top=2 $skip=2
and so on
these are all GET requests, to read data already persisted
but we can also create new entities
with a POST request
and this requires a BODY
in JSON
we can delete data
or update with PATCH
a simple tutorial, to get familiar with working with Odata
of course, there is much more material freely available on the internet to learn about Odata
just search for odata on YouTube, for example
Odata for beginners
and here from SAP Developers
back to basics - Odata
a whole talk, of about an hour, on the topic
=
okay, hands-on, where were we?
here we have our sample application, using SAP HANA Cloud for persistence
we created a data model in the db folder.
interactions.cds,
with two entities, interactions header and items
we also created the service model, interactions_srv.cds,
referencing the data model
we then deployed the design-time artifacts to runtime database objects in an HDI container
using the database deployer,
you can review the steps in the previous video in this series
then we have to do a little bit of magic,
bind the cds server running on our development client,
SAP Business Application Studio to the HDI container,
using the shared key, which contains all the information needed
to connect to the database, including a certificate for authentication
you don’t need to memorise this, but the binding is saved to a hidden file .cdsrc-private
and cds then suggests to run the command cds watch profile hybrid
here we have the connect string displayed
cds is serving CatalogService path / catalog
and when we connect to the CDS server
View, Find Command, Ports preview
we see an automatically generated page,
hosted by the CDS server running locally in our Business Application Studio environment.
There is no UI yet.
Web Applications: none.
But we do have service endpoints, OData terminology.
The catalog, /catalog
with the available entries
this is in JSON, formatted here using a Chrome browser extension called JSON viewer
Raw it is a bit harder to read.
the metadata
in XML format
$metadata in the URL
Interactions Header in JSON
running a query against the SAP HANA Cloud database
Same for interactions
and that’s what we need to cover for OData.
To recap, you need to be familiar, to some extent, with the basics of OData.
For this, just go through the tutorials on the odata.org website.
Just the basics
and then using CDS, we create a file with cds extension, defining the service, with
the entities we want to expose, make avaiable.
You can find the links to the resources mentioned in the description of this video below.
This video tutorial was recorded by Denys van Kempen, SAP HANA Academy.
Any good?
Give us a like, and for updates, don’t forget to subscribe.
Thanks for watching.