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:
- Right click the Data Model folder, and click Create
. The Create Complex Type dialog box opens.
- Specify the Complex Type Name. The complex type will be displayed in the mass
maintenance view. Do the following in the mass maintenance view:
- 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.
- 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.
- 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.
- 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) and then click
(Insert Row)
- Click Save
Note To delete an existing complex type, select the relevant row in the
mass maintenance view and click

(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.