Skip to Content
Author's profile photo Venugopal Chembrakalathil

Process Instance Search Using Context Attributes


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://”);

    The URI contains the vendor name ( 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 (
         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.



SAP Netweaver BPM Process and Task Management Facade

BPM API for Reporting Data Source-Based Search

BPM Reporting API: Description and Usage

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Stefan Henke
      Stefan Henke

      Great stuff!. It´s really incredible how flexible you can use NetWeaver BPM by using the java API.

      Thanks for sharing this.

      Author's profile photo Former Member
      Former Member

      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://");

      Author's profile photo Ajeet Phadnis
      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 = ( new"bpm://"+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


      Author's profile photo Prasad Bandaru
      Prasad Bandaru



      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://");


      Please help me this.