That means, the read and update operation on extension fields are already supported. In this blog, we will finish the left part: support creation operation as well. The UI after enhancement would look like below:

Step1 add new extension field in creation UI view

The logic is exactly the same as how we have added the extension in detail view and edit view. To avoid duplication the source code is not listed here:

Step2 Create sub class based on CL_CRM_OPPORTUNITY_IMPL

In my blog, the sub class is ZCL_CRM_OPPORTUNITY_IMPL_SUB. Only one method below needs redefinition.

The purpose of this redefined method are to populate necessary information regarding extension field passed from UI and store them in internal table et_customer_h and et_input_fields, which will be used in function module CRM_ORDER_MAINTAIN for opportunity creation.

Step3 Redefine /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY

Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY of your own OData service implementation class. The idea is simple, just replace the usage of standard CL_CRM_OPPORTUNITY_IMPL to your own sub class created in step2.