SAP MCF is a collection of out of the box applications(ODATA services). This standard ODATA services comes under Customer master data and business master data domain for SAP ISU market.

While implementation of the MCF we faced a challenge to implement patch method.

Problem Statement:

  • Patch is tightly coupled with Get and Update Entity.
  • So invoking Get and Update to make a patch has performance issue.
  • If we use only patch method(custom built), once the request is translated to the ABAP input structure , we loose track of the HTML tags. So we do not have any clue if the property is to be updated with null value or no update is required for that property.

 

To overcome this problem we had to read the input tags for the service ūüôā

Solution: Read input tags

 

How to Achieve this ?

 

A ¬†bit of code ūüôā

 

METHOD /iwbep/if_mgw_core_srv_runtime~update_entity.
DATA ls_request_details TYPE /IWBEP/IF_MGW_CORE_SRV_RUNTIME=>ty_s_mgw_request_context.

*Pass entity attributes to the request of the method

ls_request_details = is_request_details.
CALL METHOD me->/iwbep/if_mgw_core_srv_runtime~get_expand_root
EXPORTING
iv_cardinality     = /iwbep/if_mgw_med_odata_types=>gcs_cardinality-cardinality_1_1
CHANGING
cs_request_details = ls_request_details.

CALL METHOD super->/iwbep/if_mgw_core_srv_runtime~update_entity
EXPORTING
iv_entity_name     = iv_entity_name
iv_source_name     = iv_source_name
io_data_provider   = io_data_provider
is_request_details = ls_request_details
CHANGING
ct_headers         = ct_headers
cr_entity          = cr_entity.

ENDMETHOD.

 

This will enrich the request with the root elements. This can be used to find properties of the elements (updatable/sortable/filterable etc.).

As we know every ODATA entity can be generated from ABAP structure, it is very important that we get the elements. This helps us in passing values and assigning control parametres for update dynamically. Which gives us an unique advantage of create and forget mechanism of the ervice.

As even control parameters/ vlaues are passed dyncmically, so this eleminates the redesign issues when a new element is added to the ODATA service.

Mostly for getentity/getentityset methods , we use MOVE-CORRESPONDING, we do not need to modify (if the entity technical name and the function module parameter name is same) them.

After implementing the patch method we do not need to modify it as well(if the technical name and the bapi structure element name is same) ūüôā

 

 

What did we gain ?

 

Sorry that I can not publish the code of the dynamic patch method, but I hope this concept will be helpful to build the same.

 

Happy coding.

 

Regards,

Avishek

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply