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: 
martin_moeller
Contributor

How often do you deal with business processes that require human interaction in their very first step?

Typically they follow this pattern:

Figure 1: Standard BPMN process with a human activity at the beginning

The downside of this model is that the process starts off with a message start event. This means that somehow the process needs to be invoked before the user can interact with the first task. This can either be through the Process Repository (part of the SAP NetWeaver Administrator) for test purposes or directly by invoking the web service (WS) endpoint that is exposed by the process model.

Another disadvantage of this approach is that the process needs to be kicked off and the user has to go to the Universal Worklist in order to open the task. When talking about a smooth user experience that is typically not what you want to achieve. To bypass this I also happen to see such patterns:

Figure 2: Standard BPMN process with an upstream human activity

Here the user interface got removed from the process model and put before. That way, the user can directly invoke the user interface, enter the data and thereby, kick-off the process under the hood (by invoking the WS endpoint again).

In my opinion, the problem with this approach is that you lost a substantial part of information, namely the user triggering the process. Of course, this could be compensated by modeling different actors/pools and documenting that a user interaction sent the message to the system.

But is not the BPMS promise in the end that you could model business processes that could directly be executed? So I would put something like this onto my personal BPMS wish list:

Figure 3: BPMN process with 'human start event' extension

Let’s call this a human start event.

Similar to human activities one could attach a user interface behind that and as a result receives an endpoint URL that could directly be invoked.

Figure 4: Fictive properties sheet for a human start event

Entering data and completing the task at runtime will implicitly invoke the business process. Thus, no indirection through the worklist is needed. Furthermore, the information about the human interaction is preserved and exactly at the point one would expect it in the process model.

Of course, one could now argue if the notation above is the correct. I personally like it as the event of some human activity kicked off the process. Alternatively, it could also be expressed this way to comply with standard BPMN semantics:

Figure 5: Standard BPMN process that does not define the trigger for the start event

The model does not define how the process is started, but the first activity will be executed by a human.

At the current state SAP NetWeaver BPM does not allow this to be built and executed as an event needs to have a trigger. So this means that we are left with the pattern from the start:

Figure 6: Standard BPMN process with a human activity at the beginning

The good news is that the BPM Public API allows us to bypass the indirection through the worklist: One could start the process implicitly and directly forward the user to the first human activity.

In an easy example - without input for the process and only one human activity at the beginning - this could look like follows:

final String vendor = "sap.com";
final String dcName = "my~human~centric~dc";
final String processName = "MyProcess";
final ProcessDefinitionManager processDefinitionManager = BPMFactory.getProcessDefinitionManager();
final ProcessStartManager processStartManager = BPMFactory.getProcessStartManager();
final TaskInstanceManager taskInstanceManager = BPMFactory.getTaskInstanceManager();
final ProcessDefinition processDefinition = processDefinitionManager.getActiveProcessDefinition(vendor, dcName, processName);
final Set<ProcessStartEvent> startEvents = processStartManager.getProcessStartEvents(processDefinition.getId());
if (startEvents.size() != 1) {
     throw new IllegalStateException(“Exactly one start event is needed.”);
}
final ProcessStartEvent startEvent = startEvents.iterator().next();
final DataObject dataObject = processStartManager.createDataObjectForStartEvent(startEvent);
final URI processInstanceURI = processStartManager.startProcess(startEvent, dataObject);
waitForProcessInactivity(processInstanceURI);
final Set<TaskAbstract> taskAbstracts = taskInstanceManager.getTaskAbstractsByParent(processInstanceURI, Collections.<Status> emptySet());
if (taskAbstracts.isEmpty()) {
     throw new IllegalStateException(“First task was not found.”);
}
final TaskAbstract taskAbstract = taskAbstracts.iterator().next();
final URL generatedTaskExecutionUrl = taskInstanceManager.generateTaskExecutionUrl(taskAbstract.getId());
response.sendRedirect(generatedTaskExecutionUrl.toExternalForm());

Finally, by putting this in a custom web application it gets addressable by URL (e.g. http://server:port/CreateRequestAndStartProcess). This way, it can easily be included in a portal or bookmarked by users on their PC, their tablet or mobile.

So even without human start events SAP NetWeaver BPM allows putting your users first in human centric processes.

Looking forward to your feedback,
Martin

Update:

For your convenience I published the sample project at SAP Code Exchange: https://code.sdn.sap.com/spaces/bpm

11 Comments