This chapter provides overviews of workflow batch processes, batch workflow applications, Database Agents conversion, and the Notification Application Class, and discusses how to create batch workflow applications.
When you are working with PeopleSoft applications, you perform some activities interactively (online processes) and the system performs some behind the scenes (batch processes). Batch processes provide three major benefits:
You can schedule them to run later, on a recurring schedule.
They can process a large number of items all together, unlike online processes, which typically process one item at a time.
You can transfer processing to a server so that time-consuming tasks don’t monopolize your machine.
However, batch processes have one drawback: they connect to the database directly, rather than working through the PeopleSoft pages. If your application validates incoming data or runs custom PeopleCode, you might not want a batch process updating the database in this way. Also, because you trigger business events by saving data on a page, batch processes cannot initiate a workflow.
You can use Application Engine programs or a component interface to work around these limitations. Like online processes, Application Engine programs enter data through PeopleSoft pages (using a component interface as an intermediary). Like batch processes, they can handle a batch of items.
For example, suppose a batch process transfers assets between departments, and you want to notify (using an email message) the managers of all affected departments. The batch process cannot trigger an email routing, and to create the email messages manually is time-consuming. Instead, after the batch process is complete, you can run an Application Engine program that selects the transferred assets and sends an email message to each manager. You can also replace the batch process with an Application Engine program that makes the asset transfer.
This section provides overviews of:
Workflow batch processing.
Database monitoring with PeopleSoft Application Engine.
Events triggered with component interfaces.
For an Application Engine program to trigger a business event, it must pass its data to a component interface, and the component interface must then trigger Workflow PeopleCode in a component. Therefore, to set up batch processing, you must set up all three stages of the process:
Create the Application Engine program that queries the database.
Define a component interface that maps the results to a page.
You decide whether to enter new data on a page. For example, you can create a separate table for tracking overdue invoices. Alternatively, you can use the Save method in the component interface to force PeopleCode to run without entering data on the page. In this case, you set up PeopleCode in your main invoice record and use the component interface Save method to run that PeopleCode when the invoice is overdue (without affecting the data).
Create the Workflow PeopleCode that triggers the appropriate business event.
Usually, a user entering data on a page triggers a business process. For example, in a purchase order approval process, the system generates an approval request when a user enters a new purchase order. This immediate response is part of the productivity gain that PeopleSoft Workflow provides.
However, you might want to trigger routings based on an event that doesn’t involve a user; for example, when the number of outstanding work item entries becomes too high, a contract lapses, PeopleSoft Process Scheduler completes a batch process, and so on. Application Engine programs make such routings possible.
Application Engine programs do not trigger business events directly. With PeopleSoft Workflow, you trigger business events by entering (and saving) data on a PeopleSoft page that has Workflow PeopleCode associated with it.
Application Engine programs trigger business events indirectly, by passing the results of their queries to the component interface. If the component has associated Workflow PeopleCode, a business process is triggered when the component interface saves the page.
If an Application Engine program returns multiple rows of data, for example, if it finds several overdue item, the agent passes the rows to the component interface one row at a time.
Database Agents were used in previous versions of PeopleSoft to perform batch processing. If you implemented Database Agents, convert them to use the most recent technology offered by PeopleCode and Application Engine.
Here are some additional guidelines to consider if you are converting an existing database agent:
Duplicate the database agent behavior using PeopleCode.
The database agent behavior is determined through its properties, so using PeopleCode to produce this behavior provides greater flexibility because you have all of the capabilities of PeopleCode functions, including the PeopleCode debugger.
The Field Mapping dialog box for the database agent contains all of the information that you need to set the component interface properties.
If the component interface has multiple levels, use the level mapping information in the database agent property dialog box to determine how to handle matching and non-matching rows in the component interface level data.
Use the ItemByKey method to help determine whether you have matching rows.
This PeopleSoft application provides a method for sending email messages from PeopleCode through the Notification application class. The Notification application class can be called from Application Engine PeopleCode or from component, page, and record PeopleCode.
Here are some guidelines for deciding when to use the Notification application class instead of calling a component interface to use TriggerBusinessEvent PeopleCode:
To leverage existing business logic on a page, use a component interface.
If you have already defined a business process, activity, roles, and routing for sending the email message or worklist, use a component interface.
To send an email or worklist notification (for example, if you want to run an Application Engine program that selects the transferred assets and sends an email message to each manager), use the notification application class.
This assumes that the list of user IDs or email addresses to which you want to send the notification is easy to determine in PeopleCode.
This section provides an overview of batch workflow applications and discusses how to:
Create batch workflow applications.
Monitor the database with PeopleSoft Application Engine.
To create batch workflow applications, you must be familiar with PeopleSoft Application Designer, and you must understand how to create Application Engine programs, component interfaces, and workflow applications.
This section provides a high-level overview of the process.
To create batch workflow applications:
Create the workflow application.
Build workflow maps, events, routings, and TriggerBusinessEvent PeopleCode. Everything must be working for a batch program to trigger the workflow event.
Create a new record to use as the state record for the new Application Engine program. This record type can be either derived or a table.
Note. If you are converting a database agent (a technology used in previous PeopleSoft versions), this record contains the database agent input and output fields, that is, the fields on the page where you ran the database agent and the fields that were returned by the database agent query.
Create a new Application Engine program.
Define the state record that you created in step 1 as the default state record for the Application Engine program. Insert a SQL statement to select values from the run control record into the state record. PeopleSoft Application Engine automatically initializes the OPRID and RUN_CNTL_ID fields.
Create a step in the Application Engine program to select data that meets your conditions.
This step consists of a PeopleCode program with a SQL query that selects the data. For example, if you are looking for invoices that are over a month old, write a SQL query to select the appropriate invoices.
You might want to break the SQL query into separate statements if the data is passed to a component interface with multiple levels.
Note. If you are converting an existing database agent (a technology used in previous PeopleSoft versions), in most cases you can paste the SQL from the database agent query into the Application Engine statement with only minor modifications.
Create the component interface for the component with the Workflow PeopleCode.
When you create the component interface, expose the properties that the Application Engine program will update.
Be sure to test the component interface in the interactive environment provided by PeopleSoft Application Designer.
Create an Application Engine step that invokes the component interface once for each row that is returned by the query.
How you invoke the component interface depends on what you’re trying to accomplish. Here are some general guidelines:
Remember the mode that you are using for the component. If you are using Add mode, then use the Create and Save methods on the component interface. If you are using Update/Display mode, use the Get and Save methods on the component interface.
On the Save method, you should record errors to a file or record. Workflow PeopleCode triggers routings when the component successfully saves.
Create a process definition for the new Application Engine program and link to the run control page.
The steps for scheduling an Application Engine program are the same as those for any PeopleSoft Process Scheduler process:
Define a process type definition.
PeopleSoft ships with the process types for PeopleSoft Application Engine already defined, so you can bypass this step.
Create a process definition.
Set up the page and component where users will run the process.
If the program includes runtime bind variables, the page must include fields where users can enter values for the variables.
Users can then schedule the process just as they schedule any process:
Navigate to the page.
Click the Run button to reach the Process Scheduler request page.
Click Run to initiate the process.
Test the application.
To trigger routings based on a nonuser-initiated event:
Write a SQL program that checks the database for data that must be processed.
Put the SQL program into an Application Engine program.
Use PeopleSoft Process Scheduler to schedule the Application Engine program to run on a regular schedule.
When the condition for which you’re checking is true, the Application Engine program sends the data to the component interface, which initiates a workflow event. After you’ve started the Application Engine program, no user intervention is required.