
You can use the GP design time API to set transition targets based on the result states defined for the callable objects of the process.
Transitions provide flexibility of process logic and allow you to guide process flow based on runtime decisions.
Create a block containing two actions ( a_2, a_3 ).
For more information, see Creating Blocks .
We assign a callable object with two result states ( X and Y ) to action a_1 and add it to the block structure.
| Wrapping a Callable Object with Result States into an Action |
|---|
import java.util.Locale;import com.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager;import com.sap.caf.eu.gp.co.api.IGPCallableObject;import com.sap.caf.eu.gp.co.api.IGPPhysicalCallableObject;importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; // create a callable object co_1 IGPCallableObjectco_1 = manager.createCallableObject( coType, locale, coTitle, coDescription, cat.getID() ); // define two result states: x and y IGPPhysicalCallableObjectpco = co_1.resolvePhysicalCallableObject(); pco.addResultState("x","X");pco.addResultState("y","Y");// save and activate the object manager.save(co_1); manager.activate(co_1); // create action a_1 IGPModifiableActiona_1 = manager.createAction( locale, aName, aDescription, cat.getID() ); // set execute callable object co_1 a_1.setExecuteCallableObject(co_1); manager.save(a_1); // add a_1 to the block structure b.getModifiableStructure().addItem(a_1); |
For more information on how to create a callable object with result states and assign it to an action, see:
To define transitions between the actions, we need to access the corresponding block structure items.
The block structure contains three items, ia_1 , ia_2 , ia_3 , one for each of the three actions.
| Retrieving Block Structure Items |
|---|
import com.sap.caf.eu.gp.process.api.IGPModifiableBlockStructureItem;//retrieve block structure items IGPModifiableBlockStructureItemia_1 = b.getModifiableStructure().getModifiableItem(0); IGPModifiableBlockStructureItemia_2 = b.getModifiableStructure().getModifiableItem(1); IGPModifiableBlockStructureItemia_3 = b.getModifiableStructure().getModifiableItem(2); |
We set transition target ia_2 for result state X , and transition target ia_3 for result state Y . Thus, depending on the user's runtime decision, the process flow is directed either to action a_2 or action a_3 .
| Defining Transitions |
|---|
// define transitions ia_1.setTransitionTarget("x",ia_2);ia_1.setTransitionTarget("y",ia_3); |
You can also set a terminal transition, that is, a transition that directs the workflow to the end of the parent activity (block b ).
| Defining Terminal Transitions |
|---|
// define terminal transitions ia_1.setTerminalTransition("x"); |