You use Application Engine to develop batch or online programs that perform high-volume background processing against your data.
This chapter discusses:
Application Engine fundamentals.
Meta-Structured Query Language (SQL).
Application Engine program elements.
Application Engine program types.
Application Engine comprises two distinct components—a designer where you define your batch program and the runtime environment where you run and monitor your program.
In Application Engine, a program is a set of SQL statements, PeopleCode, and program control actions that enable looping and conditional logic. A program is defined in Application Designer to perform a business process. You can use Application Engine for straight, row-by-row processing, but the most efficient Application Engine programs are written to perform set-based processing.
Application Engine does not generate SQL or PeopleCode. It runs the SQL and PeopleCode that you include in an Application Engine action as part of your program.
Application Engine is designed for batch processing where you have data that must be processed without user intervention—for example, calculating salaries in payroll processing (although not printing the checks). Another example might be converting money from one currency to another.
You can write SQL within Application Engine, or you can copy SQL statements into Application Engine from any SQL utility with few, if any, changes. This capability enables you to write and fine tune SQL statements before you try to incorporate them into an Application Engine program.
Database platforms can have different syntax rules, especially in regard to date, time, and other numeric calculations. Generally, you can work around syntax differences using PeopleSoft meta-SQL, which Application Engine supports. Meta-SQL is a set of predefined terms (meta-strings) designed to replace relational database management system (RDBMS)-specific SQL syntax with a common syntax.
In addition, PeopleSoft meta-SQL enables you to dynamically generate portions of SQL code. For example, to join two tables based on their common keys, use the following meta-string:
%Join(COMMON_KEYS, PSAESECTDEFN ABC, PSAESTEPDEFN XYZ )
At runtime, the function would be expanded into the following:
ABC.AE_APPLID = XYZ.AE_APPLID AND ABC.AE_SECTION = XYZ.AE_SECTION AND ABC.DBTYPE = XYZ.DBTYPE AND ABC.EFFDT = XYZ.EFFDT
An Application Engine program comprises the set of processes to carry out a given task. It is made up of these key elements:
Sections include one or more steps and are equivalent to a COBOL paragraph or an SQR procedure. All Application Engine programs must contain at least one section entitled MAIN.
A section is a set of ordered steps that is executed as part of a program. You can call sections (and other programs) from steps within other sections.
A program must contain at least one section. Running the program always starts with the section defined as MAIN.
Steps are the smallest unit of work that can be committed within a program. Although you can use a step to execute a PeopleCode command or log a message, typically you use a step to execute a SQL statement or to call another section. The SQL or PeopleCode that a step executes are the actions within the step.
When a section is called, its steps execute sequentially. Every program begins by running the first step of the required section called MAIN and ends after the last step in the last section completes successfully.
You can specify multiple types of actions for inclusion within a step. Multiple actions are commonly associated with a single step.
Do actions contain a SQL Select statement designed to return results on which subsequent actions depend. For instance, if a Select statement returns no rows, then subsequent actions may not need to execute. A Do action is equivalent to a COBOL Perform statement and has similar constructs.
The four types of Do actions are:
Most SQL actions contain a single SQL statement. These actions can perform the following types of SQL statements:
A SQL action differs from a Do action, which also contain SQL, in that the SQL action does not control the flow of the program.
You can include PeopleCode in a PeopleCode action. Application Engine PeopleCode provides an excellent way to build dynamic SQL, perform simple if/else edits, set defaults, and other operations that do not require a trip to the database. It also enables you to reference and change active Application Engine state records.
Most importantly, PeopleCode provides access to the PeopleSoft integration technologies, such as PeopleSoft Integration Broker, Component Interfaces, Business Interlinks, and file processing.
You use a Log Message action to write a message to the message log based on a condition in your program. This functionality gives your program multi-language capability. The system stores the message generically as a message set, message number, and parameter values. When a user views the messages using the Application Engine Message Log page, the system retrieves the appropriate message string from the message catalog based on the user’s language preference.
You can also insert an action that calls another section. The called section can be in the same program as the calling section, or it can be in an external program. This capability enables you to chunk your program into more maintainable, reusable pieces. If a section already exists in one program, then rather than copying it into another program you can just call it.
Note. Application Engine supports up to 99 levels of nested Call Section actions. For example, the first called section can call a second, which can call a third, and so on up to 99 calls.
A state record is a PeopleSoft record that must be created and maintained by the Application Engine developer. This record defines the fields a program uses to pass values from one action to another. Think of the fields of the Application Engine state record as the working storage for your Application Engine program.
An Application Engine state record can be either a physical record or a work record, and you can associate any number of state records with a program. You must key physical state records by process instance.
This section discusses:
Application Engine program types.
Daemon program type.
Transform program type.
Application Engine has five types of programs. You specify the type in the Program Properties dialog box for your program definition. The types are:
Standard, which is a normal entry-point program.
Upgrade Only, which is used in PeopleSoft upgrade utilities.
Import Only, which is used by PeopleSoft import utilities.
Daemon Only, a type of program used as a daemon process.
Transform Only, a program type used to support Extensible Stylesheet Language Transformations (XSLT).
Application Engine provides a daemon process, called PSDAEMON, that runs continuously when PeopleSoft Process Scheduler is running and is intended for recurring jobs. It polls the system, checking for certain conditions to occur. A predefined set of conditions is an event. When the conditions are true, PSDAEMON schedules a process to handle the event.
PSDAEMON supports limited tracing because it runs indefinitely. Specifically, it only allows Application Engine tracing at the step and SQL levels, in addition to the standard PeopleSoft SQL and PeopleCode tracing. It does not support other options, such as Timings and DB Optimizer tracing.
You activate PSDAEMON in PeopleSoft Process Scheduler or from the command line.
Note. One PSDAEMON process can run for each row in the PS_SERVERDEFN table. The PS_SERVERDEFN.DAEMONENABLED field must be set to 1.
Starting PSDAEMON from the Command Line
The command line syntax is:
psdaemon [-CT database_type] [-CD database_name]⇒ [-CO userID] [-CP password] -R server_name
Use the –R option to query PS_SERVERDEFN, obtaining the daemon group, sleep time, and recycle count (terminate after N iterations). Server_name is the key value for PS_SERVERDEFN. You do not need to pass ProcessInstance (–I) or AE Program ID (–AI).
Starting a Daemon Program from PeopleSoft Process Scheduler
Before starting a daemon Application Engine program, you must add the program to the Daemon Group page in PeopleSoft Process Scheduler.
To add a daemon program:
Select PeopleTools, Process Scheduler, Daemon Group.
Select the Add New Value page.
Enter a daemon procedure group name and click Add.
On the Daemon Group page, add the appropriate programs to the program name list.
Restarting the AEDAEMONMGR Program
AEDAEMONMGR is a restartable Application Engine program that commits after each daemon procedure. When PSDAEMON executes, it determines whether it must restart AEDAEMONMGR following an abnormal end to a program.
If a restart is not required, PSDAEMON assigns a new process instance and runs AEDAEMONMGR from the beginning. Because of this design, PeopleSoft Process Scheduler does not have to determine whether PSDAEMON exited due to an error or because it had reached the recycle count.
AEDAEMONMGR uses the Daemon Group page value to get related daemon procedures from PS_DAEMONGROUP in order, and then it initiates each procedure. After all procedures have been executed, AEDAEMONMGR logs a sleep message and returns control to PSDAEMON. The sleep time is used only to log an informational message at the end of each cycle, for example, "Sleeping for N minutes...." It also logs a message at the beginning of each cycle so that an administrator can monitor the runtime and sleep-time of a specific PSDAEMON process.
If an error occurs in AEDAEMONMGR, if the recycle count has been reached, or if PSSERVERSTAT.DAEMONACTION = '1' (indicating that PeopleSoft Process Scheduler is idle), then PSDAEMON exits. Otherwise, it sleeps for the requested number of minutes and then calls AEDAEMONMGR again.
Using PSDAEMON to Start Parallel Processing
Within a daemon group, programs are invoked sequentially and one program does not execute until the previous program has completed. The programs contained in a daemon group should be quick programs that scan information to find events. When an event is discovered, the daemon program can use the ProcessRequest class to invoke programs that are not of the daemon type. These non-daemon type Application Engine programs can execute in parallel. For that reason, do not include application-specific processing in a PSDAEMON type program.
Defining Process Type Definitions
Transform Only type programs enable different systems to communicate with one another by transforming messages into appropriate formats. When you specify an Application Engine program as a Transform Only program, you must specify actions of type XSLT or PeopleCode. You can use transform programs to:
Apply a transformation to a message to make its structure comply with the requirements of the target system.
Perform a data translation on a message so its data is represented according to the conventions of the target system.
Determine whether to pass a message through to its target by filtering it based on its content.
Developing Transform Programs Using PeopleSoft Application Engine