
The Guided Procedures (GP) framework allows you to initiate GP processes in two basic ways:
This procedure describes the steps needed to introduce scheduled initiation of processes to your composite application with the Scheduled Process Initiation API.
| Instantiating the Scheduling Service |
|---|
importcom.sap.caf.eu.gp.scheduling.api.GPScheduleFactory; importcom.sap.caf.eu.gp.scheduling.api.IGPScheduleService; IGPScheduleService scheduleService = GPScheduleFactory.getGPScheduleService(); |
| Creating a User |
|---|
importcom.sap.security.api.IUser; importcom.sap.security.api.IUserFactory; importcom.sap.security.api.UMFactory; importcom.sap.caf.eu.gp.context.api.IGPUserContext; importcom.sap.caf.eu.gp.context.api.IGPContextManager; importcom.sap.caf.eu.gp.context.api.GPContextFactory; |
For detailed information about the relevant API, see Starting and Terminating Processes Using the GP API .
You have to associate this object with the process template you have retrieved previously. You may also specify a post-processing implementation that provides a set of custom methods, including a callback method.
| Creating a Scheduled Initiation Object for a Process |
|---|
importcom.sap.caf.eu.gp.scheduling.api.IGPTask; importcom.sap.caf.eu.gp.scheduling.api.IGPScheduledProcessInitiation; String processName = "Process scheduled for initiation"; String processDescription = "Description"; intafterExCompType = IGPTask.APPLICATION_COMPONENT_TYPE_LIBRARY; String afterExCompName = "test.sap.com~caf~jtest~eu~gp~api~demo~callback"; String afterExClass = "com.sap.test.caf.test.eu.gp.api.schedinst.postproc.ScheduledInitiationCallback"; IGPScheduledProcessInitiation initiation = GPScheduleFactory.createScheduledInititation( // the IGPProcess instance from step 2 process, // the relevant user creator, // free text values for process name and description processName, processDescription, // the IGPProcessRoleInstanceList from step 2 roles, // type and name of the post-processing component afterExCompType, afterExCompName, // name of the post-processing class afterExClass ); |
You must associate the task with the initiation object you have created previously and provide additional information, such as the task name and a description, creator, time of creation and the input parameter structure of the process.
| Creating a Task for Scheduled Process Initiation |
|---|
String taskName = "Schedule process initiation task"; String taskDescription = "Description"; inttaskId = scheduleService.createTask( // initiation object from step 3 initiation, // name and description of the task taskName, taskDescription, // the user that creates the task creator, // time of creation - current time newTimestamp(System.currentTimeMillis()), // the IGPStructure structure from step 2 inputStr ); |
GPScheduleFactory
createTimingOnce()
createTimingRecurrentDaily()
createTimingRecurrentMonthly()
createTimingRecurrentWeekly()
createTimingRecurrentYearly()
IGPTimingCreation
Schedule Properties
| Property | Possible Values |
|---|---|
|
Priority |
IGPScheduleService.PRIORITY_HIGH |
IGPScheduleService.PRIORITY_LOW |
|
IGPScheduleService.PRIORITY_STANDARD |
|
|
Error Mode |
IGPScheduleService.ERROR_MODE_DISMISS |
IGPScheduleService.ERROR_MODE_TRY_AGAIN |
|
IGPScheduleService.ERROR_MODE_TRY_UNTILL_SUCCESS |
| Creating a Schedule Occurring Once |
|---|
importcom.sap.caf.eu.gp.scheduling.api.IGPTimingCreation; longScheduleInitTimeOffset = 2000; // set initial time of schedule - delayed with some offset Timestamp scheduleInitTime =newTimestamp(System.currentTimeMillis()+ ScheduleInitTimeOffset); IGPTimingCreation taskSchedule = GPScheduleFactory.createTimingOnce( // task id from step 4 taskId, // schedule priority IGPScheduleService.PRIORITY_STANDARD, // initial time of schedule scheduleInitTime, // error mode of schedule IGPScheduleService.ERROR_MODE_DISMISS ); // assign the schedule to the task by persisting it in the database intscheduleID = scheduleService.scheduleTask(taskSchedule); |
IGPTiming
| Modifying and Deleting a Schedule |
|---|
importcom.sap.caf.eu.gp.scheduling.api.IGPTiming; // get the schedule created previously from the database |
The schedule that you created allows you to start a particular process according to the timing preferences you have specified.
initiatedProcess()IGPScheduledInitiationPostProcessingInterface