To abort the process instance and join the data into specified target process instance, use joinProcessInstance method of the WorkflowService.
/**
* Aborts the specified process instance and joins the data into the specified target process instance.
* Existing data values of the target process instance are not overwritten. Process attachments are merged.
*
* @param processInstanceOid The oid of the process instance which should be aborted and joined into the target process instance.
* @param targetProcessInstanceOid The oid of the process instance that should be the target of the join.
* @param comment Allows specifying a comment.
* @return The target process instance.
*/
@ExecutionPermission(
id=ExecutionPermission.Id.abortProcessInstances,
scope=ExecutionPermission.Scope.processDefinition,
defer=true)
public ProcessInstance joinProcessInstance(long processInstanceOid,
long targetProcessInstanceOid, String comment);
The required permission to execute this method is joinProcessInstance.
Note that when using the API to abort and join a process, you may get ConcurrencyException.
In that case, wait for sometime and retry the API call.