Skip to Content
0
Former Member
Jun 02, 2008 at 09:51 AM

How to assign a group to a role when starting a gp process programmatically

45 Views

Hi

I started a gp process programmatically like it is described here: http://help.sap.com/saphelp_nw2004s/helpdata/en/43/fcdf77fc6510b3e10000000a11466f/frameset.htm

Creating the Role Assignment List

import com.sap.caf.eu.gp.process.api.GPProcessFactory;
import com.sap.caf.eu.gp.process.api.IGPProcess;
import com.sap.caf.eu.gp.process.rt.api.IGPProcessRoleInstanceList;
import com.sap.caf.eu.gp.process.rt.api.IGPRuntimeManager;
import com.sap.security.api.IUser;

public void startProcess( java.lang.String processId )
  {
...

   // retrieve the Runtime Manager
   IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();

   // create an empty role assignment list
   IGPProcessRoleInstanceList roles = rtm.createProcessRoleInstanceList();

   // get the process role number
   int rolenum = process.getRoleInfoCount();

   // iterate over the required roles
   for (int i = 0; i < rolenum; i++) {

      // create a new role instance by specifying the role's unique name
      IGPProcessRoleInstance roleInstance = roles. createProcessRoleInstance(process.getRoleInfo(i).getRoleName());

      // add a user to the role instance
      roleInstance.addUser(roleUser);

      // add the new role to the assignment list
      roles.addProcessRoleInstance(roleInstance);    

   }

...
}

Instead of assigning a user to the role

       // add a user to the role instance
      roleInstance.addUser(roleUser);

I would like to assign a group to the user. How can I do this?

Thanks for your help (points will be awarded)

Best regards

Bettina