import note 2183832, and then:
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY - no change
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY - no change
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~PATCH_ENTITY:
keypoint
a. you have to manually insert entry to cl_crm_opportunity_impl=>gt_customer_h in your own code:
[外链图片转存失败(img-GDVe3wH4-1562295211610)(https://user-images.githubusercontent.com/5669954/27517921-cfa72664-59d4-11e7-96d9-cd61b0455c53.png)]
b. you have to manually insert entry to cl_crm_opportunity_impl=>gt_input_fields in your own code as well:
[外链图片转存失败(img-AyV3voPg-1562295211612)(https://user-images.githubusercontent.com/5669954/27517925-d40e3206-59d4-11e7-8da0-83153b9178e5.png)]
complete source code
METHOD /iwbep/if_mgw_appl_srv_runtime~patch_entity.
CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~patch_entity
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
io_data_provider = io_data_provider
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
io_tech_request_context = io_tech_request_context
IMPORTING
er_entity = er_entity.
FIELD-SYMBOLS: TYPE crmt_odata_oppt_header,
TYPE crmt_customer_h_com,
TYPE crmt_odata_oppt_header-ext_created_by,
LIKE LINE OF cl_crm_opportunity_impl=>gt_input_fields.
* Jerry: in CL_CRM_OPPORTUNITY_impl=>PATCH_OPPT_HEADER_ENTITY only extension field name
* like "fld00008c" is passed in, and it is impossible for us to determine which BO part this
* extension field comes from, eg from OPPORT_H or CUSTOMER_H?
* as a result, it is necessary for extension developer to specify mapping in this method
DATA: ls_input TYPE crmt_input_field_names.
CHECK iv_entity_name = 'Opportunity'.
ASSIGN er_entity->* TO .
CHECK sy-subrc = 0.
ASSIGN COMPONENT 'EXT_CREATED_BY' OF STRUCTURE TO .
DATA: ls_customer_h LIKE LINE OF cl_crm_opportunity_impl=>gt_customer_h.
ls_customer_h-fld00008c = .
ls_customer_h-ref_guid = -guid.
APPEND ls_customer_h TO cl_crm_opportunity_impl=>gt_customer_h.
DATA: ls_customer_h_input LIKE LINE OF cl_crm_opportunity_impl=>gt_input_fields,
ls_name LIKE LINE OF ls_customer_h_input-field_names.
ls_customer_h_input-ref_guid = -guid.
ls_customer_h_input-ref_kind = 'A'.
ls_customer_h_input-objectname = 'CUSTOMER_H'.
ls_name-fieldname = 'FLD00008C'.
APPEND ls_name TO ls_customer_h_input-field_names.
INSERT ls_customer_h_input INTO TABLE cl_crm_opportunity_impl=>gt_input_fields.
ENDMETHOD.