Skip to Content
Author's profile photo Piyas Kumar Das

How to get All Task of a user to design your custom UWL using BPM API as a rest full service.

This guide provides instructions on how to get All Task of a user to design your custom UWL using BPM API as a Restful Service.

Applies to:

This Document Holds good for all CE 7.3 SP05 onwards. This service can be called from UI5 Screen as an Ajax call.

Please note that from 7.31 SP12 onward you can also use the standard BPM OData service to get All Task of a user to design custom UWL as mentioned by Christian Loos.

Special Thanks to Christian Loos  for commenting in the document.


This guide describes step-by-step how to get All Task of a user to design custom UWL using BPM Process using BPM API as a rest full service.

About Me:

Piyas Kumar Das

As a Sr. Netweaver Consultant, I’ve been undertaking consulting assignments leveraging on my undermentioned NetWeaver skills.

  • Business Process Management (SAP NW BPM)
  • Restful Services using BPM api to be used in UI5 Screens.
  • SAP Web Dynpro Java (SAP WD4J)
  • SAP Business Rules Management (SAP BRMS)
  • SAP Composit Application Framework (SAP CAF)
  • Master Data Management (SAP NW MDM)
  • Enterprise Portal (SAP EP)
  • Services creation using NWDS (SAP EJB)
  • Enterprise SOA


You should have read through the document :How to Start a BPM Process using BPM API as a RESTful service.

We will be discussing following points in detail in this document –

  1. Adding Libraries.
  2. Setting up the foundation for using Libraries.
  3. Creating Deploy-able Object.
  4. Accessing the methods exposed.
  5. Testing your REST services

Adding Libraries:

Step 1 : Refer the document to add libraries.

Setting up the foundation for using Library:

Step 1 to Step 3 is same as mentioned in the document.

Step 4 : Create Business Objects as shown below:

public class TaskHeader {
  private String priority;
  private String status;
  private String taskType;
  private String id;
  private String name;
  public String getPriority() {
  return priority;
  public void setPriority(String priority) {
  this.priority = priority;
  public String getStatus() {
  return status;
  public void setStatus(String status) {
  this.status = status;
  public String getTaskType() {
  return taskType;
  public void setTaskType(String taskType) {
  this.taskType = taskType;
  public String getId() {
  return id;
  public void setId(String id) { = id;
  public String getName() {
  return name;
  public void setName(String name) { = name;

import java.util.ArrayList;
import javax.xml.bind.annotation.XmlRootElement;
public class TaskHeaders {
  protected ArrayList<TaskHeader> taskHeaders;
  public ArrayList<TaskHeader> getTaskHeaders() {
  return taskHeaders;
  public void setTaskHeaders(ArrayList<TaskHeader> taskHeaders) {
  this.taskHeaders = taskHeaders;

Step 5 : Create a restful service class file and write a code as shown below or if you are continuing from the document then just copy past the methods only.

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import bo.Material;
import bo.MaterialCreation;
import bo.TaskHeader;
import bo.TaskHeaders;
import commonj.sdo.DataObject;
import commonj.sdo.helper.XMLHelper;
public class MaterialCreationToRestService {
  private static final Location location = Location.getLocation(MaterialCreationToRestService.class);
  private final String PRE_TASK_URI = "bpm://";
  public TaskHeaders getAllTasks() throws Exception
    System.err.println("ArticleMaintenanceService -> getAllTasks");
    TaskHeaders taskHeaderDetails = new TaskHeaders();
    TaskHeader bpmTaskDetail;
    TaskAbstract myTask;
  URI taskInstanceId;
  TaskDetail taskDetails;
    //Retrieve the TaskInstanceManager
    TaskInstanceManager taskInstanceManager = BPMFactory.getTaskInstanceManager();
    //Build the set of statuses to query
    HashSet<Status> statuses = new HashSet<Status>();
    //Query those statuses
    Set<TaskAbstract> myTasks = taskInstanceManager.getMyTaskAbstracts(statuses);
    System.err.println("size(myTasks) : "+myTasks.size());
        ArrayList<TaskHeader> bpmTaskDetails = new ArrayList<TaskHeader>();
    //Use the ID of a task instance to generate the URL of the task execution UI
    for (Iterator iterator = myTasks.iterator(); iterator.hasNext();)
    myTask = (TaskAbstract);
    taskInstanceId = myTask.getId();
    taskDetails = taskInstanceManager.getTaskDetail(taskInstanceId);
    bpmTaskDetail = new TaskHeader();
    // Add Detail to the List
  catch (BPMException e)
  System.err.println("BPMException : "+e.getMessage());
  throw e;
  return taskHeaderDetails;

Step 6 & Step 7 is same as mentioned in the document. If you are continuing then you can ignore these steps.

Creating Deploy-able Object & Accessing the methods exposed.

Refer the document to “Creating Deploy-able Object” & “Accessing the methods exposed” as it is the same.

Testing your REST services

You can test the created REST services using the POSTMAN for Chrome or Advanced REST client for Chrome.2.JPG

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.