May 19

OData Basics – Part 1 (Entity Data Model)

In this blog, I have covered basics part of OData creation of :

  • Project
  • 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:

2017-05-19 17_10_45-183.82.114.111_3333 - Remote Desktop Connection

Start creating the OData service:2017-05-19 17_11_13-183.82.114.111_3333 - Remote Desktop Connection

Populate Project, Description and continue

2017-05-19 17_12_03-183.82.114.111_3333 - Remote Desktop Connection

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.

2017-05-19 17_14_00-183.82.114.111_3333 - Remote Desktop Connection

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

2017-05-19 17_14_34-183.82.114.111_3333 - Remote Desktop Connection

Choose the fields you need..

2017-05-19 17_15_09-183.82.114.111_3333 - Remote Desktop Connection

Also, specify the key field

2017-05-19 17_15_53-183.82.114.111_3333 - Remote Desktop Connection

By this, Entity type and Entity Set got created..

2017-05-19 17_16_58-183.82.114.111_3333 - Remote Desktop Connection

Next step is to generate run time artifacts..Click generate button

2017-05-19 17_18_11-183.82.114.111_3333 - Remote Desktop Connection

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.

2017-05-19 17_18_47-183.82.114.111_3333 - Remote Desktop Connection

Generated classes can be seen in the run time artifacts section:

2017-05-19 17_19_38-183.82.114.111_3333 - Remote Desktop Connection

Next step is to register the service..

2017-05-19 17_20_24-183.82.114.111_3333 - Remote Desktop Connection

2017-05-19 17_21_14-183.82.114.111_3333 - Remote Desktop Connection

2017-05-19 17_21_52-183.82.114.111_3333 - Remote Desktop Connection

Registration status is green..

2017-05-19 17_22_30-183.82.114.111_3333 - Remote Desktop Connection

Activate and maintain the service, Click maintain button..

2017-05-19 17_22_57-183.82.114.111_3333 - Remote Desktop Connection

Click ‘Call Browser’ button to verify the details..

2017-05-19 17_23_49-183.82.114.111_3333 - Remote Desktop Connection2017-05-19 17_24_13-183.82.114.111_3333 - Remote Desktop Connection

XML format of the service..

2017-05-19 17_25_00-183.82.114.111_3333 - Remote Desktop Connection

To check the meta data, just change the URL as shown below:

2017-05-19 17_25_49-183.82.114.111_3333 - Remote Desktop Connection

We can also view the service definition in JSON format..

2017-05-19 17_36_15-183.82.114.111_3333 - Remote Desktop Connection