You must implement data providers for complex scenarios (if you are using multiple entities defined in the SAP Gateway Object Model). EDP and data providers can be implemented in different cases (see the diagram below):
Option 1 and option 2 is preferred in case there are multiple entities defined in the SAP Gateway Object Model and each entity corresponds to different backend API (RFC or BAPI or Web service). In this case a data provider instantiates EDPs
Option 3 is preferred if the model has a single entity defined. In this case EDPs act as data providers.
The runtime processing for a SAP Gateway Data Model can be handled by one data provider class for each software release. Implement one EDP for each individual entity in the SAP Gateway Data Model. For example, If a SAP Gateway data model is defined for Sales Order with Sales Order Header as one entity and Sales Order Item as another entity (each having different backend APIs), then implement an EDP for each of these entities separately. Proceed as follows:
Create a data provider class by inheriting /IWBEP/CL_MGW_ABS_DATA.
Redefine the CRUD operations of the data provider class.
Do not call CRUD operations of the super class.
Instantiate the EDP based on the entity name IV_ENTITY_NAME provided as importing parameter. While creating an EDP pass the system alias and the context.
CREATE OBJECT <entity_ref> TYPE <ENTITY> EXPORTING io_context = mo_context iv_system_alias = mv_system_alias. ir_service_doc_name = mr_service_document_name ir_service_version = mr_service_version ir_service_namespace = mr_service_namespace.
Execute the CRUD operations of EDP.
Continue with Implementing Entity Data Provider.