
When working with the GP design time API, you need access to development objects saved to the database. This procedure shows you how to search for persisted objects by specifying object attributes. Once you have found the development objects you need, you can use the design time update manager listing functionality to retrieve information about them or open them for editing. When an object is open for editing, it is locked until you save and release it.
You can filter objects depending on their category and status. If you do not want to restrict object search to a given category or status, you should replace the search criteria with null.
| Retrieving Actions with Status ACTIVE |
|---|
importjava.util.Iterator; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager; importcom.sap.caf.eu.gp.process.api.IGPCategory; importcom.sap.caf.eu.gp.base.api.GPDevelopmentObjectStatus; // retrieve actions with a category and status ACTIVE Iteratorlist = manager.getActions( newString[] {cat.getID()}, newGPDevelopmentObjectStatus[] {GPDevelopmentObjectStatus.ACTIVE_STATUS}); |
You can use this information, for example, to retrieve an object's Id and version number by specifying a title and description for it.
| Retrieving Objects Information |
|---|
importcom.sap.caf.eu.gp.base.api.IGPDevelopmentObjectInfo; while(list.hasNext()) {// get object info IGPDevelopmentObjectInfo info = (IGPDevelopmentObjectInfo) list.next(); ... } |
| Opening a Development Object of Type Action |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; IGPModifiableAction a= manager.openAction(info.getId(), info.getVersionNumber()); |
You can modify:
| Modifying Development Objects |
|---|
importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; importcom.sap.caf.eu.gp.co.api.IGPCallableObject; importcom.sap.caf.eu.gp.process.api.IGPModifiableBlock; importcom.sap.caf.eu.gp.process.api.IGPModifiableProcess; action.replaceExecuteCallableObject(co); co.setConfigProperty("CONFIG","value");block.addRole("approver","Approver");process.setDefaultRuntimeView(viewID); |
The modification lock imposed on the object does not allow simultaneous editing and should be removed after all editing operations have been performed.
| Saving and Releasing an Action |
|---|
importcom.sap.caf.eu.gp.exception.api.GPBaseException; IGPModifiableActiona = null; try{// open action or create a new one // make some changes... // save it manager.save(a); }catch (GPBaseException e) {// handle exception } finally{if (a != null) manager.release(a); } |
Once activated, the current object version can no longer be edited. You can only modify the upgraded inactive version of the object.
| Activating an Action |
|---|
manager.activate(a); |
| Retrieving Callable Objects Based on Category |
|---|
importcom.sap.caf.eu.gp.base.api.IGPDevelopmentObjectInfo; importcom.sap.caf.eu.gp.process.api.IGPCategory; importcom.sap.caf.eu.gp.co.api.IGPCallableObject; importjava.util.Iterator; importjava.util.Locale; importcom.sap.caf.eu.gp.context.api.IGPUserContext; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeManager; importcom.sap.caf.eu.gp.process.api.GPProcessFactory; importcom.sap.caf.eu.gp.exception.api.GPEngineException; importcom.sap.caf.eu.gp.exception.api.GPInvocationException; // find category "test" in the root category String catName ="test"; IGPCategory cat =null; IGPDesigntimeManagerdtManager = GPProcessFactory.getDesigntimeManager(); IGPCategoryroot = dtManager.getRootCategory(userContext); IGPCategory[]subs = root.getSubCategories(); for(int i = 0; i < subs.length; i++) { if (subs[i].resolveTitle(Locale.getDefault()).equals(catName)) {cat = subs[i]; } } // specify search attributes for the callable object StringcoTitle = "Title"; StringcoDescription = "Description"; IGPCallableObjectco = null; try{//retrieve callable objects of any status in category cat Iteratorlist = manager.getCallableObjects( new String[] {cat.getID()},null ); //for each callable object in the list while(list.hasNext()) {// get object info IGPDevelopmentObjectInfo info = (IGPDevelopmentObjectInfo) list.next(); // open it if title and description match if (info.getTitle().equals(coTitle) && info.getDescription().equals(coDescription)) {co = manager.openCallableObject(info.getId(), info.getVersionNumber()); break; } } } catch (GPEngineException e) {// handle exception } catch (GPInvocationException e) {// handle exception } |
| Retrieving Processes Based on Status |
|---|
importcom.sap.caf.eu.gp.base.api.GPDevelopmentObjectStatus; importjava.util.Iterator; importcom.sap.caf.eu.gp.base.api.IGPDevelopmentObjectInfo; importcom.sap.caf.eu.gp.process.dt.api.IGPDesigntimeUpdateManager; // define the status of the processes you want to list GPDevelopmentObjectStatus[]statusArray = {GPDevelopmentObjectStatus.ACTIVE_STATUS, GPDevelopmentObjectStatus.INACTIVE_STATUS }; // list processes of any category, with status ACTIVE and INACTIVE Iteratorprocesses = manager.getProcesses(null, statusArray); // for each process in the list while(processes.hasNext()) {// get object info IGPDevelopmentObjectInfo gpDevelopmentObjectInfo = (IGPDevelopmentObjectInfo)processes.next(); // edit objects... } |