h1. *Overview* Occasionally we would like to create a consumer Workflow application (e.g. a mobile application) that displays business object data on top of the Workflow item’s regular data. For example, for each Workflow task based on a purchase order, we want to display the purchase order items together with their data. We would like to use the existing Workflow OData Channel Service and also display business data in the application. Since we do not wish to change the functionality of the Workflow service, there is no need to create a new Workflow service and re-implement all the existing functionality. Instead, we can use the existing service with its functionality and add our own functionality using inheritance . To inherit the Workflow OData Channel Service: * Inherit the runtime class and implement reading the new entities and any actions you wish to implement. * Configure your new service in the SAP system. * Activate the service in the Gateway system. h1. Example We want to build a Workflow service that has an extra entity – POItem (Purchase Order Item Data). We want to be able to view all the items’ details and to update a purchase order item through this service. Necessary fields for the new entity: 0.1. PO Number 0.2. PO Item Number 0.3. Material 0.4. Quantity 0.5. Unit of Measure 0.6. Plant 0.7. Net Price 0.8. Agreement 0.9. Agreement Item h1. Creating the Metadata Class The metadata class of the service defines all the service’s data. This means all fields, all entities the fields are contained in, connections between the entities, cardinalities etc.. We must implement the metadata class so that it keeps all the Workflow data as well as the additional data. To do that, the class needs to inherit from the metadata class of the Workflow service – /IWWRK/CL_MGW_MED_WORKFLOW – and we need to redefine the method DEFINE. Refer to the code below as an example: METHOD define. super->define( ).” All of the base service’s entities create_po_item_entity( ). ” The new entity ENDMETHOD. METHOD create_po_item_entity. DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ, “The new entity lo_property TYPE REF TO /iwbep/if_mgw_odata_property. “A field in the entity DATA: lo_association TYPE REF TO /iwbep/if_mgw_odata_assoc. “Association to the header entity *Creating a new entity in the metadata model. lo_entity_type = model->create_entity_type( ‘POItem’ ).
* Able to make an update, Choose *SAP Reference IMG*.0.1. Navigate to: SAP NetWeaver –> SAP NetWeaver Gateway Business Suite Enablement –> Backend OData Channel –> Maintain Object Models. 0.2. Enter the name and version of your object model and choose *Create*. In the next screen, enter the metadata class you have created and a description for the object model. 0.1. Choose Save. 0.1. Create the Service. 0.1. In your SAP system, open transaction SPRO. 0.2. Choose *SAP Reference IMG*.0.1. Navigate to: SAP NetWeaver –> SAP NetWeaver Gateway Business Suite Enablement –> Backend OData Channel –> Maintain Service. 0.2. Enter the name and version of your service and choose *Create*. 0.1. In the next screen, enter the runtime class you have created and a description for the service. 0.2. Choose *Assign Model*.” 0.1. In the *Assign Model* screen, enter the object model and version you maintained in the previous step. h1. Activating the Service in the Gateway System Now that the service is configure, we need to activate it in the Gateway system. 0.1. In the Gateway system, go to transaction SPRO. 0.2. Choose *SAP Reference IMG*.0.1. Navigate to: SAP NetWeaver –> Gateway –> Administration –> OData Channel –> Activate Services. 0.2. Enter the system alias of the SAP system and press *Enter*. A list of all services from this SAP system displays. 0.1. Mark the service you have just created and choose *Activate Service*.