Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Venugopal
Product and Topic Expert
Product and Topic Expert

Introduction

SAP NetWeaver Business Process Management 7.3 EHP1 offers various possibilities to search process instances using process context attributes. The default out of the box solution is to use the SAP NetWeaver Administrator (NWA) and go to Operations > Processes and Tasks > Manage Processes. A process administrator/technical administrator would be able to search process instances using specific context attributes.

If you require more flexibility with respect to search criteria and provide a monitoring application outside the NWA, you can build custom monitoring application using the BPM public API. BPM Public API offers Java APIs to access process management, task management and reporting data sources.

A reporting data source is a modeled artifact in a process model and it persists the selected process context attributes for analytical/operational reporting purposes. A reporting data source persists the process instance ID together with the process context attributes, which are mapped during design time.

The context attributes persisted from a process instance can be retrieved using the BPM Reporting API. The BPM Reporting API offers various filtering capabilities to retrieve the process instances based on the filters. The life cycle of the persisted process context data is linked to the process instances. Archiving of a process instance will also archive the context attributes and it will not be accessible by using the BPM Reporting API.

The context attributes can also be persisted using custom tables. This will provide more flexibility with respect to the query filters. The context data persisted in such a custom table has its own life cycle and will not be archived as part of process archiving.

Access Process Context Attributes Using the BPM Reporting API

  1. Add a reporting activity in the process model and define a reporting data source.
  2. Add the attributes to the reporting data source.
  3. Map the process context attributes to the reporting data source.

Access the Reporting Data Source ID Using the BPM Public API

  1. Retrieve the reporting data source ID.

    URI reportingDataSourceId = new URI ("bpm://bpm.sap.com/reporting-datasource/teched.sap.com/pop266~process/CustomerReq");

    The URI contains the vendor name (teched.sap.com) and the development component name (pop266~process) and the reporting data source name (CustomerReq).

  2. Get the reporting data source and retrieve the result set using a search parameter.

    ReportingDataSource rds = BPMFactory.getReportingDataSourceManager().getReportingDataSource(reportingDataSourceId);

    ReportingResultSet resultSet = BPMFactory.getReportingDataSourceManager().query(rds.getId(),"requestid", param);

  3. Iterate through the result set and access the process context data and process instance ID.

    Using the process instance ID retrieve the technical information about the process instance including process instance visualization URL.

    while (resultSet.next())
       {
         String firstName = resultSet.getString("firstname");
         String lastName = resultSet.getString("lastname");
         String city = resultSet.getString("city");
         String country = resultSet.getString("country");
         URI pid = resultSet.getProcessInstanceId();

       

         ProcessInstance processInstance = BPMFactory.getProcessInstanceManager().getProcessInstance(pid);

       

         java.util.Date startDate =  processInstance.getStartDate();
         java.util.Date endDate   =  processInstance.getEndDate();
         String subject           =  processInstance.getSubject();
         ProcessStatus status     =  processInstance.getStatus();
         String processurl = BPMFactory.getProcessInstanceManager().generateProcessInstanceVisualizationURL(pid).toString();
      }

Access Process Context Attributes Using JPA

If you require little bit more flexibility with respect to the search criteria and to be independent of the process instance life cycle, you can persist the process context attributes in an application table using JPA. It is possible to access the process instance ID from the process context. The process instance ID and context attributes can be persisted using an automated activity. This provides various filtering capabilities including value range, which are possible in JPA.

  1. Model a table using the Dictionary perspective.

    Define a Process_ID column, which represents the process instance ID.

    The rest of the column represents process context attributes.

  2. Generate the JPA entities from the dictionary.
  3. Define named queries to access the table based on various filters:

  4. Expose a service to access the process data and persist the process data:

  5. Expose the above service as a Web service interface to be able to consume it in SAP NetWeaver BPM.
  6. Import the Web service to your BPM project in the SAP NetWeaver Developer Studio and assign the service interface to the automated activity PersistCustomerRequest.
  7. Define the input mapping as shown below:

  8. Build a Web Dynpro UI application to consume the service.

    Enter a search request using the RequestID, for example, REQ*.

    This will retrieve all process instances with request ID starting REQ.

    Selecting a process instance will retrieve the task instances of the process instance.

    The process view column navigates to the process instance graphical visualization.

    REQ713 will retrieve process instances with matching context values.

References

SAP Netweaver BPM Process and Task Management Facade

BPM API for Reporting Data Source-Based Search

BPM Reporting API: Description and Usage

4 Comments