Show TOC

Entity TypesLocate this document in the navigation structure

NoteThe following image contains links to more information.
In SAP Gateway Service Builder, you can define a new data model within your project to suit your exact service requirements based on the data you want to expose at runtime. Entity Types Entity Sets Associations Association Sets Function Imports Complex Types
Use entity types in your Service Builder project to describe the structure of data in the Entity Data Model (EDM). Entity types represent a specific type of data, for example an item or a concept. Entity Types comprise:
  • A unique name
  • A key, which can be defined by one or more properties (Is Key)
  • Properties (optional)
  • Navigational properties (optional to navigate between associations)
The entity type properties must adhere to the data types allowed and provided by the OData protocol or be of a complex type. An entity type must have a unique identifier that allows the entities belonging to this entity type to be used within an OData context. You can group entity types together in entity sets.
Procedure
To create an entity type in your Service Builder project, proceed as follows:
  1. Right click the Data Model folder, and select Create and then select Entity Type. The Create Entity Type dialog opens.
  2. Specify the following:
    • Entity Type Name: Specify a name for the Entity Type Name. The name for entity type and entity sets is unique. An error displays if a character in the specified name is not allowed.
    • Create Related Entity Set: Select the Create Related Entity Set and the entity set name is added. Click OK, a new entity type and its entity set are created. In the mass edit view, the entity set table displays the entries for the new data model elements, the entity set and the entity type.
Alternatively, use the following steps:
  1. Expand the Data Model folder in the tree view of your project, and double-click Entity Types to open the mass maintenance view.
  2. Click Edit and then Insert Row to add a new row to the table for the new entity type.
  3. In the Name column, enter a unique name for the entity type. You must enter a name in this column. For example, enter NEW_ENTITY_TYPE.
  4. In the ABAP Structure Type Name column, you can enter the appropriate ABAP structure directly, or use the input help to search for an existing structure in the repository.
  5. In the Base Type column, you can enter the relevant base type name directly or use the input help to display a list of existing node names and their descriptions. Base types (parents) inherit their properties to derived type (children). Inheritance between base types and derived types enables you to reuse existing entity types.
  6. In the Is Abstract column, select the checkbox if you want to define the entity type as an abstract type.
  7. In the Label column, enter a label for the new entity type. You can enter a free-text label directly or use the Label Text Reference Editor to enter the reference type, for example, program, data element, class or program. The reference type you select influences which of the other input fields (that is, Object Name, Key,, and Label you can, and need to, edit).
  8. You can define the following optional attributes for the entity type:

    Column

    Description

    Semantics

    Specifies how the entity type is to be used. For example, classifies a number as a telephone number or a fax number.

    Thing Type

    Select this checkbox if the entity type is a thing as opposed to a subordinate object. For example, a thing type is a tangible object such as a purchase order and a subordinate object is a purchase order item.

    Media

    Select this checkbox if the entity type belongs to a media collection and has a media source stream. This means every instance of this entity type points to an additional resource with some arbitary (MIME) type, for example, a photo with type image or jpeg.

    As Author Property

    OData feed customizing setting. Enter a property to be used for populating the atom:author element at runtime. Use the input help to select an existing property from the same entity type.

    As ETag Property

    OData feed customizing setting. Enter a property to be used as an ETag to support OData optimistic currency control for modifying requests. Use the input help to select an existing property from the same entity type.

    As Published Property

    OData feed customizing setting. Enter a property to be used for populating the atom:published element at runtime. Use the input help to select an existing property from the same entity type.

    As Title Property

    OData feed customizing setting. Enter a property to be used for populating the atom:title element at runtime. Use the input help to select an existing property from the same entity type.

    As Updated Property

    OData feed customizing setting. Enter a property to be used for populating the atom:updated element at runtime. Use the input help to select an existing property from the same entity type.

  9. Click Save to create the new entity type.
    Note To delete an existing entity type, select the relevant row in the mass maintenance view and click Delete Row.
Creating Entity Type Properties and Navigation Properties
After you have created and saved your entity types in the Entity Types subfolder, you can define the properties for each of these entity types. You can also define navigation properties that are required to create a link from one entity type to another using an association. For more information about how to define properties in the Service Builder see Defining Properties and how to define navigation properties, see Navigation Properties. .