Show TOC

Defining PropertiesLocate this document in the navigation structure

Use

In SAP Gateway Service Builder, you can define properties for entity types and complex types. Properties define the characteristics of the data that an entity type or complex type instance will contain at runtime. The properties of entity types and complex types are stored in a separate Properties sub-folder within the Entity Types and Complex Types folders in your Service Builder project.

Properties comprise the following:

  • Attributes

    • Name

    • Type (Core type (with facets such as Nullable, MaxLength, FixedLength, Precision, Scale) or complex type)

  • Annotations

    • SAP annotations (such as Creatable, Deletable, Label, UnitProperty)

    • Vocabulary-based annotations

  • ABAP type information

    • ABAP field name

    • ABAP type assignment

Procedure

To create a new property, proceed as follows:

  1. Expand the Data Model folder in the tree view of your project.

  2. Expand the Complex Types or Entity Types sub-folder (depending on the data object type for which you want to edit the properties), expand the entity type or complex type and double-click the Properties sub-folder.

  3. Click Display/Change in the mass maintenance view (to switch to edit mode) and then Insert Row to add a new row to the table for the new property.

  4. In the Name column, enter a name for the property. For example, enter NEW_PROPERTY. This is a mandatory input field. If you do not enter a name, an error message is displayed and you cannot save the changes to your project.

  5. Define the attributes of the new property:

    Note

    The columns in the Properties table differ depending on the project type selected. For example, if your project is of type Service with Vocabulary-Based Annotations, the standard SAP attributes (creatable, updatable, sortable, for instance) are not displayed as vocabulary-based annotations are to be used instead.

    Column

    Description

    Name

    Enter a new name for the new property or modify the existing name as required. If you have imported the complex type or entity type, a name is already displayed, for example, currency.

    Is Key

    Select to indicate that this is a key property in the data model.

    Edm Core Type

    Enter the Entity Data Model (EDM) type allowed in OData for this property. For example, Edm.String, Edm.DateTime.

    Type Kind

    Specify whether the property is a Complex Type or Core Type for projects of type Service with Vocabulary-Based Annotations and Annotation Model for Referenced Service.

    Data Type

    Enter the data type that corresponds to the complex or core type property. If it is a core type property, use the input help to select the appropriate Edm. type.

    Precision

    EDM facet. Enter the number of decimal places permitted for numeric data types. The value defines the maximum number of decimal places permitted to the left and right of the decimal point.

    Scale

    EDM facet. Enter the maximum number of decimal digits permitted after the decimal point.

    Max Length

    EDM facet. Enter the maximum length you want to allow at runtime. For example, enter 30 to specify a maximum length of 30 characters for this property.

    Fixed Length

    EDM facet. Select to specify if fixed length applies.

    Unit Property Name

    Enter the unit property name. Use the input help to select an existing property from the same complex type or entity type. For example, if the property comprises a number that refers to a currency or amount, you can specify the relevant currency or unit of measure.

    Creatable

    SAP annotation for projects of type Service with SAP Annotations. Select this option to allow a value assignment to this property in Create (POST) requests at runtime. If you have selected, you must include a Create operation in the data model.

    Updatable

    SAP annotation for projects of type Service with SAP Annotations. Select this option to allow a value assignment to this property in Change (PUT/MERGE) requests at runtime. If you have selected, you must include an Update operation in the data model.

    Sortable

    SAP annotation for projects of type Service with SAP Annotations. Select this option to allow this property to be used in $orderby statements for sorting data at runtime.

    Nullable

    EDM facet. Select this option to allow a null value to be entered for this property at runtime.

    Filterable

    Select this option to allow this property to be used in $filter statements for filtering data at runtime.

    Label

    SAP annotation. Enter a language-dependent label using the Label Text Reference Editor in the next column.

    Label Editor

    Use the Label Editor to specify the reference type (Data Element, Class, Program, Free Text). Depending on the reference type you select, the fields object name, key, and label that are relevant for the particular reference type are ready for input. Input help is available for these fields.

    Complex Type Name

    Enter the name of the complex type you have created in your project. You can use the input help to obtain an overview of complex types that exist in the current project.

    ABAP Field Name

    Internal name of the property. If you specified a structure binding for the parent entity or complex type, this denotes a component of this structure. Enter the ABAP field name. If you have imported the entity type, this field contains the ABAP field name in uppercase. You can use the ABAP Type Editor.

    ABAP Type Editor

    Use the ABAP Type Editor to specify how mapping from ABAP type to EDM type is to be determined (Structure Binding at Entity or Complex Type, Explicit Assignment, Determination by Runtime Object Generator) to be used for the ABAP field. For more information, see Mappings and the ABAP Type Editor.

    Semantics

    Enter how the property is to be used. For example, classifies a number as a telephone number or a fax number.

    Value Collection

    Indicates whether or not the imported vocabulary includes property for which a collection of values (multiple entries) exists. Applies to projects of type Service with Vocabulary-Based Annotations and Annotation Model for Referenced Service. This field is read-only in the properties view for the data model.

    Note

    Label and Label Text Reference Editor columns are available only in projects of type Service with SAP Annotations.

    To delete an existing property, select the relevant row in the mass maintenance view and click Delete Row. SAP annotations provide additional metadata for the data model, but they are not validated at runtime. As such, the metadata merely provides the user of the service with additional information. However, if you are developing a specific application, you could include validation checks in the relevant data provider classes. Since the validation checks require a specific use case, these must be tailored to suit the particular customer application.

    Note

    If an Entity/Complex type is created manually and a structure is assigned to it, you can import properties related to the structure into your project. For this, right click the entity/complex type created, click Import and then click Properties. You can select the required properties from the wizard.

As, it is possible to set an EDM type as well as an internal ABAP type for properties, these types must be validated to ensure that there is no mismatch between the values. Mismatches of this kind where one type is more restrictive than another, for example DateTime and Date, may lead to data loss. In case of non-compatibility between an EDM type and an ABAP type, an error message is displayed. For more information, see EDM Type Vs ABAP Type Validation.

More Information

For information about defining navigation properties for entity types, see Navigation Properties.