The purpose of this article is to explain the developers how standard MCF service(ERP_ISU_UMC) can be utilized to incorporate the custom requirements.
SAP NetWeaver Gateway Service model extensibility can be achieved on different levels :
- OData entity structure extension(Using append structure to add custom fields)
- OData entity logic extension(for example , adding additional validations)
- Addition of new OData entities
So now let’s move to our example.
Scenario : Fetch few additional custom fields from Account Contacts and customize the logic(Point 1 and 2)
Step 1 : Go to SEGW and open project ERP_ISU_UMC, Right Click and Select ‘Copy Project’
Step 2 : Enter the custom Project name , Change the Package and click Ok.
Step 3 : To include the additional fields in entity AccountContact
- Identify the structure being used for that particular entity
In this case , structure ISUS_UMC_CONTACT is used for Entity AccountContact.
Enhance the above structure using .Append
Step 4: After enhancing the structure with .Append, select the Entity AccountContact and click Import->Properties, to fetch the additional fields from the append structure.
Select all the required fields and click on Next and Finish .
Step 5 :Then generate the service, using the Generate Runtime Objects Button.
Rename the classes as per naming convention and click ok. Note : Keep the ‘Overwrite Base/Extended Services’ check box unchecked.
Step 6 : Open the ZCL_ZICCSERP_ISU_UMC_DPC_EXT Class and redefine the method ‘GET_SERVICE_IMPL’ with the code shown below.
METHOD get_service_impl. DATA: lr_badi TYPE REF TO isu_umc_odata. IF mv_no_commit = abap_true. "batch processing is active mo_context->set_parameter( EXPORTING iv_name = 'CHANGESET_ACTIVE' iv_value = abap_true ). ENDIF. mo_context->set_parameter( iv_name = 'DPC' iv_value = me ). mo_context->set_parameter( iv_name = 'RECDET' iv_value = mr_request_details ). GET BADI lr_badi FILTERS entity_name = iv_entity_name service_name = iv_service_name. CALL BADI lr_badi->get_instance EXPORTING ir_context = mo_context CHANGING cr_service_impl = rr_result. ENDMETHOD.
Step 7 : Now to write our custom logic we must enhance BAdI : ISU_UMC_ODATA.
In this E.g. we are enhancing the logic for AccountContact Entity.
Below are the steps to enhance the BAdI
Step 7.1 : Create a Custom Class(ZLCS_ICC_ERPISU_UMC_ACCOUNTCONTACT’ with ‘CL_FKK_UMC_ODATA_ACCCONTACT’ as superclass and mark it as Final
Step 7.2 : Go to SE19 , enter the standard BAdI name(ISU_UMC_ODATA) and click Create Implementation
Step 7.3