Creating Processes

Use

You can create processes using the GP design time API. The interface allows you to manipulate the process structure and properties.

Prerequisites

You have instantiated the IGPDesigntimeUpdateManager. For more information, see Instantiating the Design Time Manager .

Procedure

  1. Create a process by providing its basic data:

You need to specify a category for the newly-created process. For this purpose, you can create a new category or provide the Id of an existing one.

Creating a Process
importjava.util.Locale;
importcom.sap.caf.eu.gp.context.api.IGPUserContext;
importcom.sap.caf.eu.gp.process.api.IGPCategory;
importcom.sap.caf.eu.gp.process.api.IGPModifiableProcess;
importcom.sap.caf.eu.gp.process.api.GPProcessFactory;
importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeManager;
importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager;
 
// instantiate the design time manager to get the root category
IGPDesigntimeManagerdtManager = GPProcessFactory.getDesigntimeManager();
IGPCategoryroot = dtManager.getRootCategory(userContext);
 
// create a new category "test" in the root category
IGPCategory cat = manager.createCategory("test","A test category", root);
 
// create a process in the cat category
StringpName ="Test API Process";
StringpDescription ="Test API Process Description";
IGPModifiableProcessprocess=manager.createProcess(
         Locale.getDefault(),
         pName,
         pDescription,
         cat.getID()
);
  1. Add blocks to the process.

    The process content is represented by a structure (IGPModifiableBlockStructure). It is an indexed sequence of items (IGPModifiableBlockStructureItem), which hold object references to activities within the process.

    The GP design time API provides the following functionalities for process structure manipulation:

    • Adding an item to the structure
    • Inserting an item into a specific position in the structure
    • Replacing an item in the structure
    • Exchanging two items in the structure
    • Deleting an item from the structure

    Since the process itself is a top-level block, the operations listed above are equivalent to the ones described in Creating Blocks .

import com.sap.caf.eu.gp.process.api.IGPModifiableBlockStructure;import com.sap.caf.eu.gp.process.api.IGPModifiableBlock;// add a block to the process structure
IGPModifiableBlockStructurepStruct = process.getModifiableStructure();
pStruct.addItem(block);
  1. Optionally, you can add new roles to the process, specify their type, and assign default users.
    Default users can be changed at runtime if you allow it with the
    setIsOverWriteAllowed()
    method. If you do not provide defaults, and the role type is Initiation Defined, you must create a role instance and assign a specific user to it before you start the process.

import com.sap.caf.eu.gp.process.api.GPRoleType;// add role Processor of type Initiator
IGPModifiableRoleInfo role = process.addRole("processor","Processor", GPRoleType.ROLE_TYPE_INITIATOR);
// add role Advisor of type Initiation Defined
process.addRole("advisor","Advisor", GPRoleType.ROLE_TYPE_INITIATION_DEFINED);
// add a default principal to the role (IPrincipal)
role.addDefault(defaultPrincipal);
// allow defaults to be overwritten at runtime
role.setIsOverWriteAllowed(true);
  1. Make sure you save and release the process after you have created and modified it.

manager.save(process);
manager.release(process);

Result

Once you have created a process, assigned blocks and roles to it, you can also:

For more information on how to edit processes, see Editing GP Development Objects .