Understanding Application Engine

You use Application Engine to develop batch or online programs that perform high-volume, background processing against your data.

This chapter discusses:

Click to jump to parent topicApplication Engine Fundamentals

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 and performs 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 executes 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.

Click to jump to parent topicMeta-SQL

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 enables you to write and 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

Click to jump to parent topicApplication Engine Program Elements

A Application Engine program comprises the set of processes to execute a given task. It is made up of these key elements:

Click to jump to top of pageClick to jump to parent topicSections

Sections comprise 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. The execution of the program always starts with the section defined as MAIN.

Click to jump to top of pageClick to jump to parent topicSteps

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 executing the first step of the required section called MAIN and ends after the last step in the last section completes successfully.

Click to jump to top of pageClick to jump to parent topicActions

You can specify multiple types of actions for inclusion within a step. Multiple actions are commonly associated with a single step.

Do Actions

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:

SQL

Most SQL actions contain a single SQL statement. These actions can perform the following types of SQL statements:

PeopleCode

You can include PeopleCode in the 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.

Log Message

You use a Log Message action to write a message to the message log based on a condition in your program. This gives your program multilanguage 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.

Call Section

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 enables you to chunk your program into more maintainable, reusable pieces. If a section already exists in one program, rather than copying it into another program, 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.

Click to jump to top of pageClick to jump to parent topicState Records

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 any number of state records can be associated with a program. Physical state records must be keyed by process instance.

Click to jump to parent topicApplication Engine Program Types

This section discusses:

Click to jump to top of pageClick to jump to parent topicApplication Engine Program Types

Application Engine has five types of programs. You specify the type in the Program Properties dialog box for your program definition. The types are:

Click to jump to top of pageClick to jump to parent topicDaemon Program Type

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. Other options, such as Timings and DB Optimizer tracing, are not supported.

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:

  1. Select PeopleTools, Process Scheduler, Daemon Group.

  2. Select the Add New Value page.

  3. Enter a daemon procedure group name, and click Add.

  4. 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, which commits after each daemon procedure. When the 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...". A message is also logged at the beginning of each cycle, so 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), 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.

See Also

Defining Process Type Definitions

Click to jump to top of pageClick to jump to parent topicTransform Program Type

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 do any of the following:

See Also

Developing Transform Programs Using PeopleSoft Application Engine