
By redefining an existing SAP Gateway service, you create a new service that inherits all functionality of the original one. This is used to extend an SAP-delivered service in the customer namespace or if you want to create a new version of the service keeping the original one.
SAP Gateway Services Redefinition Process

The development starts with the creation of a new project. Data model definition and service implementation are performed in just one step by choosing Redefine → OData Service (SAP GW) from the context menu of the data model folder. After generating the runtime artifacts, the implementation can be tested.
The real extension starts with changing the data model, which does not only include beautification but also adding additional data model elements like entity types or associations. New elements will get available after generating again the runtime artifacts. Then the implementation adding the new functionality can follow.

Usually entity types delivered in SAP-services are bound to DDIC structures. If you want to add additional properties to such an entity type, you must first add these as new components to the DDIC structure by using include or append structures. For adding these new components as properties, right-click the entity type and choose Import → Properties.

The Import Properties Wizard displays components added via include or append structures as normal properties. Select them and change the name and label as you wish. It is even possible to add new key components.

As usual, you get a set of data and model provider classes. In the model provider base class, the new method get_extended_model is used to set the technical model and service, which should be to imported. The model provider extension class can be used to enhance the data model as usual.
The data provider base class inherits the original data provider extension class. That means that all die implementation of the original SAP Gateway service, the generated part as well as the hand-written one, is directly available in the new service. Enhancements can be implemented as usual by redefining the methods in the new extension class – but also by generating code in the new base class.
Adding Additional Entities
The SAP Gateway Service Builder does not generate CRUD methods if you add additional entity sets to a service that has been created using redefinition. You must add these methods yourself and redefine the generic CRUD methods in the DPC_EXT to call your methods.
To redefine a generic method, perform the following steps:
- Check for the name of the new entity set.
- Call the super method for all other entity sets.
As an example, the /iwbep/if_mgw_appl_srv_runtime~get_entityset may look like this:
12345678910METHOD /iwbep/if_mgw_appl_srv_runtime~get_entityset.
...
CASE io_tech_request_context->get_entity_set_name( ).
WHEN '<NewEntitySet>'.
me-><NewEntitySet>_get_entity( ... ). " The method you created
WHEN OTHERS.
super->/iwbep/if_mgw_appl_srv_runtime~get_entityset( ... ).
ENDCASE.
...
ENDMETHOD.
The other methods are implemented in a comparable way.