Skip to Content

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.

Mapping_Reporting1.png

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.

    Table1.png

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

    namedQueries.png

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

    exposeService.png

  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:

    InputMapping.png

  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.

    SearchInput.png

    REQ713 will retrieve process instances with matching context values.

    SearchInput2.png

References

SAP Netweaver BPM Process and Task Management Facade

BPM API for Reporting Data Source-Based Search

BPM Reporting API: Description and Usage

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Priyadarshini P

    Nice Blog!!!

    I just wanted to know, is it possible to Query standard reporting datasource – BPM_MY_TASKS_DS like above. If yes what would be the URI?? like below –

    URI url = new URI(“bpm://bpm.sap.com/reporting-datasource/BPM_MY_TASKS_DS“);

    (0) 
  2. Ajeet Phadnis

    Hello Venugopal,

    I am not sure if you are still listening on this blog, but I am trying to implement a reporting activity retrival application based on ejb. my code is  as follows:

     

    this.reportingDSId = (java.net.URI) new java.net.URI(“bpm://bpm.sap.com/reporting-datasource/dfo.no/dfodss_prod_dc/”+reportingURI);

      this.ejbTrace = this.ejbTrace + this.reportingDSId.toString();

      this.reportDS = BPMFactory.getReportingDataSourceManager().getReportingDataSource(this.reportingDSId);

      this.ejbTrace = this.ejbTrace + this.reportDS.toString();

      this.rrSet = BPMFactory.getReportingDataSourceManager().query(this.reportDS.getId(),”inn_registration”, 1);

     

     

    When executing the ejb method, I get Class Cast Exception when accessing

    getReportingDataSource bpm api method.

    Can you help me identify what is the cause for this exception ?

     

    Appreciate your help.

     

    Best Regards,

    Ajeet Phadnis

    e-mail: ajeet.phadnis@dfo.no

    (0) 
  3. Prasad Bandaru

    Hi,

     

    I just wanted to know, is it possible to Query standard reporting datasource – BPM_MY_TASKS_DS like above. If yes what would be the URI?? like below –

    URI url = new URI(“bpm://bpm.sap.com/reporting-datasource/BPM_MY_TASKS_DS“);

     

    Please help me this.

     

    -Prasad

    (0) 

Leave a Reply