● Sample ATOM Output:
● Sample JSON Output:
$select
This property allows you to control which properties for each entity are returned in the entity set.
● URI Construct:
/<service>.xsodata/<Entity Set Name>/$select=<property>,<property>,<...>
● Sample URI:
http://hanaxs:8000/sample/hello/hello_odata.xsodata/Entries/?$select=TEXT
● Sample ATOM Output:
● Sample JSON Output:
8.1.4 OData Security Considerations
Enabling access to data by means of OData can create some security-related issues that you need to consider and address, for example, the data you want to expose, who can start the OData service, and so on.
If you want to use OData to expose data to users and clients in SAP HANA application services, you need to bear in mind the security considerations described in the following list:
● Data Access
Restrict user select authorization for tables/views exposed by the OData service
● OData Service
Restrict authorization rights to start the OData service
● OData Statistical content
Restrict access to the URL/Path used to expose OData content in the Web browser
8.1.5 Defining the Data an OData Service Exposes
An OData service exposes data stored in database tables or views as OData collections for analysis and display by client applications. However, first of all, you need to ensure that the tables and views to expose as an OData collection actually exist.
To define the data to expose using an OData service, you must perform at least the following tasks:
1. Create a database schema.
2. Create a simple database table to expose with an OData service.
3. Create a simple database view to expose with an OData service.
This step is optional; you can expose tables directly. In addition, you can create a repository view (for example, Analytic, Attribute, Calculation).
4. Grant select privileges to the tables and views to be exposed with the OData service.
8.1.6 Creating an OData Service Definition
The OData service definition is a configuration file you use to specify which data (for example, views or tables) is exposed as an OData collection for analysis and display by client applications.
An OData service for SAP HANA XS is defined in a text file with the file suffix .xsodata, for example,
OdataSrvDef.xsodata. The file resides in the package hierarchy of the OData application and must contain at least the entry service {}, which would generate an operational OData service with an empty service catalog and an empty metadata file.
Prerequisites for the creation of an OData service definition:
● SAP HANA studio/client installed and configured
● SAP HANA database user available with repository privileges (for example, to add packages)
● A SAP HANA development system added to (and available in) SAP HANA studio, for example, in either the Navigator view or the SAP HANA Repositories view
● A working development environment including a repository workspace, a package structure for your OData application, and a shared project to enable you to synchronize changes to the OData project files in the local file system with the repository
● Defined data to expose with the OData application, for example, at least the following:
○ A database schema
○ A database table
1. In the shared project you are using for your OData application, use the Project Explorer view to locate the package where you want to create the new OData service definition.
Note: The file containing the OData service definition must be placed in the root package of the OData application for which the service is intended.
2. Create the file that will contain your OData service definition.
In the Project Explorer view, right-click the folder where you want to create the new OData service-definition file and choose New File in the context-sensitive popup menu.
3. Define the OData service.
The OData service definition uses the OData Service Definition Language (OSDL), which includes a list of keywords that you specify in the OData service-definition file to enable important features.
The following example shows a simple OData service definition exposing a simple table:
service namespace "my.namespace" {
"sample.odata:table.hdbtable" as "MyTable";
}
This service definition exposes a table defined in the file sample.odata:table.hdbtable and creates an EntitySet for this entity named MyTable. The specification of an alias is optional. If omitted, the default name of the EntitySet is the name of the repository object file, in this example, table.
4. Place the valid OData service definition in the root package of the OData application to which it applies.
5. Save, commit, and activate the OData service definition in the SAP HANA repository.
Related Links
OData Service Definitions [page 165]
The OData service definition is the mechanism you use to define what data to expose with OData, how, and to whom. Data exposed as an OData collection is available for analysis and display by client applications, for example, a browser that uses functions provided by an OData client library running on the client system.
8.1.7 OData Service Definition Language Syntax
The OData Service Definition Language (OSDL) provides a set of keywords that enable you to set up an ODATA service definition file that specifies what data to expose, in what way, and to whom.
The following list shows the syntax of the OData Service Definition Language (OSDL) in an EBNF-like format;
conditions that apply for usage are listed after the table.