To implement the Define Entity Type code pattern and use the generated source code in the DEFINE method, proceed as follows:
Start ABAP Workbench in transaction SE80.
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.
Choose the Edit button. After you have switched to editing mode, the Pattern push button in the application tool bar is active.
Place your cursor at the position in the source code where you want to insert the generated code pattern for entity types.
Choose the Pattern push button. The Ins. statement dialog box is displayed.
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.
In the dialog box ODC Code Pattern Selection Screen, select the radio button Define Entity Type under Metadata Definition.
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.