How to create an OData Service in SAP

  1. The OData service is developed on a new project in the SAP system. Therefore start with the Transaction SEGW.
  2. Click New in the toolbar.
  3. Please enter a new project name and a short description on the popup fenster. Define also a package and finally confirm the entries through tick mark.
  4. A new project is now created. There are four folders under the new project. Right click on the folder ‘DATA MODEL’ and choose import from DDIC structure. The already available ABAP Dictionary structure can be imported directly and it is not necessary to manually assign an OData-service to each field. In addition to the ABAP structures, you can also import Type definitions from BAPI-Function module parameters or search help.
  5. In the popup fenster, provide the entity type and also provide the structure SFLIGHT in the respective fields. Ensure that the option Create default entity set is selected. Finally click the ‘Next’.
  6. In the next window, you will see all the fields of the table SFLIGHT. Now click all the fields of the structure, except the field MANDT. Click ‘Next’.
  7. In the next window, you will see all the fields with their respective Datatype. The primary keys of this structure must be confirmed through the checkbox column ‘IS KEY’. So please select the checkbox for the respective primary key fields of the structure. In this case, let us choose the CARRID, CONNID, FLDATE as our primary keys. Once you are done with the selection, please confirm the entries by selecting the ‘FINISH’ Button.
  8. As you can see, the Data model consists of the Entity types and Entity sets. The Entity Type Flights contains the properties folder. The properties folder contains all the fields of the structure. It displays the Edm core type and Label which describes the fields. The entityset ‘Flightsset’ is created as we checked this option ‘Create Default Entity Set’.
  9. The CRUDQ Methods of the Entityset is available in the folder service implementation.

How to construct an OData service in SAP ABAP

ODATA SERVICE CONSTRUCTION

Entity container: It contains all the entity sets.

Entity set: It represents a table. It is based on the entity type.

Entity type: All the fields(properties) and the primary keys are mentioned.

Property: It represents the fields along with data type.

Entity: It describes a line of record in the data table.

Association: It connects the primary and foreign key fields. It represents the cardinality of the relationship (1:1, 1: n).

Navigation: The two different entity sets can be related and represented through the navigation.