
The Service Builder provides the user with the option of generating the Model Provider Class and Data Provider Classes. The MPC class generated also supports inline annotations if annotations are maintained in the model. This document provides details for generating MPC for two Project Types:
Service with SAP Annotations
Service with Vocabulary-Based Annotations
For Model Provider Class, when the user initiates the generation process, two names should be specified in the dialog box under Model Provider Class:

Model and Service Definition window
Class Name
Base Class Name
Fields | Description | Naming Sample |
|---|---|---|
Class Name — Implementation Class | This is the Implementation class that inherits the Base class. This class can be modified manually. | CL_<Project Name>_MPC_EXT Project Name is the actual name of project in the Service Builder. |
Base Class Name | This is the Base class that is generated by the system during the generation process.
Do not modify this class manually End of the note. | CL_<Project Name>_MPC Project Name is the actual name of project in the Service Builder. |
Note
The MPC names cannot be changed after the generation.
During re-generation of the model in SEGW, the Model and Service Definition dialog box will be displayed again only if the Generate Classes option is unselected in the Data Provider Class region.
After generation, the Service Builder creates two types of Model Provider Classes, the Base Class and an Extension Class.
The generated Base class always inherits its code from /IWBEP/CL_MGW_PUSH_ABS_MODEL which in turn inherits from /IWBEP/CL_MGW_ABS_MODEL. The base class CL__Project Name_MPC that gets generated will have redefinition for DEFINE() and GET_LAST_MODIFIED() methods. See Base Class: Model Provider Class for more information.
The Service Builder creates an extension class CL_<Project Name>_MPC_EXT for the MPC, which is the implementation class. The extension class is inherited from the MPC base class. This class can be used to perform any manual changes required to the MPC, rather than changing the model in the Gateway Service Builder. See Extension Class: Model Provider Class.
This is a sample model definition as seen in the Service Builder for project PROJECT_DEMO. A representation of the generated base and implementation classes after the MPC generation is given in the Generated MPC Classes section below:
Syntax
PROJECT NAME: PROJECT_DEMO
DATA MODEL
COMPLEX TYPES
complex_type_1
complex_type_2
ENTITY TYPES
entity_type_1
PROPERTIES
key_1
key_2
property_1
property_2
NAVIGATION PROPERTIES
nav_property_1
entity_type_2
PROPERTIES
key_3
property_3
property_4
NAVIGATION PROPERTIES
ASSOCIATIONS
association_1
REFERENTIAL CONSTRAINTS
referential_constraint_1
ENTITY SETS
entity_set_1
entity_set_2
ASSOCIATION SETS
association_set_1
FUNCTION IMPORTS
function_import_1
For given sample model definition above, on generation of runtime artifacts (MPC Classes), the base class and the implementation class will look as below:

Representation of Base Class and Implementation Class
If the generated Model Provider Class has a syntax error try to rectify the error from the Service Builder. The error information can be obtained when the MPC class is opened in SE24. Once the error is rectified delete the generated Model Provider Class before regeneration.
Annotation maintenance is not supported in the Service Builder’s mass maintenance view and you have to manually write the code in the _EXT class. However, the Service Builder assists you to generate most of required code, which can be copied to the _EXTclass as required.
Note
The Project Type should be Service with Vocabulary-Based Annotations.
Execute the steps provided in this section in-addition to the steps executed above.
Create a Project with Type Service with Vocabulary-based Annotations.
Import vocabularies as detailed in the Importing a Vocabulary File section.
Click Generate Runtime Objects button to generate the MPC class.
Method DEFINE_VOCAB_ANNOTATIONS will be created in the Model Provider Class to maintain the Vocabulary based Annotations.
Note
For Project Types other than Service with vocabulary-based Annotations the method DEFINE_VOCAB_ANNOTATIONS will not be created.
Vocabulary references will be created Inside the method DEFINE_VOCAB_ANNOTATIONS.
Syntax
lo_reference = vocab_anno_model->create_vocabulary_reference(
iv_vocab_id = 'ZCAPABILITIES'
iv_vocab_version = '0001').
lo_reference->create_include( iv_namespace = 'Org.OData.Capabilities.V1'
iv_alias = 'UI' ).Annotations may be of different types:
Simple value can be of type of one of the following String, Boolean, Integer, Path, Property path, Navigation property path.
For simple value annotation, the code will look like:
Syntax
lo_ann_target = vocab_anno_model->create_annotations_target( 'EPMDemo.PurchaseOrderItem' ). lo_annotation = lo_ann_target->create_annotation( iv_term = 'Core.Updateble' ). lo_simp_value = lo_annotation->create_simple_value( ). lo_simp_value->set_boolean( abap_true ).
Annotation with collection:
Collection may contain more than one record or simple value.
Syntax
lo_ann_target = vocab_anno_model->create_annotations_target( 'EPMDemo.PurchaseOrder/GrossAmount' ).
lo_annotation = lo_ann_target->create_annotation( iv_term = 'Core.AcceptableMediaTypes'
iv_qualifier = 'iPad' ).
lo_collection = lo_annotation->create_collection( ).
lo_simp_value = lo_collection->create_simple_value( ).
lo_simp_value->set_string( 'image/jpeg' ).
lo_simp_value = lo_collection->create_simple_value( ).
lo_simp_value->set_string( 'image/gif' ).Annotation with Record:
Record will contain one or more properties. A property may contain another collection or a simple value.
Syntax
lo_annotation = lo_ann_target->create_annotation( iv_term = 'UI.HeaderInfo'
iv_qualifier = 'iPad' ).
lo_record = lo_annotation->create_record( iv_record_type = 'Some_Type' ).
lo_property = lo_record->create_property( 'ValueID' ).
lo_collection = lo_property->create_collection( ).
lo_simp_value = lo_collection->create_simple_value( ).
lo_simp_value->set_string( 'Inside a collection in a record' ).