Show TOC

Defining Entity TypeLocate this document in the navigation structure

Procedure

To implement the Define Entity Type code pattern and use the generated source code in the DEFINE method, 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. Select the Other Pattern radio button and enter the technical name of the OData Channel pattern in the corresponding input field /IWBEP/FM_MGW_PAT. Input help is available for this field.

  7. Choose Continue.

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

  9. Choose Continue.

After you have selected the Define Entity Type code pattern and specified where you want to insert the generated source code in the DEFINE method of your model provider class, you need to configure the code pattern in the Local Entity Type Pattern dialog box. To configure the code pattern, proceed as follows:

  1. Enter in the ABAP Structure field an ABAP data structure from the ABAP Dictionary or from a global class or global interface, for example SFLIGHT. When you enter an ABAP structure, you must adhere to the ABAP syntax, for example, ZIF_INTERFACE=>TY_TYPE. An input help is available for this field so you can choose to search for views, database tables or structures.

  2. A proposal for the object name you are creating is displayed automatically in the Object Name field. The proposed name is derived from the ABAP structure and you can change the object name to suit your requirements.

  3. Choose Continue. A list of all fields in the ABAP structure you entered is displayed in the table view. If the ABAP structure you entered includes nested structures and includes these are also displayed.



    Figure 1: Define Local Entity Type Pattern screen
  4. Define the usage type of the fields in the ABAP structure by using the drop-down lists in the Usage column. Possible usages of the fields are Key, Property, and Ignore. At least one field must be defined as being a Key field in the Usage column. Fields of usage type Key are displayed at the top of the table. If you define usage type Ignore for structure, all subordinate fields are set automatically to ignore as well.

    Note

    The field types table, data, object, or interface references are not currently supported. These field types are displayed in the table, but they are ignored for code generation. This is indicated by the usage type Ignore in the Usage column.



    Figure 2: Fields with usage type Ignore on the Local Entity Pattern screen
  5. In the case of substructures, the code pattern proposes complex types for generation. You can select the Exists check box to specify if you want the statements for the complex types to be generated by the code pattern or if the name refers to a type that is already defined in the data model and does not therefore need to be generated.

  6. Check the names in the EDM Property Name and Complex Type Name columns and make any changes as required. A message is displayed if the names specified are not unique.

  7. Choose the Check button to check the validity of the entries in the table. If errors have occurred, double-click the appropriate error message to navigate to the line in the table that you need to correct.

  8. After checking the validity of the entries and correcting any errors, choose Continue to generate the source code. The source code is inserted into your DEFINE method.

More Information

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