Context
With the Business Process Management (BPM) application programming interfaces (APIs), you can customize and enhance the way you use business processes and execute tasks. This document describes how you start a deployed process using the BPM API. For a detailed description of the BPM public
APIs, see
http://help.sap.com/javadocs/.
Procedure
- Retrieve the ProcessDefinitionManager.
ProcessDefinitionManager processDefinitionManager = BPMFactory.getProcessDefinitionManager();
- Get the active process definition of a specified process deployed on the server.
ProcessDefinition processDefinition = processDefinitionManager.getActiveProcessDefinition(VENDOR, DC_NAME, PROCESS_NAME);
- Retrieve the ProcessStartManager.
ProcessStartManager processStartManager = BPMFactory.getProcessStartManager();
- Get the start event of the process definition.
In the current version of SAP NetWeaver BPM, only one start event is supported for each active pool; therefore, the result will contain one element only.
Set<ProcessStartEvent> processStartEvents = processStartManager.getProcessStartEvents(processDefinition.getId());
ProcessStartEvent processStartEvent = processStartEvents.iterator().next();
- Create a data object for the start event, adhering to the service interface definition assigned to the start event.
DataObject processStartDataObject = processStartManager.createDataObjectForStartEvent(processStartEvent);
- Fill in the data object with valid input data for the process.
processStartDataObject.setString(processStartDataObject.getType().getProperty(FIELD_CUSTOMER), VALUE_CUSTOMER);
- Start the process with the start event and the matching input data.
The call returns the ID of the process instance that was just started.
URI processInstanceId = processStartManager.startProcess(processStartEvent, processStartDataObject);
Results
You have started a deployed process by using the BPM API.
Caution
For a correct behavior while executing the process at runtime, you have to configure the
http.baseurl property. This configuration can be done in the SAP NetWeaver Administrator when you are logged with administrator rights. Choose
. Then choose the
Application tab and select the
tc~bpem~base~ear application.