Show TOC

Defining AssociationLocate this document in the navigation structure

Use

An Association is a named relationship between two or more Entities. Association defines a peer-to-peer relationship between participating Entity Types and can support different multiplicities at both the ends. An example of an association is the relationship between the Customer and Order entities.

Procedure

To create Association proceed as follows:

  1. Start ABAP Workbench in transaction SE80.

  2. Navigate to your model provider class and open the DEFINE method

    in which you want to insert the source code generated by the code pattern.

  3. Choose the Edit button. After you have switched to editing mode, the Pattern push button in the application tool bar is active.

  4. Place your cursor at the position in the source code where you want to insert the generated code pattern for entity types.

  5. Choose the Pattern push button. The Ins. statement dialog box is displayed.

  6. Choose the Other Pattern radio button and enter the technical name of the OData Channel pattern in the corresponding input field /IWBEP/FM_MGW_PAT.

  7. Choose continue

  8. In the ODC Code Pattern Selection Screen dialog box , select the Define Association radio button under Metadata Definition.

  9. Choose Continue to open the Define Association window.

  10. Do the following in the Define Association window:

    Fields

    Description

    Association Name

    Enter a association name for the Association in the Association Name Field

    Principle

    Navigation Property and Referential Constraint should have a From Role and To Role defined. The From Role refers to the Principal entity.

    See Referential Constraints and Navigation Properties for more details.

     

    Entity

    Enter the name of the Principal Entity for which the association has to be created (Mandatory field)

    Property

    Enter the Navigation Property of the Principal Entity (Optional field, but becomes mandatory when the Dependent Property is specified). The Property refers to the declared properties of an Entity Type or Complex Type. Property can be an EDM Simple Type or Complex Type. A declared property description consists of its name, type and a set of facets, such as Nullable or Default.

    Cardinality

    Select a cardinality for the Principal Entity from the drop-down list (Mandatory field). Cardinality is the measure of the number of Entity instances occurring in a relationship.

    Example

    An example of an association is the relationship between the Customer and Order entities. Typically, this relationship has the following characteristics: Multiplicity: each Order is associated with exactly one Customer. Every Customer has zero or more Orders. Hence the result would be 0:n.

    Dependent

    Navigation Property and Referential Constraint should have a From Role and To Role defined. The To Role refers to the Dependent entity.

     

    Entity

    Enter the name of the Dependent Entity for which the association has to be created (Mandatory field)

    Property

    Enter the Navigation Property of the Dependent Entity (Optional field, but becomes mandatory when the Principal Property is specified)

    Cardinality

    Select a cardinality of the Dependent Entity from the drop-down list (Mandatory field)

    Note

    To create Referential Constraint, both the Principle and Dependent Property fields are mandatory.

  11. Click continue to generate the code.

  12. The code will now be generated in the ABAP editor.

More Information

Refer Defining Complex Type, Defining Entity Type and Defining Composition for more options in Metadata Definition Code Patterns.