OData Basics – Part 1 (Entity Data Model)
In this blog, I have covered basics part of OData creation of :
- Entity type
- Entity set
- Generating run time artifacts
- Registering the service &
- Checking the metadata.
Refer to following link to understand above terminology, OData Entity Data Model
In Simple language..
- Entity type – collection of different attributes of business object
- Entity Set – Collection of entity types
- In a data model, more than one entity type can be defined and the relationship between two entity types is called their association .
Start with transaction SEGW:
Start creating the OData service:
Populate Project, Description and continue
Now the next step is to create Entity type..
An entity type can be created in many way as shown in below screenshot. Now, lets choose the option “DDIC structure”.
Right Click on Data Model and Import->DDIC Structure.
In the next popup, just populate entity type name and choose the DDIC structure. IF we check “Create Default Entity Set” – Entity set is automatically created
Choose the fields you need..
Also, specify the key field
By this, Entity type and Entity Set got created..
Next step is to generate run time artifacts..Click generate button
Click the following link to read about Generated ABAP Classes and Service Registration
In short, Model Provider Class is used to dynamically handle the model definitions and Data Provider Class is used to handle CRUDQ operations..
The base classes contain the Service Builder generated logic. The logic in the base class is overwritten every time the project is regenerated.
The extension class names have the suffix, EXT. An extension class is a subclass of the base class that is created once, only when the project is generated for the first time. An extension class contains no logic. Service Builder provides the extension class for you to write own code. Regenerating the project does not overwrite your code in the extension class. You provide own logic (typically for the DPC) by redefining the method you wish to modify.
Generated classes can be seen in the run time artifacts section:
Next step is to register the service..
Registration status is green..
Activate and maintain the service, Click maintain button..
Click ‘Call Browser’ button to verify the details..
XML format of the service..
To check the meta data, just change the URL as shown below:
We can also view the service definition in JSON format..