OData(Open Data Protocol)
Description:Open Data Protocol (OData) is a standardizedprotocol designed for exposing and accessing
information from multiple sources. It is built on foundational protocols such as HTTP, AtomPub (Atom
Publishing Protocol), XML, and JSON (JavaScript Object Notation). OData offers a uniform API for
presenting service data and metadata, as well as for performing data operations.
● It facilitates the development and consumption of interoperable and scalable APIs for accessing
h
and manipulating data. In the context of SAP ABAP, OData is utilized to expose SAP data and
services as RESTful APIs, enabling external systems to access and manage SAP data through HTTP
protocols.
ng
● Important T-codes for Odata services:
SEGW: Create OData service.
/IWFND/MAINT_SERVICE: Register and Activate the Odata Service
Si
/IWFND/ERROR_LOG: Check errors in Odata
/IWFND/GW_CLIENT: Test Service
ta
Entity vs Entity Set
ee
Entity Entity Set
ng
E ntities are specific instances of entity types (e.g., E ntity sets are named collections of entities (for
Customer, Employee, etc.). example, "Customers" is an entity set that
contains Customer entities).
Entity types are structured types defined by a key.
An entity can belong to only one entity set at a
Sa
Each entity includes named properties and may time.
also have relationships with other entities.
Entity sets serve as the main entry points into the
E ntity types support single inheritance from
ata model.
d
other entity types.
E ntities serve as the fundamental identity types
within a data model.
What are the different types of CRUD operations supported by OData?
OData supports four primary types of CRUD operations:
❖ C reate (C): This operation allows new data entities to be created by sending a POST request to
the URL of the entity set.
❖ Read (R): This enables the retrieval of data entities by sending a GET request to the URL of the
h
entity or entity set.
❖ Update (U): This supports modifying existing data entities through PUT or PATCH requests sent to
the entity URL.
❖ Delete (D): This operation allows for the removal of existing data entities by sending a DELETE
ng
request to the entity URL.
Si
DPC vs MPC data class
MPC (Model Provider Class) DPC(Data Provider Class)
ta
T his is used to define the model. You can utilize It is used to implement your CRUD methods and
the Define method to create entities, properties, function import methods. You write all your logic
and more through code-based implementation. in the redefined methods of the DPC extension
ee
The MPC extension class is rarely used in this class.
context.
T he Model Provider class registers the metadata T he Data Provider class offers methods to the
utilized in a service, it serves as the base class, Data Provider Extension class, allowing
ng
while the Model Provider extension class developers to implement functionalities for
functions as the derived class. interacting with the database.
Sa
Sa
ng
ee
ta
Si
ng
h
Sa
ng
ee
ta
Si
ng
h
When we regenerate OData, which classes are overwritten?
If you add a new property to the Entity and regenerate the runtime object, the MPC and DPC classes will
be overwritten by SAP, resulting in the loss of your custom code. The MPC and DPC classes will be
regenerated, but the MPC_EXT and DPC_EXT classes will remain intact. Any custom code you’ve
implemented within those extension classes will not be erased.
h
Steps to create OData service
1. Create a project in T-Code SEGW.
ng
Si
ta
. C
2 reate Entity Types and Entity Sets.
3. Generate runtime artifacts.
ee
ng
Sa
4. R
egister and Activate the Odata Service.
T-Code: /IWFND/MAINT_SERVICE
h
ng
5. T est Service
Si
Select the registered service and Click on SAP Gateway Client
ta
ee
A new screen will appear; execute the transaction and review the response.
ng
Sa
arious query options possible in OData service URI like $select, $count, $expand,
V
$format,$links, $value etc.
Odata service output can be displayed in XML or JSON format.
Advantages of Odata service
Some advantages of using OData in SAP ABAP development include:
★ S tandardized Protocol: OData adheres to REST principles, offering a consistent method for
exposing and consuming data.
★ Flexible Data Access: OData facilitates both read and write operations on SAP data, providing a
versatile and powerful approach to data access.
★ Ease of Integration: OData simplifies the integration process with external systems and
h
applications, allowing for seamless data exchange.
★ Client Compatibility: OData is compatible with various client platforms, including web browsers,
mobile devices, and desktop applications.
ng
★ Security and Authentication: OData includes built-in security features, such as mechanisms for
authentication and authorization.
Si
Conclusion:In summary, OData services provide a standardized framework for accessing and managing
ata through RESTful APIs. They enhance interoperability and scalability, support rich querying and
d
flexible operations, and are compatible with various client platforms. With built-in security features,
OData enables safe and efficient data workflows, making it a valuable asset for developers and
ta
organizations seeking to optimize their data integration and application development.
ee
ng
Sa