You can implement EDP in simple scenarios. In such cases, EDP will act as a data provider.
The abstract EDP class handles the life cycle of BOP objects, their corresponding Data Objects and the mapping instances. There are two variants:
Read Only abstract EDP class /IWFND/CL_MGW_RT_EDP_RO_BASE.
Write abstract EDP class /IWFND/CL_MGW_RT_EDP_WR_BASE.
To implement an EDP, proceed as follows:
Create an EDP class by inheriting either /IWFND/CL_MGW_RT_EDP_RO_BASE (in case of read only entity) or /IWFND/CL_MGW_RT_EDP_WR_BASE (in case of write) .
Implement the abstract method REGISTER_MAPPING_SPECIALISTS.
Register only those BOP and mapping specialist required for the current operation. For example, to update an entity, register only the BOP and mapping specialist required for the update scenario.
An update scenario might need a read before update. In such cases, register a Read BOP and the corresponding mapping specialist for read followed by update BOP and the corresponding mapping specialist.
Registration of BOP and mapping specialist is done by filling the structure of type GTYS_MAP_SPECIALIST_ATTRIBUTES.
Attribute Name |
Description |
execution_mode* |
Execution mode tells which mapping interface needs to be executed for an operation. Each operation supports only a valid set of execution modes. Refer the below matrix (table) for details. |
mapping_specialist_name |
Name of the mapping specialist. Note
Ignore this field if you are providing a reference to a mapping specialist instance (mapping_specialist_ref). |
mapping_specialist_ref |
Reference to mapping specialist instance. This attribute will be filled by the abstract EDP based on the mapping specialist name. Note
Ignore this option if you are providing the name of a mapping specialist (mapping_specialist_name). |
bop_type * |
Choose one of the following:
Note
If BOP is registered as custom then the attribute be_api_ref needs to be filled by you. Following constants defines the values for BOP type:
|
bop_name |
Class name of the BOP ID. |
be_api_ref** |
Reference to custom backend connectivity api. This attribute needs to be filled if BOP type is Custom. See Custom Backend Connectivity API for more information. |
ws_service_group** |
Web Service Group Name. This attribute needs to be filled if BOP type is Web Service. |
* - Mandatory attribute
** - Mandatory attribute based on the BOP Type
Matrix - Following Matrix explains valid set of execution modes for an operation code.
Operation Code / Execution Mode |
Create |
Update |
Delete |
Read |
Query |
Action |
Create |
X |
X |
X |
X |
||
Update |
X |
X |
X |
X |
||
Delete |
X |
X |
X |
|||
Read |
X |
|||||
Query |
X |
|||||
Expand Entity |
X |
|||||
Expand Entity Set |
X |
|||||
Deep Insert |
X |
X |
||||
Action |
X |
Following constants defines the operation codes and execution modes:
/IWFND/CL_MGW_RT_EDP_RO_BASE=>GC_OPERATION_CODE_RO
/IWFND/CL_MGW_RT_EDP_RO_BASE=>GC_EXECUTION_MODE_RO
/IWFND/CL_MGW_RT_EDP_WR_BASE=>GC_OPERATION_CODE_WR
/IWFND/CL_MGW_RT_WR_BASE=>GC_EXECUTION_MODE_WR
Sample code for implementing the method REGISTER_MAPPING_SPECIALISTS:
DATA: LO_MAP TYPE REF TO /IWFND/CL_MGW_MAP_COMMIT. CASE iv_entity_name. WHEN 'flight'. CASE iv_entity_operation. WHEN gc_operation_code_wr-create. ls_mapping_specialist_attr-execution_mode = gc_operation_code_wr-create. ls_mapping_specialist_attr-mapping_specialist_name = '/IWFND/CL_MGW_MAP_FLIGHT_CRE'. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_rfc. ls_mapping_specialist_attr-bop_name = '/IWFND/CL_MGW_BOP_FL_CRE'. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr. ls_mapping_specialist_attr-execution_mode = gc_operation_code_wr-create. CREATE OBJECT lo_map. ls_mapping_specialist_attr-mapping_specialist_ref = lo_map. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_rfc. ls_mapping_specialist_attr-bop_name = '/IWFND/CL_MGW_BOP_COMMIT'. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr. ls_mapping_specialist_attr-execution_mode = gc_operation_code_ro-read. ls_mapping_specialist_attr-mapping_specialist_name = '/IWFND/CL_MGW_MAP_FLIGHT_RQ'. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_rfc. ls_mapping_specialist_attr-bop_name = '/IWFND/CL_MGW_BOP_FL_READ'. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr. WHEN gc_operation_code_wr-update. ls_mapping_specialist_attr-execution_mode = gc_operation_code_wr-update. ls_mapping_specialist_attr-mapping_specialist_name = '/IWFND/CL_MGW_MAP_FLIGHT_UPD'. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_rfc. ls_mapping_specialist_attr-bop_name = '/IWFND/CL_MGW_BOP_FL_CRE'. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr. mv_remote_commit_req = abap_true. ENDCASE. |
Implementing the method GET_EXPAND_CLAUSE_DEFAULT.
Perform this step if entity needs to support Expand and Deep insert.
Transaction Handling — To commit a remote SAP Logical Unit of Work (LUW), BAPI_TRANSACTION_COMMIT is executed. A default implementation for calling the BAPI to commit data remotely is handled in the abstract EDP. You need to set the member variable MV_REMOTE_COMMIT_REQ = abap_true, if default handling is required. However, the method SAVE of the class /IWFND/CL_MGW_RT_EDP_WR_BASE can be redefined by the content if additional processing is required. This method will be executed for:
CREATE
UPDATE
DELETE
CREATE_DEEP_ENTITY
EXECUTE_ACTION
The methods ON_AFTER_COMMIT and ON_AFTER_ROLLBACK are event handlers. The methods react to the events COMMIT WORK and ROLL BACK WORK statement execution done by transaction handler. You can write your own logic to react to these events if needed.
Continue with Register the SAP Gateway Data Model.
Back to Developing Content on SAP Gateway OData Channel.