Show TOC

Context CollectionLocate this document in the navigation structure

This collection enables you to add business context data to the generic workflow task object. This helps the user to make better decisions by reading related business data.

The Task Gateway service enables to link additional SAP Gateway service which will return the business context of a collection or a single entry.

At runtime, the consumer application retrieves the business data context using the link supplied.

Implementation

The business context is retrieved from an additional SAP Gateway service. For the context service to work properly, a predefined collection must be implemented in the new context service.

To create the context service metadata provider class (MPC):

  1. In your SAP Gateway system, open transaction SE24. The Class Builder: Initial Screen is displayed.

    Note

    Make sure the component IW_BEP is installed in this system. If your system is based on SAP NetWeaver 7.40 or higher you do not need to install IW_BEP since the SAP Gateway Foundation component SAP_GWFND is installed as standard and includes the necessary functionality.

  2. In the Object type field, enter the name of the new MPC class.

  3. Choose Create.

  4. In the Object type dialog box, select the Class radio button and choose the checkmark.

  5. In the Create Class dialog box, enter a description and choose Save. The Create Object Directory Entry page is displayed.

  6. In the Package field, assign a valid package and choose the checkmark. The Class Builder: Change Class page is displayed.

  7. Select the Properties tab.

  8. Derive your class from super class /IWPGW/CL_TGW_CONTEXT_MD_ABS and choose Save.

  9. Select the Methods tab.

  10. Redefine and implement the CREATE_CONTEXT_ENTITY method, adding the desired properties that will be used for holding business context data. For example,

    METHOD create_context_entity.
    
      DATA lo_property TYPE REF TO /iwbep/if_mgw_odata_property.
    
      lo_property = io_entity->create_property( iv_property_name  = 'MaterialName'
          iv_abap_fieldname = 'TXZ01' ).
    
      lo_property = io_entity->create_property( iv_property_name  = 'MaterialID'
      iv_abap_fieldname = 'MATNR' ).
    
      lo_property = io_entity->create_property( iv_property_name  = 'Quantity'
            iv_abap_fieldname = 'BSTMG' ).
    
      lo_property = io_entity->create_property( iv_property_name  = 'Price'
            iv_abap_fieldname = 'BAPICUREXT' ).
    
    ENDMETHOD.
     
  11. Activate your class. Your metadata class is created.

To create the context service data provider class (MPC):

  1. In your SAP Gateway system, open transaction SE24. The Class Builder: Initial Screen is displayed.

    Note

    Make sure the IW_BEP is installed in this system. If your system is based on SAP NetWeaver 7.40 you do not need to install IW_BEP since the SAP Gateway Foundation component SAP_GWFND is installed as standard and includes the necessary functionality.

  2. In the Object type field, enter the name of the new DPC class.

  3. Choose Create.

  4. In the Object type dialog box, select the Class radio button and choose the checkmark.

  5. In the Create Class dialog box, enter a description and choose Save. The Create Object Directory Entry page is displayed.

  6. In the Package field, assign a valid package and choose the checkmark. The Class Builder: Change Class page is displayed.

  7. Select the Properties tab.

  8. Derive your class from super class /IWPGW/CL_TGW_CONTEXT_RT_ABS and choose Save.

  9. Select the Methods tab.

  10. Redefine and implement the ENTITYSET_CONTEXT and the ENTITY_CONTEXT methods, to retrieve the business context data on runtime either to get a context entity set or a context entity respectively.

  11. Activate your class. Your metadata class is created.

To create a new context service:

  1. Inherit metadata class /IWPGW/CL_TGW_CONTEXT_MD_ABS and runtime class /IWPGW/CL_TGW_CONTEXT_RT_ABS.

  2. Implement the abstract methods accordingly.

For more information on how to create an SAP Gateway service see the Creating OData Channel Content section.

Mapping the Context Service

You can map your new context service to the Task Gateway in the following manner:

  1. On your SAP Gateway system, register your Model and Service as described in the Register the Model / Service section.

  2. Activate the service as described in the Activate the Service section.

  3. Maintain the context service in customization table /IWPGW/C_TGW_CTX.

Field

Example

Description

Task Type

Task ID.

TS00008267

System Alias

System alias according to the Task Gateway service.

ERP

Technical Service Name

Technical service name for the context service as maintained in transaction /IWFND/MAINT_SERVICE.

ZCONTEXT_PURCHASE_ORDER

Version

Service version as maintained in transaction /IWFND/MAINT_SERVICE.

1