Show TOC

Model Provider ClassLocate this document in the navigation structure

Introduction
The Service Builder provides you an option of generating the Model Provider Class(MPC). Generated MPC classes 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 you initiate the generation process, you must specify two names in the dialog box under Model Provider Class:
  • Class Name
  • Base Class Name
Model and Service Definition Dialog box

Fields

Description

Naming Sample

Class Name - Implementation Class This is the Implementation class that inherits Base class. This class can be modified manually. CL_<Project Name>_MPC_EXT. Project Name is the name of project in Service Builder
Base Class Name This is the Base class that is generated by system during generation process.
Note Do not modify this class manually
CL_<Project Name>_MPC. Project Name is the name of project in Service Builder.
Note The MPC names cannot be changed after the generation. During re-generation of the model in SEGW, Model and Service Definition dialog box displays again only if Generate Classes option is unselected in Data Provider Class region.
After generation, the Service Builder creates two types of Model Provider Classes: Base Class and 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 generated base class CL__Project Name_MPC 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 MPC, rather than changing the model in 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 MPC generation is given in Generated MPC Classes section below:
Structure
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 

         
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:

Generated MPC Classes
Additional Information

If the generated Model Provider Class has a syntax error try to rectify the error from 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 _EXT class 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.
Procedure
  1. Create a Project of type Service with Vocabulary-based Annotations.
  2. Import vocabularies.
  3. Click Generate Runtime Objects to generate the MPC class.
  4. Method DEFINE_VOCAB_ANNOTATIONS is created in the Model Provider Class to maintain the Vocabulary based Annotations.
    Note For Project Type Service with SAP Annotations the method DEFINE_VOCAB_ANNOTATIONS will not be created.
  5. Vocabulary references is 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 one of the following types: String, Boolean, Integer, Path, Property path, Navigation property path. Sample for simple value annotation:
      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 may contain one or more properties. A property may contain a 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' ).End of the code.