SAP for Utilities Blogs
Discover insights and practical tips to optimize operations, reduce costs, and deliver reliable energy with SAP technology. Contribute your own blog post!
Showing results for 
Search instead for 
Did you mean: 

The OData Service model delivered in SAP Multichannel Foundation for Utilities and Public Sector is built via the SAP Gateway Service Builder (SEGW) tool. Depending on the business needs, the SAP Gateway service model can be extended on different levels:

     1. OData entity structure extension (adding append structure with custom fields) Extending the Interface of an OData Entity Using Custom Fields

      2.  Addition of new OData entities

      3.  OData entity logic extension (for example, adding additional validations) SAP Multichannel Foundation for Utilities: Implement Custom Logic for an Existing Entity

The common situation a customer faces is that the customer would like to add new entity to existing service model.

In this blog, we will illustrate how to add new entity “ExternalAccountIdentification” to show Account identification. You can also refer to other two blogs mentioned above.

1. Start SEGW in the SAP CRM system and create a new service model project Z_CRM_UTILITIES_UMC_NEW.

2. Right click on Data Model, select Redefine OData service (GW).

3. Select CRM_UTILITIES_UMC as a service to be redefined.

4. Select all entities to be included in the new service

5.Create new entity (ExternalAccountIdentification) and entity set (ExternalAccountIdentifications).

6. Add association and navigation property from Account entity so that ExternalAccountIdentifications can be accessed via navigation from Account Entity.

    Navigation Property: Identifications

    Association: Account_ExternalAccountIdentifications

7. Save and activate the model service.

8.Create implementation class for newly created entity. You have to inherit the abstract class CL_CRM_IU_UMC_ODATA_ABSTRACT

  DATA:  ls_textid    TYPE scx_t100key,
        lv_string    TYPE string,
        lt_param     TYPE crmt_iu_umc_order_search_param,
        lt_result    TYPE crmt_isu_order_search_result_t,
        lt_cntritem  TYPE crmt_iu_umc_cntritem.
   DATA ls_idnumber    TYPE zcrms_iu_umc_idnumber.
   DATA lt_idnumber    TYPE TABLE OF zcrms_iu_umc_idnumber.
   DATA lt_idnumbers   TYPE TABLE OF bapibus1006_id_details.
   DATA lt_return      TYPE bapiret2_t.
   DATA lv_partner_id  TYPE bu_partner.
   DATA lv_id_type     TYPE bu_id_type.
   DATA lt_key_tab     TYPE /iwbep/t_mgw_name_value_pair.
   DATA ls_key_tab1    TYPE /iwbep/s_mgw_name_value_pair.
   FIELD-SYMBOLS: <fs_id>    TYPE bapibus1006_id_details.
   FIELD-SYMBOLS <result>  TYPE zcrms_iu_umc_idnumber.
   READ TABLE it_key_tab INTO ls_key_tab1 WITH KEY name = gc_key_attribute1.
   IF sy-subrc IS INITIAL.
     lv_partner_id = ls_key_tab1-value.
   READ TABLE it_key_tab INTO ls_key_tab1 WITH KEY name = gc_key_attribute2.
   IF sy-subrc IS INITIAL.
     lv_id_type = ls_key_tab1-value.
   CALL METHOD check_user_authorisation
       iv_account_id  = lv_partner_id
       iv_entity_type = 'ExternalAccountIdentification'.
   IF ls_key_tab1 IS NOT INITIAL.
     ls_idnumber-accountid = lv_partner_id.
         iv_partner              = ls_idnumber-accountid
*       IV_PARTNER_GUID         =
         et_identificationdetail = lt_idnumbers.
     LOOP AT lt_idnumbers ASSIGNING <fs_id>.
       IF sy-subrc IS INITIAL.
         ls_idnumber-identificationnumber = <fs_id>-identificationnumber.
         ls_idnumber-identificationtype = <fs_id>-identificationtype.
       APPEND ls_idnumber  TO lt_idnumber.
     IF sy-subrc <> 0.
       handle_technical_error( 'GET_ENTITYSET' ) .
     er_entityset = copy_data_to_ref( lt_idnumber ).
     TRY. "support of long navigation from other than Account and Business agreement (unlikely)
           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     er_entityset             =  er_entityset
                         es_response_context      =  es_response_context ).
       CATCH /iwbep/cx_mgw_tech_exception .
         MESSAGE e008(crm_iu_umc_odata) WITH iv_entity_set_name gc_key_attribute2 INTO lv_string.
         handle_technical_error( 'GET_ENTITYSET' ).

9. Create new BAdI implementation using the implementation class created in the previous step and give the filter value “ExternalAccountIdentification”(Entity Name).

10. In SAP Gateway system, add and activate backend service.

11. You can use the advanced REST client to test your newly created entity. You can add your username and password in the Authorization header.

Labels in this area
Top kudoed authors