Show TOC

Generated Classes for Model Provider ClassLocate this document in the navigation structure


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:

Figure 1: Model and Service Definition window
  • Class Name

  • Base Class Name



Naming Sample

Class Name — Extension 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

CL_<Project Name>_MPC

Project Name is the actual name of project in the Service Builder.


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.

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

Implementation Class

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 SAP Gateway Service Builder. See Extension Class: Model Provider Class.

Sample Model-Service Builder

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:

        DATA MODEL
              COMPLEX TYPES 
              ENTITY TYPES
                                   NAVIGATION PROPERTIES    
                                   NAVIGATION PROPERTIES    
                                  REFERENTIAL CONSTRAINTS
              ENTITY SETS
              ASSOCIATION SETS
              FUNCTION IMPORTS

Generated MPC Classes

For given sample model definition above, on generation of runtime artifacts (MPC Classes), the base class and the implementation class will look as below:

Figure 2: Representation of Base Class and Implementation Class

Additional Information

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.


MPC Generation Using Inline Annotations

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.


The Project Type should be Service with Vocabulary-Based Annotations.

Execute the steps provided in this section in-addition to the steps executed above.

  1. Create a Project with Type Service with Vocabulary-based Annotations.

  2. Import vocabularies as detailed in the Importing a Vocabulary File section.

  3. Click Generate Runtime Objects button to generate the MPC class.

  4. Method DEFINE_VOCAB_ANNOTATIONS will be created in the Model Provider Class to maintain the Vocabulary based Annotations.


    For Project Type Service with SAP Annotations the method DEFINE_VOCAB_ANNOTATIONS will not be created.

  5. Vocabulary references will be created Inside the method DEFINE_VOCAB_ANNOTATIONS.

    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:

    1. 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:

      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 ). 
    2. Annotation with collection:

      Collection may contain more than one record or simple value.

      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' ). 
    3. Annotation with Record:

      Record will contain one or more properties. A property may contain another collection or a simple value.

      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' ).