Show TOC

Complex TypesLocate this document in the navigation structure

Use complex types to define structured properties for entity types or other complex types without exposing complex types themselves as an independent OData entity. Because complex types consist of a collection of properties without a unique key, they can only exist as properties of a containing entity or, outside an entity, as a temporary value. Unlike entity types, complex types cannot form either end of an association between data objects, and therefore you cannot define navigation properties for complex types. However, complex types can contain other complex types, meaning that they can have a deep structure. Within a complex type the cardinality is always 1:1.
Complex types comprise:
  • A unique name
  • Properties (optional)
Example A complex type structure called Fullname could comprise two properties, firstname and lastname.
Procedure
To create a complex type in your Service Builder project, proceed as follows:
  1. Right click the Data Model folder, and click Create Start of the navigation path Complex Types End of the navigation path. The Create Complex Type dialog box opens.
  2. Specify the Complex Type Name. The complex type will be displayed in the mass maintenance view. Do the following in the mass maintenance view:
    1. In the ABAP Structure Name column, you can enter the appropriate ABAP structure directly, or use the input help to search for an existing structure in the repository.
    2. In the Base Type Name column, you can enter the relevant base type name directly or use the input help to display a list of node names and their descriptions. Base types (parents) inherit their properties to derived types (children). Inheritance between base types and derived types enables you to reuse existing complex types.
    3. In the Is Abstract column, select the checkbox if the new complex type is of type abstract as opposed to concrete. As default, this checkbox is not selected. If you set the type as abstract, your service implementation has to use a concrete derived type at runtime.
    4. In the Label column, you can enter a label for the new complex 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.
    Alternatively, in the mass maintenance view of Complex Types, click Display<-> Change (Display<-> Change) and then click Insert Row (Insert Row)
  3. Click Save
Note To delete an existing complex type, select the relevant row in the mass maintenance view and click Delete Row (Delete Row).
Creating Complex Type Properties
After you have created and saved your complex types in the Complex Types subfolder, you can define the properties for each of these complex types.