Application Engine


Application Engine : Detailed

Application Engine programs are PeopleSoft's batch processing technology. They are developed using in application designer and consist of blocks of PeopleCode and SQL. Application engine programs can also use application classes, compoonent interfaces, XML publisher reports, and call SQRs and COBOLs through PeopleCode. 

Program Structure

Application engine programs are have very structured hierarchy (loosely based on COBOL). They consist of a single application (application engine program) that can consist of one or more sections. Each section can contain one or more steps, and each step can contain one or more actions. The actions in a step can include:

SQL actions
Do actions
PeopleCode actions
Call Section actions
Log Message actions
Program Properties

There are number of properties associated with an application engine program. These include:

General PeopleSoft object properties
State records
Temporary Tables
Advanced program properties
There several different types of application engine programs:

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).
State Records

A state record is a PeopleSoft record object that contains one or fields used by the program to pass values between steps and actions. Essentially it is a work record for your application to store common variables that can then be used throughout the program. A state record can either be a database table or a PeopleSoft work record. If you make a state record a database table it must be keyed by process instance. Otherwise the state record will not work properly.

Because state records contain process instance, you can use the following SQL action to ge tthe operator ID and run control ID of the person who triggerred the application engine program.

%Select(OPRID,RUN_CNTL_ID)  SELECT OPRID ,RUN_CNTL_ID   FROM PS_AE_REQUEST  WHERE PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE) 
Note %Select and %Bind are special meta SQL elements for working with application engine state records. %Select puts data in the state record and %Bind gets data from the state record. Think Select-In and Bind-Out.

Logging to the Message Log

The PeopleSoft process Scheduler provides access to the message log. The message log is part of the PROCESSMONITOR component - it is defined in the page object PMN_BAT_MSGLOG. You can use log message actions in application engine programs to write to the message log - essentially the PS_MESSAGE_LOG table behind the scenes.

Call Sections

Call sections can be dynamic. To use a dynamic call section:

Add the fields AE_APPLID and AE_SECTION to your state record
In a PeopleCode step, set the value of AE_APPLID to the application engine program name that you are calling. If it is a section in the same application engine program, you can leave this blank and it will default to the current running application engine program
In a PeopleCode step, set the value of AE_SECTION to the section of the application engine program you are calling
Set the dynamic flag check box on the call section step
For a good delivered example, look at the Data Archive application engine program, ARCH_PROCESS. The relevant parts are:

ARCH_PROCESS.MAIN.Step001b
ARCH_PROCESS.MAIN.Step003b
The data archive process application engine can dynamically call application engine programs specified by the user in the data archive configuration template.

Migrating in a Project

One of the problems with application engines is getting all the relevant parts of the application engine into a project.

I've found the following to be the best approach (repeat for each program):

Develop away until you have the application design in place. Don't worry about putting it all into a project at this point. The reason is that you will make mistakes and remove/add/update sections, SQL, PeopleCode etc. Obviously you should have a project that you are doing all this in, just don't worry about getting everything related to the application engine(s) into this project at this point.
When you're satisfied with the final design, do a validate project on your working project. This will clear out all invalid definitions that may have been placed in the project over the time you were working out the design. To do this in application designer, select Tools -> Validate Project.
In application designer select Insert -> Definitions into Project or press CTRL + F7. Select the Application Engine Programs definition type, find your application engine program and select all the related definitions. Press insert. Now check in the upgrade tab to verify that the program, sections, PeopleCode, SQL, records and XSLT are all shown in the upgrade tab.
Make sure that the action flag is set to copy for all relevant definitions and that the upgrade flags are checked.
Migrate your app engine to another environment and confirm everything was copied over and works.