Retrieving Process Notification Instances
Use
To be able to dynamically update at runtime the status and processing time of notifications you need to instantiate the runtime and notification managers and retrieve the available notification instances of the relevant process.
Prerequisites
You have set up your project in SAP NetWeaver Developer Studio. For more information, see Setting Up Your Project .
Procedure
Retrieving Notification Instances
- Instantiate the runtime and notification managers:
importcom.sap.caf.eu.gp.process.api.GPProcessFactory; importcom.sap.caf.eu.gp.process.rt.api.IGPNotificationManager; importcom.sap.caf.eu.gp.process.rt.api.IGPRuntimeManager; IGPRuntimeManager rtManager = GPProcessFactory.getRuntimeManager(); IGPNotificationManager notifManager = GPProcessFactory.getNotificationManager(); |
- Retrieve a running process instance by specifying search criteria:
- Specify start and end dates for the process:
importjava.util.Calendar; importjava.util.Date; Calendar calendar = Calendar.getInstance(); calendar.set(2006, 1, 1); Date startDate = calendar.getTime(); calendar.set(2006, 11, 31); Date endDate = calendar.getTime(); |
- Search for process instances meeting your requirements:
importjava.util.Locale; importcom.sap.security.api.IUser; importcom.sap.caf.eu.gp.context.api.GPContextFactory; importcom.sap.caf.eu.gp.context.api.IGPContextManager; importcom.sap.caf.eu.gp.context.api.IGPUserContext; importcom.sap.caf.eu.gp.process.api.GPSearchRole; importcom.sap.caf.eu.gp.process.api.IGPProcessInstanceInfo; // create user context from the current user and locale IGPContextManagercontextManager = GPContextFactory.getContextManager(); IGPUserContextuserContext = contextManager.createUserContext(user, locale); IGPProcessInstanceInfoprocessInfo[] = rtManager.getRunningInstances( // specify a search role GPSearchRole.SEARCH_ROLE_ADMINISTRATOR, startDate, endDate, // specify user context userContext ); |
- Retrieve the information for a single process instance:
importcom.sap.caf.eu.gp.process.api.IGPProcessInstance; // get process instance information for(int i = 0; i < processInfo.length; i++) {
IGPProcessInstance process = rtManager.getProcessInstance( processInfo[i], userContext ); |
- Retrieve all notification instances related to the running process instance:
importjava.util.Enumeration; Enumerationnotifications = process.getNotificationInstanceEnumeration(); |
Retrieving Notification History
You can retrieve all versions of a notification instance by providing its ID, the ID of the process, and, optionally, the activity ID (if it is defined at the activity level):
importcom.sap.caf.eu.gp.process.rt.notification.api.IGPNotificationInstanceEnumeration; IGPNotificationInstanceEnumeration notifEnum = notifManager.retrieveNotificationHistory( processInstanceID, activityID, notifID ); |
Result
Once you have information about the process notifications, you can update them or change their status. For more information, see Updating Notification Processing Time and Status .