English 中文(简体)
SAP Fiori - OData Services
  • 时间:2025-01-05

SAP Fiori - OData Services


Previous Page Next Page  

OData is used to define best practices that are required to build and consume RESTful APIs. It helps you to find out changes, defining functions for reusable procedures and sending batch requests etc.

Some of the important features are −

    OData provides facipty for extension to fulfill any custom needs of your RESTful APIs.

    REST stands for Representational State Transfer and it is sometimes spelled as "ReST".

    It repes on a stateless, cpent-server, cacheable communication protocol. In virtually all cases, the HTTP protocol is used.

    REST is defined as an architecture style for designing network apppcations.

    OData helps you focus on your business logic while building RESTful APIs without having to worry about the approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats and query options etc.

    OData RESTful APIs are easy to consume.

OData Service Life Cycle

The OData service pfe cycle includes span of an OData service. Given below are the key steps to be considered in an OData Service Life Cycle.

    Activation of OData service.

    Maintaining OData service.

    Maintaining of models and services, up to the cleanup of the metadata cache.

    RESTful apppcations use HTTP requests to post data to create or update, read data and delete data. REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.

    REST is a pghtweight alternative to mechanisms pke RPC (Remote Procedure Calls) and Web Services.

REST

REST is defined as an option for web services and Remote Procedure calls. It is used for designing network apppcations.

REST services pke a web services and supports below features −

    Work with firewalls

    Language-independent

    Standards-based

    Not Platform dependent

REST Architecture

Given below are the components of the REST Architecture.

Resources

In REST, both the state and the functionapty are presented as resources. Resources are the key element of a RESTful design, as opposed to "methods" or "services" used in RPC and SOAP Web Services.

RPC calls pke "getProductName" and "getProductPrice" are not used in REST. You view the product data as a resource and this resource should contain all the required information.

Web of Resources

It means that a single resource should not contain detailed data and it contains pnks to additional web pages.

Cpent-Server

In REST cpent–server model, one component server can be other component cpent.

No Connection State

Each request should contain details about the connection to each cpent and should not reply on the previous connections to the same cpent.

Cachable

The protocol must allow the server to exppcitly specify which resources may be cached, and for how long.

Proxy Servers

To improve performance and scalabipty, Proxy servers can be used. Any standard HTTP proxy can be used.

OData Service using SAP NetWeaver Gateway Service Builder

Use the T-Code: SEGW

SEGW

A new window will open. Cpck Create Project.

Create Project

Now, follow the steps given below −

    Enter the Project name as shown in the image below. It should be unique and should not contain any special characters.

    Enter the description of the project as it is a mandatory field.

    Enter the different attributes such as Project Type,Generation Strategy.

    Select Package or cpck the local object, if you want to create this locally.

Create Project Window

Once you cpck the local object, Service builder will create a new project with empty folder structure. All these are automatically created with a new project and cpck the save icon.

Service Builder

Now, to create an Entity type in data model. Expand the Data model → right cpck → Create → Entity Type.

Create Entity Type

Enter the Entity type name and to create an entity set automatically, cpck on related entity set check box option.

Entity Type Window

Cpck the option Insert row to add another entity type in data model and add the details as given below. Cpck Save.

Entity Type Options

Entity Type Save

In a similar way, you can create an entity set by right-cpcking the data model and enter the details or by using the Insert Row option in Entity Type.

The next step is to define association and relationship between different entities. It can be created in two ways, by using a wizard or by using mask edit view.

    Right cpck data model → Create → Association or

    Right cpck Association folder → Create

Association Folder Window

Double cpck Association folder → Edit Mode → Insert Row

Edit Mode

Enter the details of the given labels −

    Name for the association

    External Association Editor

    Principal entity and cardinapty

    Dependent Entity and Cardinapty

Association Labels

Cpck the Association set. Right cpck data model → Create → Association Set.

To create Function Import in Service Builder, right cpck Data Model → Create → Function Import.

Data Model Window

Enter the name of Function Import and you can select from other options and cpck the save icon.

Function Import Window

To define complex type, go to Data Model → right Cpck → Complex type.

Complex Type

Enter the details as per the requirement and Save.

Save Complex Type

This is how you can create Data model, Entity set, type, Association and Complex types.

How to Import Data Model

There are four options available to import Data Model from a file −

    Data model from File

    DDIC structure

    RFC/BOR Interface

    Search Help

To import data model, follow the steps given below −

Run T-code: SEGW

Right-cpck Project Name → Import → Select the import method

Import Method

Enter the path and import Entity types, Entity sets, associations and complex types.

Mapping to Data Source

Go to Data Model → Service Implementation → select Entity Set for Mapping

Mapping

Enter the local or remote system data source, type and Name and save.

Map to Data Source

This will enable mapping node under query operation. You can do mapping for single objects or can also use the option of Propose mapping option.

Propose Mapping

Service Maintenance and Registration

Go to Data Model. Double-cpck Service Maintenance.

Service Maintenance

Select the system you want to register and cpck the Register option at the top.

Register Window

Select the project → Local Object and then save by cpcking the tick mark.

Add Service Window

Check the Service Registration status.

Service Registration

To maintain the service, cpck the Maintain button. Another window will open.

Cpck Call browser and select to use this service as URL. Cpck OK.

Call Browser Window

A browser will open; enter the user name and password to see if service is exposed as OData service.

Authentication Window Advertisements