Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

The conclude words:

The following are the processes for adding a new entity to extend the OData service:

  1. In your target service, CRM_ODATA , create and add the new entity--CustomizingPriority, and then it will generate a relative entity set, we name it --CustomizingPriorityCollection.

    TCODE: SEGW

2.Configure the ABAP Structure Type Name for entity--CustomizingPriority.


3.Configure the properties for entity--CustomizingPriority.

4.Click [Check] button for messages in case of any wrong in above steps.

5.Click [Generate Runtime Object] button , this is to refresh the metadata. After this, MPC should be ready, please check.


Do 2 checks here:

(1)  Test metadata in SAP GateWay Client.

      Aim:Check entity--CustomizingPriority and it's properties in metadata is ok, see below picture.

      URI: /sap/opu/odata/sap/CRM_ODATA/$metadata



(2) Check model in CL_xxx_MPC.

Aim:Check entity--CustomizingPriority and it's properties in Model Provider Class(CL_xxx_MPC) is ok, see below picture.



6. Create class CL_CRM_ODATA_RT_CUSTPRIORITY (Runtime Class for Customizing Priority) for implementation this entity.

7. Then we should focus on how to implement this entity by coding.

7.1 Class:CL_CRM_ODATA_DPC_EXT

      Method:CONSTRUCTOR

      Coding:

"Customizing Priority. Name the class name and entity name in Data Provider Class.

     READ TABLE gt_data_provider WITH KEY entity_name = cl_crm_bp_odata_model_gen=>GC_ENTITY_NAME_CUST_TASK_PRIO ASSIGNING <ls_data_provider>.

     IF sy-subrc = 0.

       <ls_data_provider>-class_name  = 'CL_CRM_ODATA_RT_CUSTPRIORITY'. "#EC NOTEXT

       <ls_data_provider>-entity_name = 'CustomizingPriority'"#EC NOTEXT

     ENDIF.

7.2

      Class:CL_CRM_ODATA_RT_CUSTRPRIORITY

      Method:CONSTRUCTOR

      Coding:

    super->constructor( ).

* Tasks

     IF gr_task_rt  IS NOT BOUND.

       CREATE OBJECT gr_task_rt.

     ENDIF.


7.3

      Class:CL_CRM_ODATA_RT_CUSTPRIORITY

      Method:/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET

      Coding:

DATA: custpriority_get_entityset TYPE cl_crm_odata_mpc=>tt_customizingpriority.

     " EntitySet -CustomizingPriorityCollection

     IF iv_entity_set_name = gc_cust_priority_collection.

*     Call the entity set generated method

       custpriority_get_entityset(

         EXPORTING

          iv_entity_name = iv_entity_name

          iv_entity_set_name = iv_entity_set_name

          iv_source_name = iv_source_name

          it_filter_select_options = it_filter_select_options

          it_order = it_order

          is_paging = is_paging

          it_navigation_path = it_navigation_path

          it_key_tab = it_key_tab

          iv_filter_string = iv_filter_string

          iv_search_string = iv_search_string

          io_tech_request_context = io_tech_request_context

        IMPORTING

          et_entityset = custpriority_get_entityset

          es_response_context = es_response_context

        ).

*     Send specific entity data to the caller interface

       copy_data_to_ref(

         EXPORTING

           is_data = custpriority_get_entityset

         CHANGING

           cr_data = er_entityset

       ).

     ENDIF.


7.4

      Class:CL_CRM_ODATA_RT_CUSTPRIORITY

      Method: CUSTPRIORITY_GET_ENTITYSET

      Coding:

CALL METHOD gr_task_rt->get_user_priorities

       IMPORTING

         et_entityset = et_entityset.


Up to now, the development is done, below is the test result.


8. Test in SAP Gateway Client

URI: /sap/opu/odata/sap/CRM_ODATA/CustomizingPriorityCollection

Result: http 200.


1 Comment