peoplesoft application engine rel 8 - javeriana · designer, an intuitive graphical interface, to...
TRANSCRIPT
PeopleSoft Application EngineRel 8.50
Student Guide
D60579GC11
1.1
October 2010
D69310
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.
The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free.
If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS
The U.S. Government's rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
iii
Contents
Lesson 1Course Overview ............................................................................................................................................. 1Agenda ............................................................................................................................................................... 2
Lesson 2Technology Overview ...................................................................................................................................... 7Describing Application Engine Features ........................................................................................................... 8Describing Application Engine Benefits ......................................................................................................... 10Finding Information About PeopleSoft Application Engine in PeopleBooks ................................................ 21
Lesson 3Introducing Application Engine Designer .................................................................................................. 25Describing Student Workstation Resources .................................................................................................... 26Running an Application Engine Program ....................................................................................................... 29Activity 1: Running PSU_INACT_1 .............................................................................................................. 34Using Application Engine Designer ................................................................................................................ 39Activity 2: Preparing Your Application Designer Project .............................................................................. 44Describing Application Engine Program Structure ......................................................................................... 47Building Application Engine Programs .......................................................................................................... 59Activity 3: Inserting Sections, Steps, and Actions .......................................................................................... 61Adding Markets and Filters to Application Engine Program Sections ........................................................... 65Activity 4: Adding Market-Specific Sections ................................................................................................. 68Setting Application Engine Program Properties ............................................................................................. 73Activity 5: Creating the Application Engine Program PSU_STK_INC ......................................................... 76Testing Application Engine Programs ............................................................................................................ 81Activity 6: Testing your Application Engine Program ................................................................................... 84
Lesson 4Using State Records ....................................................................................................................................... 89Describing the Function of State Records ....................................................................................................... 90Creating a State Record ................................................................................................................................... 92Running an Application Engine Program Using the Developer's Shortcut .................................................. 102Activity 7: Passing Information to Programs Using a State Record ............................................................. 105Modifying Application Engine Programs to Use State Records ................................................................... 110Activity 8: Adding a State Record to PSU_STK_INC .................................................................................. 111Adding Sections and Steps to Existing Application Engine Programs ......................................................... 115Activity 9: Adding a Log Message to PSU_CUST_CHG ............................................................................ 119
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Contents
iv
Using Meta-SQL in Application Engine Programs ....................................................................................... 124Activity 10: Adding %SQL Meta-SQL to PSU_CUST_CHG ...................................................................... 126
Lesson 5Testing and Debugging ............................................................................................................................... 133Testing Application Engine Programs .......................................................................................................... 134Using Process Monitor .................................................................................................................................. 135Using Application Engine Traces .................................................................................................................. 140Activity 11: Tracing PSU_CUST_CHG ....................................................................................................... 144Using the Application Engine Debugger ....................................................................................................... 151Activity 12: Debugging PSU_CUST_CHG .................................................................................................. 154Testing with Application Engine Restart ...................................................................................................... 157Activity 13: Testing Restart Using AETESTPROG .................................................................................... 161
Lesson 6Using the Do Select Action .......................................................................................................................... 169Describing Do Select .................................................................................................................................... 170Using Select and Fetch .................................................................................................................................. 177Activity 14: Examining PSU_ARCH_SF with Select/Fetch ........................................................................ 180Using Reselect ............................................................................................................................................... 186Activity 15: Examining PSU_ARCH_RL using Reselect ............................................................................ 188Using Restartable .......................................................................................................................................... 194Activity 16: PSU_ARCH_RB Using Restartable ......................................................................................... 199Developing an Application Engine Program Using Do Select ..................................................................... 207Building PSU_CRS_INS ............................................................................................................................... 212Activity 17: Creating PSU_CRS_INS ........................................................................................................... 220
Lesson 7Incorporating Conditional Processing ....................................................................................................... 229Defining Do Actions ..................................................................................................................................... 230Explaining Conditional Statements in SQL .................................................................................................. 236Explaining Do Action Program Flow ............................................................................................................ 240Designing a Program Using Conditional Processing ................................................................................... 242Activity 18: Building the WAITLIST program ............................................................................................ 252Using Application Engine Libraries .............................................................................................................. 260Activity 19: Creating an Application Engine Library ................................................................................... 262
Lesson 8Using PeopleCode with Application Engine ............................................................................................. 269Identifying How to use PeopleCode in Application Engine Programs ........................................................ 270Inserting PeopleCode into an Application Engine Program ......................................................................... 272
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Contents
v
Activity 20: Adding PeopleCode to the WAITLIST Program ..................................................................... 282Enabling Dynamic Calls ................................................................................................................................ 286Activity 21: Examining PSU_INACT_3 ....................................................................................................... 289Activity 22: Modifying the WAIT_PCODE Program to use Dynamic Call. ................................................ 293
Lesson 9Using Set Processing .................................................................................................................................... 299Describing Set Processing ............................................................................................................................. 300Modifying a Program to use Set Processing ................................................................................................. 305Activity 23: Creating the WAIT_SET program ............................................................................................ 312
Lesson 10Using Temporary Tables ............................................................................................................................ 321Describing Parallel Processing ...................................................................................................................... 322Implementing Parallel Processing ................................................................................................................. 330Activity 24: Adding a Temporary Table to PSU_CUST_CHG .................................................................... 343Using Meta-SQL with Parallel Processing .................................................................................................... 347Activity 25: Examining Parallel Processing with AETESTPROG ............................................................... 351Describing Run-Time Allocation .................................................................................................................. 357Activity 26: Modifying WAIT_SET to Use Temporary Tables ................................................................... 362
Lesson 11Executing Application Engine Programs .................................................................................................. 369Listing Ways to Execute Application Engine Programs ............................................................................... 370Activity 27: Launching a Process with a Push Button .................................................................................. 378Executing an Application Program with the Process Scheduler .................................................................. 382Executing an Application Engine Program with a Command Script ........................................................... 387Activity 28: Executing PSU_PROC_ORD with a Command Script ............................................................ 389
Lesson 12Creating Process Definitions for Application Engine .............................................................................. 393Identify the Process Types used with Application Engine ............................................................................ 394Creating Application Engine Process Definitions ......................................................................................... 396Implementing an Application Engine Program with No User Inputs ........................................................... 400Activity 29: Implementing the WAITLIST Program .................................................................................... 403Implementing an Application Engine Program With User Inputs ................................................................ 408Activity 30: Implementing WAIT_SET ........................................................................................................ 413
Lesson 13Using PSDAEMON ..................................................................................................................................... 423
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Contents
vi
Describing PSDAEMON .............................................................................................................................. 424Describing a Daemon-Only Application Engine Program ............................................................................ 425Defining Daemon Groups ............................................................................................................................. 428Monitoring a Daemon Process ...................................................................................................................... 432Activity 31: Creating a Daemon Group and Tracking Daemon Activity ...................................................... 435Activity 32: Creating PSU_ENR_STU as a Daemon Process ...................................................................... 440
Lesson 14Measuring Application Engine Performance ........................................................................................... 447Describing Traces .......................................................................................................................................... 448Passing Trace Values to PSAE.EXE ............................................................................................................. 452Activity 33: Tracing Application Engine Programs ...................................................................................... 460Interpreting Application Engine Trace Data ................................................................................................. 465Activity 34: Interpreting the WAITLIST Trace File ..................................................................................... 482Interpreting the PeopleTools Trace ............................................................................................................... 484Describing Advanced Trace Options ............................................................................................................ 490
Lesson 15Tuning Application Engine Programs ....................................................................................................... 497Describing the Process of Performance Tuning ........................................................................................... 498Identifying Application Level Tuning Opportunities .................................................................................... 502Explaining the Performance Impact of PeopleCode ..................................................................................... 512Activity 35: Tuning PERF_TUN ................................................................................................................. 514Describing How Do Flow Control Affects Program Performance ............................................................... 523Activity 36: Examining Loop Performance with DO_LOOP_TST .............................................................. 526Explaining Database-Level Tuning Considerations ...................................................................................... 531Activity 37: Tuning EMPL_INC ................................................................................................................... 535
Lesson 16Final Course Activity .................................................................................................................................. 541Activity 38: Creating the LOAD_STU_CRS Application Engine Program ................................................. 542
Lesson 17Course Review ............................................................................................................................................. 553........................................................................................................................................................................ 554
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
1
Lesson 1
Course Overview
Note. The appearance of the page shots in the guide may not always match the training environment. This is due to updates that have been applied to the training environment after the course guide was released. The functionality of the software has not changed.
Objectives
By the end of this course, you will be able to:
• Describe Application Engine.
• Use the Application Engine Designer to write, test, and debug Application Engine programs.
• Develop robust Application Engine programs.
• Schedule the automatic execution of Application Engine programs.
• Monitor and tune Application Engine performance.
• Develop and test an Application Engine program.
Slide 3
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Course Overview Lesson 1
2
Agenda
Day 1
On day one, we will provide an overview of Application Engine and discuss these topics:
• Using Application Engine Designer.
• Using state records.
• Testing and debugging.
Slide 4
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 1 Course Overview
3
Agenda (continued)
Day 2
On day two, we will discuss these topics:
• Using the do select action.
• Incorporating conditional processing.
• Using PeopleCode with Application Engine.
• Using set processing.
Slide 5
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Course Overview Lesson 1
4
Agenda (continued)
Day 3
On day three, we will discuss these topics:
• Using temporary tables.
• Executing Application Engine programs.
• Creating process definitions for Application Engine.
• Using PSDaemon.
Slide 6
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 1 Course Overview
5
Agenda (continued)
Day 4
On day four, we will discuss these topics:
• Measuring Application Engine performance.
• Tuning Application Engine programs.
• Final course activity.
• Course review.
Slide 7
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
7
Lesson 2
Technology Overview
Objectives
By the end of this lesson, you will be able to describe:
• Application Engine features.
• Application Engine benefits.
• Finding Information About PeopleSoft Application Engine in PeopleBooks.
Slide 9
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
8
Describing Application Engine Features
Tool For Batch Processing
Application Engine is a tool used for batch processing where data needs to be processed without user intervention.
Examples in PeopleSoft include:
• Calculating the salaries in payroll processing.
• Currency conversion.
• Dispatching purchase orders.
Application Engine comprises two distinct areas:
• Front end, where you define your batch program.
• Back end, where you run and monitor your program.
Slide 10
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
9
Describing Application Engine Features (continued)
Shell to Execute Business Logic
Application Engine is a shell to execute business logic:
• The front end uses Application Designer to define and maintain an Application Engine program.
• The back end is the PeopleTools executable that runs the Application Engine program.
An Application Engine program is a set of SQL statements, PeopleCode, and program control actions that performs a business process.
Application Engine Programs can perform row-by-row processing, or use set-based processing.
Application Engine does not generate SQL or PeopleCode.
Slide 11
Student Notes
Application Engine Program
In the realm of Application Engine, a program is a set of SQL statements, PeopleCode, and program control actions (which allow looping and conditional logic) defined in Application Designer that 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's execution component is written in standard C++ and is part of-and maintained by-PeopleTools. This executable program is called PSAE.exe. It interprets and executes your requests for processing that you have defined and written as your Application Engine program. You build your program with the Application Designer graphic developer interface and the program is stored in PeopleTools tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
10
Describing Application Engine Benefits
Benefits
There are several benefits to developing a program using Application Engine, instead of COBOL or SQR:
• Graphical Development Tool
• Program Encapsulation
• Data Dictionary Integration
• Enhanced SQL/Meta-SQL Support
• Effective Dating
• Reuse Business Logic
• Upgrade Support
Slide 12
Student Notes
Benefits
More benefits to using Application Engine include:
• Built-In Restart Logic or Rerun Logic
• Debugger and Traces
• Temporary Table Management for Parallel Processing
• Event Driven Logic i.e. Daemon Processing
• Tuning Utilities
• Commit Level Flexibility
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
11
Describing Application Engine Benefits (continued)
Graphical Development Tool.
Allows easy access to the PeopleCode and SQL editors.
Provides two views of your program.
Slide 13
Student Notes
PeopleTools Integration
Application Engine is now fully integrated with PeopleTools. This means that you use the Application Designer, an intuitive graphical interface, to create your Application Engine program.
Application Designer offers Application Engine developers the following benefits:
• Easy access to the PeopleCode and SQL editors.
• Two views of your program:
The Definition view is where you create and modify your programs.
The Program Flow view allows you to see the actual order in which your program will execute the statements.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
12
Describing Application Engine Benefits (continued)
Program Encapsulation
Application Engine programs reside completely within your database.
Application Engine programs do not require compilation.
There is no direct interaction with the operating environment.
Application Engine programs are developed within the Application Designer.
Programs can be run and debugged without exiting PeopleTools.
Slide 14
Student Notes
Program Encapsulation
Applications developed using COBOL or SQR must have elements that are stored on the host system where they will be run, which must be managed independently of the PeopleSoft elements. As Application Engine programs are stored in the database, this additional level of maintenance is avoided.
No statements need to be stored, nor is any other direct interaction with the operating environment required. Application Engine Programs run entirely within the PeopleSoft server framework, and need no customization when migrated across database or operating system platforms.
Application Engine programs are developed from scratch, including the table definitions, within Application Designer.
Application Engine programs can be designed to be independent of any database platform or operating system.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
13
Describing Application Engine Benefits (continued)
Data Dictionary Integration
Application Engine responds to changes in field attributes.
Definitions are global across the database.
Typically, no PeopleCode program changes are required when definitions are modified.
Slide 15
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
14
Describing Application Engine Benefits (continued)
Enhanced SQL and Meta-SQL Support.
You can write your SQL within Application Engine.
You can copy SQL statements into Application Engine from any SQL utility.
SQL statements can be written and tuned before incorporation in Application Engine.
Using PeopleSoft meta-SQL prevents issues with database platform specific SQL syntax.
Conversely, database platform specific SQL can be used to tune performance.
Slide 16
Student Notes
MetaSQL
Relational Database Management System (RDBMS) platforms have many differing syntax rules-especially inregard to date, time, and other numeric calculations. Using PeopleSoft meta-SQL in Application Engine will work around these issues when an Application Engine program migrates from one host environment to another. MetaSQL is designed to replace RDBMS-specific SQL syntax with a standard syntax.
Conversely, RDBMS platform specific SQL can be used to tune performance. (For example, P/L SQL, execution plan hints, etc.)
Examples:
• You can think of Meta-SQL as shorthand to make a statement platform specific. The platform you are running on is determined by the PeopleSoft log in. The meta-SQL is resolved for that platform at runtime:
SELECT %DateOut(START_DT) FROM PS_CRS_SESSN
Resolves to for SQL Developer:
SELECT (CONVERT(CHAR(10) ,START_DT ,121)) FROM PS_CRS_SESSN
• Meta-SQL also has functions that let you dynamically generate portions of your SQL statements:
%Join(COMMON_KEYS, PSAESECTDEFN A, PSAESTEPDEFN B )
At runtime, the function would be expanded into the following:
A.AE_APPLID = B.AE_APPLID AND A.AE_SECTION = B.AE_SECTION AND A.DBTYPE = B.DBTYPE AND A.EFFDT = B.EFFDT
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
15
• Meta-SQL gives you platform independence. To get the current date from the RDBMS, %CURRENTDATEOUT will work across platforms, as opposed to coding GETDATE(AE_DATE) for MSSQL Server or SYSDATE for other platforms.
Note. As we go through this course we will show examples of using meta-SQL in Application Engine programs.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
16
Describing Application Engine Benefits (continued)
Effective Dating
Application sections are effective-dated.
Only current, active sections will execute.
History sections can be made current by changing the effective date.
Slide 17
Student Notes
Effective Dating
Application sections are effective-dated, meaning you can activate or deactivate a section as of a particular date. The modified sections will become active automatically at the specified date without any direct action.
For example:
You create a new Application Engine program on January 1.
You then make some modifications to the program, add additional sections and date them for June 1 later the same year. When today's date reaches June 1, the new sections will start executing automatically.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
17
Describing Application Engine Benefits (continued)
Reuse Business Logic
Application Engine programs can invoke PeopleCode.
Application Engine libraries can store common routines as callable sections.
Multiple programs can use callable sections.
PeopleCode can call an Application Engine program.
Slide 18
Student Notes
Reuse Business Logic
A common goal for all programmers is to make code as reusable as practical. By taking advantage of the features of PeopleCode, combined with callable sections of other Application Engine programs, a developer can take advantage of existing code, potentially saving hundreds of hours of work.
If you have conditional processing written in an Application Engine program that needs to be used in PeopleCode, you can call the Application Engine program using the CallAppEngine function.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
18
Describing Application Engine Benefits (continued)
Upgrade Support
Application Engine programs are PeopleTools definitions.
Application Engine programs may be inserted into a project. Thus all related definitions affected by a change could be included.
Application Engine definitions may be upgraded by project, program, or section.
Slide 19
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
19
Describing Application Engine Benefits (continued)
Built-in Restart Logic
An Application Engine program can be designed to be restarted after an error.
A Restart mechanism is built into the application.
The Restart mechanism avoids duplicate processing and data corruption.
Overall impact on other users and processes while the background program is running is reduced.
Slide 20
Student Notes
Restart Logic
Within each Application Engine program, you must define how frequently your program will issue a commit. After doing so, each commit becomes a checkpoint that Application Engine uses to locate where within a program to restart after an abend (abnormal end).
With PeopleSoft, a checkpoint in an Application Engine program is the point at which restart information is written out to the PS_AERUNCONTROL table. This is used with restartable programs to allow them to determine where to pick up processing when they resume after a failure
Abends
Abends can be controlled or uncontrolled.
A controlled abend means that Application Engine exits gracefully because of a calculated error condition. Some examples of controlled abends are:
• SQL errors while you have set On Error = Abort.
• PeopleCode return value of if On Return = Abort.
• SQL statement affects no rows and you have set No Rows = Abort.
In these situations (when Application Engine is in control) the Run Status in Process Monitor reads "No Success". An uncontrolled abend occurs in situations where there is a memory violation or a user kills a process. In these cases, the Run Status in Process Monitor shows "Processing".
When restarted, an Application Engine program locates the last checkpoint, or the last successfully executed and committed step, and continues processing from that point.
With COBOL or SQR, restart requires manually rolling back to a known state before re-running a process after correcting an error. Otherwise, duplicate processing may occur and or the creation of inaccurate data. These processes must be restarted manually.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
20
Application Engine's restart capabilities affect the design and performance of an Application Engine program.Having restart functionality allows more frequent commits, without the added burden of coding additional restart logic.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
21
Finding Information About PeopleSoft Application Engine in PeopleBooks
PeopleBooks
Use the Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine to find Application Engine development information including:
• Planning Application Engine program development.
• Running Application Engine programs.
• Troubleshooting and debugging.
Slide 21
Student Notes
Additional Information
This table lists the locations of additional information in PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine.
Location Type of Information
Using PeopleSoft Application Engine
This chapter provides general usage information.
Development chapters These chapters discuss development concepts and tasks:
• "Creating Application Engine Programs"
• "Developing Efficient Programs"
• "Using Meta-SQL and PeopleCode"
• "Managing Application Engine Programs"
• "Calling Application Engine Programs from COBOL"
• "Tracing Application Engine Programs"
• "Using Temporary Tables"
You can access related material by clicking the Help link in the top, right corner of the application page. This automatically takes users to the relevant information in the appropriate PeopleBook.
Note. Context-sensitive help is constrained to non-application specific pages in the technical database.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
22
Finding Information About PeopleSoft Application Engine in PeopleBooks (continued)
Additional PeopleBooks
The following PeopleBooks contain information that applies to PeopleSoft Application Engine 8.50:
• Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine
• Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Designer Lifecycle Management Guide
• Enterprise PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide
• Enterprise PeopleTools 8.50 PeopleBook: PeopleCode Language Reference
• Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler
• Enterprise PeopleTools 8.50 PeopleBook: System and Server Administration
• Enterprise PeopleTools 8.50 PeopleBook: Data Management
Slide 22
Student Notes
Additional PeopleBooks
This table describes the additional PeopleBooks that contain information about PeopleSoft Application Designer and application development using PeopleTools.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 2 Technology Overview
23
PeopleBook Description
Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine
This PeopleBook describes Application Engine.
Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Designer Lifecycle Management Guide
This PeopleBook describes the fundamental elements of developing applications for PeopleSoft Internet Architecture.
Enterprise PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide
This PeopleBook covers the concepts of PeopleCode, tips for using PeopleCode, the interaction of PeopleCode and the Component Processor, and a number of other specialized topics, such as the use of the PeopleCode debugger and referencing data in the component buffer.
Enterprise PeopleTools 8.50 PeopleBook: PeopleCode Language Reference
This PeopleBook is a complete reference to PeopleCode, the proprietary language used in the development of PeopleSoft applications. Its chapters describe the syntax and fundamental elements of the PeopleCode language.
Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler
This PeopleBook describes Process Scheduler, a centralized tool that enables application developers, system administrators, and application users to manage PeopleSoft batch processes.
Enterprise PeopleTools 8.50 PeopleBook: System and Server Administration
This book includes several chapters relating to administration tools for the PeopleSoft application server, web servers including BEA's WebLogic and IBM's WebSphere. It also contains information about building and maintaining search indexes.
Enterprise PeopleTools 8.50 PeopleBook: Data Management
This PeopleBook includes information about Configuration Manager.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Technology Overview Lesson 2
24
Review
In this lesson you learned how to describe:
• Application Engine features.
• Application Engine benefits.
• Finding Information About PeopleSoft Application Engine in PeopleBooks.
Slide 23
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
25
Lesson 3
Introducing Application Engine Designer
Objectives
By the end of this lesson, you will be able to:
• Describe student workstation resources.
• Run an Application Engine program.
• Use Application Engine Designer.
• Describe Application Engine program structure.
• Build Application Engine programs.
• Add markets and filters to Application Engine programs.
• Set Application Engine program properties.
• Test Application Engine programs.
Slide 25
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
26
Describing Student Workstation Resources
Standard Software
You will use several standard software packages :
• Microsoft Internet Explorer.
• Application Designer.
• Configuration Manager.
• DataMover.
• psadmin.exe.
• Oracle SQL Developer.
Slide 26
Student Notes
Software
In this class, you will use:
• Application Designer 8.50
• Configuration Manager
• DataMover
• psadmin.exe
Some activities will use SQL Developer for examining tables. It is available through the Start menu.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
27
Describing Student Workstation Resources (continued)
Activity Files
To aid you in completing the activities, files are stored on the workstation in the 0411_AppEngine directory:
• \BAT
• \Files
• \Projects
• \Scripts
• \SQL
Slide 27
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
28
Describing Student Workstation Resources (continued)
PeopleBooks
The PeopleBooks library is your primary reference source for details about Application Engine and other PeopleTools, as well as all PeopleSoft applications.
Slide 28
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
29
Running an Application Engine Program
Launching an Application Engine Process
Launching an Application Engine process has three basic steps:
1. Navigate to the component to launch the process, and select it.
2. Monitor the progress of the process.
3. Retrieve log information to check results.
Slide 29
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
30
Student Notes
Pages Used to Launch and Monitor Application Engine Processes
Page Name Navigation
Prcsruncntl Select Courses, Process Course Information, Inactivate Rel 6 Courses.
Process Scheduler Request Click the Run button on the Run Control (Prcsruncntl) page.
Process Monitor Click the Process Monitor link on the Run Control page.
Details Click the Details link on the Process Monitor page.
• Use the Process Run Control page (Prcsruncntl) to launch a process.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
31
• Use the Process Scheduler Request page to specify parameters and select processes to run.
• Use the Process Monitor page to view all processes run by a particular user.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
32
• Use the Process Details page to view details, such as request parameters and message logs.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
33
• Use the View Log/Trace page to view the message log and trace file.
• Use the Message Log page to see information about the process run.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
34
Activity 1: Running PSU_INACT_1In this activity you will review the activity overview and:
1. Use SQL Developer to examine the contents of PS_PSU_COURSE_TBL.
2. Navigate to the component to run the Application Engine program.
3. Monitor processing status with Process Monitor.
4. View the program log when processing is complete.
5. Confirm changes to the table using SQL Developer.
Slide 30
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
35
Activity OverviewIn this course, you will be using some applications that have been set up for the Training environment. These applications are not delivered PeopleSoft products; they are used just for educational purposes.
One of the tables you will be using is the PS_PSU_COURSE_TBL. This table stores course information. Once a particular course is no longer offered, the status is changed to Inactive. The Application Engine program that you run in this activity, PSU_INACT_1, will inactivate all courses for Tools Release 6.
Before running the program, you will check the rows in PS_PSU_COURSE_TBL. After you run the process, you will check this table again to see the changes made by the program.
Note. In All Activities: Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
36
Activity Detailed StepsPerform the detailed steps to complete the activity.
Using SQL Developer to Examine the Contents of PS_PSU_COURSE_TBL
To examine the contents of PS_PSU_COURSE_TBL:
1. Double-click SQLDeveloper.exe in the desktop.
2. Expand the node T1B85001_SYSADM to connect.
Note. If prompted for sign-in, use sysadm/sysadm as userid/password and select the database name..
3. Enter the following SQL in the SQL developer:
SELECT * FROM PS_PSU_COURSE_TBL WHERE TOOLS_REL = 600
4. Run the SQL either by pressing the F5 key or by clicking the green arrow on the Icon bar.
Question Answer
How many rows were returned?
What is their effective status (EFF_STATUS)?
Navigating to the Component to Run the Application Engine Program
To run the Application Engine program:
1. Sign in to the browser.
a. Double-click the Oracle PeopleSoft Enterprise 8 sign-in shortcut on the desktop.
b. Sign in with the user ID PTTRA and password PTTRA.
2. Navigate to the program launch page by selecting Courses, Process Course Information, Inactivate Rel 6 Courses.
3. On the search page, select the Add a New Value tab.
4. For the run control ID, enter Training.
5. Click Add.
The process run control page appears.
6. Click the Run button.
7. On the Process Scheduler Request page, accept the defaults.
8. Click OK. The process is submitted, and you are returned to the program launch page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
37
Monitoring Processing Status with Process Monitor
To access Process Monitor:
1. From the run control page, click the Process Monitor link.
Alternatively, select PeopleTools, Process Scheduler, Process Monitor.
2. Note the Run status.
3. Click Refresh to update the status until the status is Success.
Viewing the Program Log When Processing Is Complete
To view the program log:
1. In Process Monitor, click the Details link at the end of the line for your process.
2. On the Process Detail page, click the View Log/Trace link.
3. On the View/Log Trace page, click the Message Log link.
Here you see the status messages that were generated when the Application Engine program ran.
Confirming Changes to the Table Using SQL Developer
To view the changes made by the program using SQL Developer:
1. If you have closed SQL Developer, follow the preceding steps to reopen it.
If your SQL Developer is still running, return it to the foreground, and rerun the SQL statement:
SELECT * FROM PS_PSU_COURSE_TBL WHERE TOOLS_REL = 600
2. Compare your SQL Developer output with the following results.
Results
These are the rows returned from PSU_COURSE_TBL after you run PSU_INACT_1.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
38
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
39
Using Application Engine Designer
Application Engine Designer
Application Engine programs are made up of one or more sections:
• Each section has one or more steps.
• Each step contains one or more actions.
• An action may contain SQL, PeopleCode, or program flow instructions.
Slide 31
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
40
Student Notes
Definitions Used to Demonstrate Application Engine Designer
Definition Name Navigation
PSU_AEClass 1. Select File, Open.
2. Definition Type: Project
3. Name: PSU_AECLASS
4. Click. Open
PSU_INACT_1 1. In the Project Workspace, click the + icon next to the Application Engine folder.
2. Double-click the program named PSU_INACT_1.
3. Select the Program Flow tab in Application Engine Designer.
• Application Engine Designer is integrated into Application Designer.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
41
• Application Engine programs are made up of sections, steps, and actions.
• The Application Engine Designer has two displays: Definition and Program Flow.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
42
Using Application Engine Designer (continued)
Application Engine Designer Toolbar
The toolbar provides convenient access to Application Engine Designer functions.
Slide 32
Student Notes
Application Engine Designer Controls
Application Engine Designer controls are available through:
• The Application Designer menu.
• The Application Designer toolbar.
• Context-sensitive pop-up menus.
Example: Pop-Up Menu
Right-click within an Application Engine definition to display a context-sensitive pop-up menu. Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
43
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
44
Activity 2: Preparing Your Application Designer ProjectIn this activity, you will review the activity overview and prepare your Application Designer project for the activities that you will be doing in this course.
Slide 33
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
45
Activity OverviewIn this activity, you will put some Application Designer settings in place to support classroom activities.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
46
Activity Detailed StepsPerform the detailed steps to complete the activity.
Preparing Your Application Designer Project
In this task you will set up tools options that determine what project is open when Application Designer is launched, and how PeopleTools objects will be managed as you create or change them.
To prepare your Application Designer project:
1. Open the PeopleTools folder on the desktop.
2. Double-click the Application Designer shortcut.
3. Sign in using the user ID PTTRA and password PTTRA.
4. Select File, Open.
a. For Definition, select Project.
b. For Name, enter PSU_AECLASS.
c. Click Open.
5. Select Tools, Options.
6. Select the Project tab, if it is not already visible.
7. Select the following options:
• Insert Definitions into Project: When definition is modified and saved, or deleted.
• Related Definitions Options: Do not insert definitions with current definitions.
• Reload last project at startup.
8. Click OK.
9. Select File, Save All.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
47
Describing Application Engine Program Structure
Application Engine Structure
Slide 34
Student Notes
Application Engine Structure
An Application Engine program identifies the set of processes to perform a given task. A program must contain at least one section.
The tasks are organized hierarchically by section, step, and action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
48
Describing Application Engine Program Structure (continued)
Application Engine Program Execution
Slide 35
Student Notes
Sections
A section is a set of steps that are performed as part of a program. A section comprises one or more steps and is equivalent to a COBOL paragraph or an SQR (Structured Query Report) procedure. You can call sections (and other programs) from steps within other sections. All Application Engine programs must contain at least one section entitled MAIN. The running of the program always starts with the MAIN section. (Application Engine libraries do not contain a MAIN section, but they are not directly executable. Libraries contain sections that must be called from another Application Engine program.)
Steps
A step is the smallest unit of work that can be performed within a program. It contains one or more actions that run SQL, PeopleCode, or a program flow action. When a section is called, its steps are performed sequentially. Every program begins by performing the first step of the required section called MAIN and endsafter the last step in the last called section finishes.
Actions
Multiple types of actions can be specified within a step. Multiple actions are commonly associated with a single step. Actions will be explained in more detail when in more advanced topics related to building Application Engine programs.
Example: Application Engine Program
This example, the PSU_INACT_1 Application Engine program, consists of one section, MAIN, which contains two steps, each containing one action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
49
• Step01 in the MAIN section contains a SQL step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
50
• Step02 in the MAIN section contains a Log Message step.
• The Log Message in this action writes the message Process Completed to the log file.
Example: Message Catalog
That message is retrieved from the Message Catalog.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
51
Describing Application Engine Program Structure (continued)
Application Engine Section Characteristics
An application Engine section:
• Is callable.
• Is run only when called, except for MAIN.
• Contains one or more steps.
• Can be configured to specify market, effective date, effective status, and platform.
Slide 36
Student Notes
Example: Application Engine Section
An Application Engine section can be configured using drop-down list boxes. To view the comments section, select View, Show All Comments (F2), or right-click and select Show Comment.
This table describes each field and its contents.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
52
Section Name You cannot change the name of the section MAIN. Every executable program needs a section called MAIN. This is how PSAE.exe knows where to start. All other sections are named Section1, Section2, and so on. The name should be changed to something more descriptive, but be careful because an 8-character limit is placed on this field.
Description Describe what the section is for; 30 characters are allowed.
Market Students can use the drop-down list box to see the markets. This uses the 3-character translate values. The default value is GBL.
Platform One of the benefits of Application Engine is to run the program on any platform. You can code sections for specific platforms. The default value is Default.
Effective Date You can future-date sections. This enables you to keep the older versions of the sections. The default value is 01 Jan 1900.
Effective Status ACTIVE or INACTIVE.
Section Type These values are discussed in the section about talk about restarts.
Auto Commit You can specify when data is committed to the database. This is important when aprogram ends abnormally and needs to be rerun or restarted. You need to know what was committed. The default is only one commit at the end of the program.
Access Controls whether this section can be called from another program. Application Engine libraries are discussed in a later lesson. Making a section public allows thesection to be called from another program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
53
Describing Application Engine Program Structure (continued)
Application Engine Step Characteristics
An Application Engine step:
• Is a logical grouping of actions.
• Contains one or more actions.
• Is the smallest unit of work that can be committed.
• Is performed from top to bottom within a section.
Slide 37
Student Notes
Example: Application Engine Step
Here is an example of a step.
This table describes the elements of a step.
Step Name Steps are consecutively numbered based on the last step name. 8 characters available.
Step Description Enter a descriptive name for the step. 30 characters available.
Sequence Number (Located at the left, below the step name.) This number shows the exact order in which the step will be performed.
Commit After Specify when a commit will be performed. Values are:
Default: Use value supplied for the section.
Later: Do not commit now.
After step: Commit when step finishes.
Frequency This is available only in loops. It is covered in more detail later.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
54
On Error Determines the action to take when an error occurs. Values are:
Abort: The program writes a message to the message log and terminate.
Ignore: The program writes a message to message the log and continues
Suppress: No message is written, but the program continues. The program ending causes a rollback to occur.
Active Determines whether the step is active (selected) or inactive (cleared).
Comment Add any additional comments to document your program. (As with Section comments, this is accessed by F2, View, or Show All Comments.)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
55
Describing Application Engine Program Structure (continued)
Application Engine Action Characteristics
An action is an Application Engine line of code.
Nine possible actions are available.
The two general types are:
• Data manipulation.
• Program flow.
Actions must be unique within a step.
Actions are performed top down.
Slide 38
Student Notes
Example: Application Engine Action
Here is an example of an action.
SQL Action
A SQL action has a No Rows setting to determine how to deal with a situation in which no rows are affected by a SQL statement.
The options are:
• Abort. Terminates the program.
• Section Break. Exits the current section and returns control to the calling step.
• Continue. Continues processing.
• Skip Step. Exits the current step immediately and proceeds to the next step.
• Application Engine ignores the commit for the current step at runtime.
• If the current step contains only one action, use only Skip Step to bypass the commit.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
56
Describing Application Engine Program Structure (continued)
Application Engine Program Structure Summary
This table gives a summary of Application Engine program composition.
Application Section Step Action
Application Engine Program
Callable block of logic. Logical grouping of actions.
Lines of code.
Slide 39
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
57
Describing Application Engine Program Structure (continued)
Application Engine Program Structure Summary (continued)
This table gives a summary of Application Engine program composition.
Application Section Step Action
Composed of one or more sections
Composed of one or more steps.
Specified by:
• Market.
• Effective date.
• Effective status.
• Platform.
Composed of one or more actions.
Smallest amount of work that can be committed.
Used to:
• Retrieve or manipulate data.
• Control program flow.
First section MAIN
12- character name for application
Run only when called, except for MAIN.
Run from top to bottom within the section.
Must be unique within step.
Run in specific order.
Slide 40
Student Notes
Action Types
This table gives a summary of Application Engine action types
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
58
Action TypeConfigurable Properties Role
SQL Data/ SQL statement
ReUse Statement No Rows
Run SQL tasks - Delete, Insert, Update, Meta-SQL. Cannot be in the same step with Call Section.
Call Section Flow/AE program section
Section Name Program Name
Call another section in this or another Application Engine Program. Cannot be in the same step with SQL.
Log Message Data/ Message Log
Message Set, Message Number Parameter List
Issue a message to the program Message Log.
PeopleCode Flow and Data/ PeopleCode
On Return Run PeopleCode. Can be used for both data manipulation and testing conditions for branching.
Do When Do While Do Until
Flow/ SQL Select (iterative)
ReUse Statement Test condition and run when true for Do When and DoWhile actions. A Do Until runs when false.
Do Select Flow/ SQL Select ReUse Statement Do Select type
Test condition and run when true.
XSLT Data eXtensible Stylesheet Language Transformation. Used only in conjunction with Integration Broker in Transform type programs.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
59
Building Application Engine Programs
Guidelines
When you build an Application Engine program, follow these guidelines:
• Sections, steps, and actions are inserted below the cursor focus.
• Sections are run only when called, but appear in alphabetical order.
• Steps are run in display order.
• Actions are displayed and run in a predefined order.
Slide 41
Student Notes
Example: Sections
Sections are initially inserted in ordinal sequence—Section1, Section 2, Section3. If they are renamed, they are ordered alphabetically.
Example: Unique Markets
Changing market, platform, effective date, or effective status makes sections with the same label unique.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
60
Example: Steps and Actions
Steps are inserted below the currently highlighted section or step. Actions are inserted below the currently highlighted step or action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
61
Activity 3: Inserting Sections, Steps, and ActionsIn this activity, you will review the activity overview and:
1. Create the TEST1 Application Engine program.
2. Insert sections, steps, and actions.
Slide 42
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
62
Activity OverviewIn this activity, you will create an Application Engine program called TEST1 with two sections.
Each section will have these steps and actions:
Section Step Action Type Action
MAIN STEPM01 Do When None
SQL None
STEPM02 SQL None
Section1 STEPI01 SQL None
Leave the actions empty for now.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
63
Activity Detailed StepsPerform the detailed steps to complete the activity.
Creating the TEST1 Program.
To create the TEST1 program:
1. In Application Designer, select File, New.
2. For New Definition, choose App Engine Program.
3. Save as TEST1.
Inserting Sections, Steps, and Actions
To insert sections, steps, and actions:
1. Highlight Step01 in the MAIN section.
Right-click and select Insert Action.
A SQL action is inserted.
2. With the SQL action still selected, right-click and select Insert Action.
A Do When action is inserted.
Click the drop-down list box and notice the action types available. Notice that SQL is not available because you have already used a SQL action in this step.
3. Highlight Step01.
Right-click and select Insert Step/Action.
Step02 is inserted, along with a SQL action.
4. Highlight MAIN.
Right-click and select Insert Section.
Section1 is inserted.
5. With Section1 still selected, right-click and select Insert Step/Action.
Step01 is inserted, along with a SQL action.
6. Save.
7. Close the program.
8. Reopen the program.
9. Select View , Expand All .
10. Compare your program with the following results.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
64
11. Answer the following question:
Question Answer
What is the difference between the following results and your program?
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
65
Adding Markets and Filters to Application Engine Program Sections
Markets
Using markets in an Application Engine program:
• Permits the customization of steps for specific global markets.
• Permits the development of one program for multiple markets
Slide 43
Student Notes
Global Markets.
GBL, or Global, is the default market.
Steps can include actions customized for the specific market's requirements (for example, tax calculations or currency conversion)
Multiple Markets
Market selection at runtime determines which section is run.
The same principle applies to platform and effective date.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
66
Adding Markets and Filters to Application Engine Program Sections (continued)
Program Filters
Program filters are used to force the display of unique sections at a given time.
Filters can be applied by:
• Market.
• Platform.
• Effective Date.
• Effective Status.
Slide 44
Student Notes
Program Filters
Changing the filter to custom automatically expands the program again.
The following table summarizes the filters.
Market Select the 3-character code for the market that you want. You will get all sections of this market type plus any global sections that do not have a market-specific section.
Platform This is similar to market. Choose the one you want. If no platform-specific sections are available, you will get the default ones.
As of Date Select a date from the calendar. You get all sections with an effective date prior toor equal to today's date.
Active Status If this filter is selected, you get only active sections, but if it is cleared, you get all sections (active and inactive).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
67
Adding Markets and Filters to Application Engine Program Sections (continued)
Sections
These rules apply when a section is run:
• If a section exists for the current market, run it.
• If a section exists for the current platform or RDBMS, run it.
• If a section exists for the current effective date, run it.
• If no unique section exists, run the default section.
• Within the called section, steps are run in order of sequence number.
• Within those steps, actions run from top down.
Slide 45
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
68
Activity 4: Adding Market-Specific SectionsIn this activity, you will review the activity overview and:
1. Add market-specific sections.
2. Filter which sections are visible.
3. Insert multiple actions.
Slide 46
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
69
Activity OverviewYou will add market-specific sections to the TEST1 Application Engine program that you created in the last activity, then apply filters to see only certain sections.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
70
Activity Detailed StepsPerform the detailed steps to complete the activity.
Adding Market-Specific Sections
To add sections to TEST1:
1. Verify that your program TEST1 is still open in Application Designer.
If it is not, open it from the Project Workspace.
2. Highlight Section1.
3. Use Ctrl+C or select Edit, Copy to copy the section.
4. Use Ctrl + V or select Edit, Paste to paste the section.
The new section, Section2, should be added just below Section1.
5. Change the section name to Section1.
You get an error because the section is not unique.
6. Change the market from GBL to GBR.
7. Change the section name to Section1.
This time you should not get an error.
You should now have two Section1 sections. At runtime, you can select the market on the Process Request run control. Based on the market selected, the program runs the appropriate section.
8. Copy and paste Section1 again.
9. Change the market to FRA.
10. Change the section name to Section1.
11. Save.
12. Compare your program with the subsequent results.
Filtering Which Sections Are Visible
Three Section1 sections are now in the program. This can be confusing when you try to follow the flow of a program. Earlier you learned that sections can be filtered out by market, platform, effective date, and effectivestatus. Now you will apply that knowledge, leaving only one Section1 visible.
To filter which sections are visible:
1. Select View, Collapse All.
2. Select View, Hide All Details.
The program display should now be collapsed into MAIN and three sections.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
71
3. Select View, Section Filtering, Custom.
4. Change the market to FRA, and click OK.
You should now see only MAIN and Section1 FRA displayed.
5. Turn filtering off by selecting View, Section Filtering, No Filtering.
Inserting Multiple Actions
To insert multiple actions:
1. Expand the first Section1.
2. Highlight Step01.
3. Insert eight more actions (Use the menu. Select Insert Action.)
Question Answer
What is the problem you face in inserting the eight actions.
4. Click the refresh button.
Question Answer
Which action is missing and why?
Results
Select View,Show all Details, if all details are not displayed.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
72
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
73
Setting Application Engine Program Properties
Program Properties
Program properties:
• Document the program and set ownership.
• Determine runtime characteristics.
• Determine state records used.
• Determine temporary tables used.
• Determine advance properties.
Slide 47
Student Notes
Example: Program Properties
Select File, Definition Properties to access the Application Engine program properties.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
74
You can also access the program properties with Alt-Enter, or by selecting the Properties icon from the toolbar.
Advanced Tab
The following table explains the options on the Properties, Advanced tab.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
75
Disable Restart Select to disable the Application Engine built-in restart capabilities for this program.
Application Library If the program is to contain only a collection, or library, of common routines (in the form of callable sections) this option is selected. The program in this case doesnot run standalone. When sections are defined as Public, other programs can call the sections, or routines, that exist in the library at runtime. A program of this typedoes not require the MAIN section, or an initial entry point. Setting this option renames or removes any existing MAIN section.
Batch Only Select this check box for batch-only programs. Batch-only programs are not run from the CallAppEngine() PeopleCode function. Any dedicated temporary table used for batch-only programs does not have online instances created.
Message Set Specifies the message set value to be assigned as the default message set number for this Application Engine program. The system uses this message set value for all Log Message actions for which the message set is not specified.
Program Type Select the appropriate program type from the list. Values are: Program Types Standard - Normal programs. Upgrade Only - PS upgrade utilities. Import Only - PS import utilities. Daemon Only - Managed and run by PSDAEMON. TransformOnly - Application Engine programs to support XSLT action types. Only Standardand Daemon programs will be covered later during this course.
Transform Program Type
These types of programs enable different systems to communicate with one another by transforming messages into appropriate formats. When an Application Engine program is specified as Transform Only, it can use an action type of XSLT or PeopleCode to perform any of the following actions:
• Apply a transformation to a message to make its structure comply with the target system's requirements.
• Perform a data translation on a message so that its data is represented according to the target system's conventions.
• Determine whether to pass a message through to its target by filtering it based on its content.
Note. Transform programs are the only ones that use XSLT action types, and can be run only through Integration Broker.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
76
Activity 5: Creating the Application Engine Program PSU_STK_INC
In this exercise, you will review the activity overview and:
1. Examine PSU_STOCK_TBL in SQL Developer.
2. Create PSU_STK_INC.
3. Enter the SQL.
4. Set the program properties.
Slide 48
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
77
Activity OverviewYou are notified that all stock items will have a price increase of 10 percent.
You will write a nonrestartable Application Engine program, PSU_STK_INC, that will update the PRICE column in PSU_STOCK_TBL by 10 percent.
Before you begin, look at PSU_STOCK_TBL in SQL Developer.
Here are two possible SQL statements to choose from:
UPDATE PS_PSU_STOCK_TBL SET PRICE = (PRICE * 1.10)
or
UPDATE PS_PSU_STOCK_TBL SET PRICE = PRICE + (PRICE * 10/100.0)
The second option allows for the substitution of a bind variable for 10, similar to the following (you will learnmore about bind variables later):
UPDATE PS_PSU_STOCK_TBL SET PRICE = PRICE + (PRICE * %Bind(INCREASE_PCT)/100.0)
When the program finishes successfully, issue a Log Message using message set 30000, number 1.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
78
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining PSU_STOCK_TBL in SQL Developer
To examine PSU_STOCK_TBL in SQL Developer:
1. Double-click SQLDeveloper.exe.
2. Expand the node T1B85001_SYSADM to connect.
Note. If prompted for sign-in, use sysadm/sysadm as userid/password and select the database name..
3. Enter the following SQL statement :
SELECT * FROM PS_PSU_STOCK_TBL
4. Click the green triangle in the toolbar, or press F9 to execute the SQL.
5. Notice the values in the PRICE column.
Creating PSU_STK_INC
In Application Designer, create a new Application Engine program.
1. Select File,New,Application Engine Program and Click OK
2. Rename Step01 to UPDATE.
3. Insert an action.
4. Leave the action type as SQL.
5. Insert another step and action.
6. Rename the step to MESSAGE.
7. Change the action type to Log Message.
8. For Message Set, enter 30000.
9. For Number, enter 1.
10. Save the program as PSU_STK_INC.
Entering the SQL
To enter the SQL:
1. Right-click the SQL action under UPDATE and select View SQL.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
79
2. Enter the following SQL statement:
UPDATE PS_PSU_STOCK_TBLSET PRICE = PRICE + (PRICE * 10/100.0)
A script is in: C:\Labs\0411_AppEngine\Scripts\Activity05.TXT so that you can copy and paste instead oftyping the SQL statement.
3. Close the SQL definition.
4. Save.
Setting the Program Properties
To set the program properties:
1. Select File, Definition Properties
2. On the General tab, enter a description and comments.
You can give any description, such as PSU_STK_INC.
3. On the Advanced tab, select the Disable Restart check box.
4. Click OK.
5. Save.
6. Compare your Application Engine program with the following results.
Results
Your program should look something like this:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
80
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
81
Testing Application Engine Programs
Test Methods
Three methods that developers use to test Application Engine programs are available:
• Execute directly from Application Designer in two-tier.
• Use a developer's shortcut through the Process Scheduler.
• Run from the host operating system command line.
Slide 49
Student Notes
Example: Run Request Dialog
You can run from Application Designer using the Run Request dialog.
The log file might look something like this if PSU_STK_INC ran correctly.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
82
The log file might look similar to the following screen, if PSU_STK_INC ran incorrectly.
Run Request
To run from Application Designer, select Edit, Run Program or click the traffic light icon.
This method is fast and simple, but does not allow you to add any run control parameters at run time. For the program that you just created, no run control parameters are available.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
83
Run Request Parameters
This table describes the run request parameters.
Run Control ID Enter the run control ID of the program that you are testing. If your program requires run control parameters, you need to populate the fields on the run control and specify the run control when running from Application Designer.
Run Minimized Select to have the window of the requested process minimized when the process issubmitted to run.
Output Log to File Select this if you want the output log to be written to a file.
Log File Name Specify the log file name (enabled only when Output Log to file is selected).
Process Instance Process instance number is 0 by default.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
84
Activity 6: Testing your Application Engine ProgramIn this activity, you will review the activity overview and:
1. Run PSU_STK_INC from Application Designer.
2. Check your results using SQL Developer.
Slide 50
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
85
Activity Overview:This is a continuation of the last exercise in which you wrote the PSU_STK_INC program. Now you will run PSU_STK_INC and check the results.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Introducing Application Engine Designer Lesson 3
86
Activity Detailed StepsPerform the detailed steps to complete the activity.
Running the Program
To run the program:
1. With the PSU_STK_INC Application Engine definition open, select Edit, Run Program, or click the traffic light icon.
The Run Request Dialog appears.
2. Select Output log to file.
3. Change the log file name from C:\temp\PSU_STK_INC.log to C:\temp\PSU_STK_INC_old.log.
4. Click OK.
Checking the Results
To check the results:
1. In SQL Developer, run the following SQL statement:
SELECT * FROM PS_PSU_STOCK_TBL
2. Compare your results with the following results.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 3 Introducing Application Engine Designer
87
Review
In this lesson, you learned that:
• In class you will access a database with the same name as your workstation.
• You can run an Application Engine program using Run Program in Application Designer.
• You use the Application Engine Designer to build Application Engine programs.
• Application Engine programs are structured in a hierarchy of sections, steps, and actions.
• You can add markets and filters to an Application Engine program.
• You document your Application Engine program in the Application Engine properties.
• Application Engine programs can be tested from within Application Designer, from the command line, or using a Developer's Shortcut.
Slide 51
Student Notes
Additional Resources
This table lists additional resources that provide more details about the topics that we have discussed in this lesson:
Topic Cross-Reference
Application Engine Processes Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler,"Understanding PeopleSoft Process Scheduler"
Application Engine Designer Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
Message Catalog Enterprise PeopleTools 8.50 PeopleBook: System and Server Administration , "PeopleTools Utilities"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
89
Lesson 4
Using State Records
Objectives
By the end of this lesson, you will be able to:
• Describe the function of state records.
• Create a state record.
• Run an Application Engine program using the developer's shortcut.
• Modify Application Engine programs to use state records.
• Add sections and steps to existing Application Engine programs.
• Use meta-SQL in Application Engine programs.
Slide 53
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
90
Describing the Function of State Records
State Record
Zero, one, or many state records may be associated with a program.
The state record:
• Is used to hold runtime variables for the Application Engine program run.
• Is maintained by the developer and is invisible to the user.
• Is used to hold all SQL Select results.
• Can be a derived/work record or a SQL table.
Slide 54
Student Notes
Runtime Variables
Runtime variables that can be held in the state record include:
• Initial run control variables (such as pay groups, departments, business units, and so on).
• Values passed in the program from prior sections, steps, and actions.
• Computed values or counters.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
91
Describing the Function of State Records (continued)
State Record (continued)
This diagram shows the relationship between an Application Engine program and the state record:
Slide 55
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
92
Creating a State Record
Guidelines
Note these guidelines when creating a state record:
• The first field must always be PROCESS_INSTANCE and it must be a key field.
• Any additional fields on the record will be variables used within the program.
• To identify the record to the system, the name of the state record must end in AET.
• If the state record is a SQL table type, it must be built as a table before it is used.
Slide 56
Student Notes
Example: State Record
Here is an example of a state record:
Note. Using Find Definition References with a record definition open lists which Application Engine programs use the record as a state record.
PROCESS_INSTANCE must be a key. No other keys are needed, but they can exist and you will see additional keys on some PeopleSoft-delivered state records; but the only key that's used is PROCESS_INSTANCE.
When you run an Application Engine program, Process Instance is populated with the process instance assigned by the system for this process.
Any additional fields on the record are variables that you use within your Application Engine program. For this example, the only field we are using is APP_REL.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
93
Creating a State Record (continued)
State Table
A state table can be a SQL table or a Derived/Work record definition.
• Use the type Derived/Work type to increase performance.
• Derived/Work records are reinitialized after each commit.
• Use the type SQL table when:
• You need to preserve any state record field values across commits in your program.
• You need to preserve values for restart.
Slide 57
Student Notes
SQL Table
As a general rule, if you want to preserve any state record field values across commits in your program, then you should store those values in a state record with a record type of SQL Table.
Derived/Work Record
Use state records of the Derived/Work record type only to store values that don't need to be accessed across commits. Derived/Work records are, however, an excellent choice for temporary flags and dynamic SQL containers that are set and then referenced immediately. Because these values aren't needed later, you don't want to pay the price of saving them to the database at each commit. When you create your state record in Application Designer, you should have an idea regarding how your state record will be used. With this information, you can select the appropriate record type to build.
In the context of Application Engine programs, state records that are Derived/Work records work the same as those that are of a SQL Table type. However, one notable distinction exists: unless you have disabled Restart,Derived/Work records have their field values reinitialized after each commit. Therefore, unless you anticipatethis behavior, you're likely to encounter problems. One quick way to diagnose such a problem is to examine atrace. Typically, you'll see %BINDs resolved to values prior to a commit, and then after the commit, they'll have no value.
This behavior is necessary to ensure consistency in the event of an ABEND and restart. During the restart, Application Engine begins, or restarts, at the point of the last successful commit and restores the values of anystate records with corresponding database tables. Derived/Work records aren't associated with a physical database table, and consequently they can't be restored in the event of a restart.
Note. The only difference between SQL tables and Derived/Work records is that Derived/Work state records cannot have their values saved at commit time; therefore, the values would be lost during a restart.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
94
Creating a State Record (continued)
Field Attributes
Note the following guidelines for state record field attributes.
• State record field attributes need not match those of the source records.
• Date fields, in particular, must not be required in the record.
• Having date fields as required will cause Application Engine to end abnormally.
• Other fields that are set as not null in the record in the database may also cause abends.
Slide 58
Student Notes
Null Fields
Warning! If the date field is required, the table build process sets the column as not null in the database. Application Engine doesn't know this and tries to store a blank in that column, which ends your program abnormally.
The date/time, long, and image type variables all build the fields as not null in the database. Initially, no valuemay be in one of these fields and therefore, because it is marked as not null, the program will end abnormally when it tries to pass a null to that field.
Note. An abend occurs when Application Engine tries to commit the state record. If the program is not restartable, Application Engine may not end abnormally even though a date field is required because only a commit of the state record table will exist if the program is restartable.
Important Points
Note these points:
• At start, a row is inserted into the state record corresponding to the system-assigned process instance.
• The state record table is updated whenever a COMMIT occurs (when restart is enabled).
• The row used by a program is deleted on successful completion.
• Multiple programs may use the same state record.
• PeopleCode or the %Select construct in a SQL action stores values in the state record.
• PeopleCode or %Bind reference fields in the state record and retrieve their values.
• No record PeopleCode on the state record is run.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
95
• No PeopleSoft edits will be applied to state record fields.
Batch Processing
During batch processing (as opposed to online invocation using CallAppEngine in PeopleCode), Application Engine automatically performs all state record updates. Application Engine updates the record whenever a commit occurs. When Restart is enabled and a commit occurs, all state records that have been updated in memory are written to the database, except for derived state records, which are instead initialized.
Then, after the program finishes successfully, Application Engine deletes the corresponding row in the state record. Only one row is in the state record for each process instance, or program. Multiple programs can use the same state record, and each program has its own row based on the unique process instance key.
Setting Values
To set values in the State Record, you use the %Select construct in a SQL statement or write PeopleCode that references the state field with the standard record.field notation. To reference fields in the state record, you use the %Bind construct.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
96
Creating a State Record (continued)
Adding State Records
Use the Application Engine program properties to add state records.
Note these points:
• The program must be open in Application Designer.
• A program may be assigned multiple state records.
• One state record is designated as the default state record.
Slide 59
Student Notes
Dialog Box Used to Add State Records
Dialog Box Name Navigation
Program Properties Select File, Definition Properties.
Select the State Records tab.
Use the Program Properties dialog box to add state records.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
97
The first record added automatically becomes the default state record.
Note. Click the Get List button. If you enter a partial name, you still have to click the Get List button. If you press Enter, it's the same as clicking OK and closes the dialog box.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
98
Creating a State Record (continued)
Execute Time
At runtime, values are inserted into the state record based on:
• The %Select meta-SQL function in your Application Engine program.
• Values entered on the AE Request page and inserted using PeopleCode.
Once a value is inserted into the state record, it can be accessed using the %Bind meta-SQL construct or PeopleCode.
On successful completion, the row of data in the state record is deleted.
Slide 60
Student Notes
Examples: SQL Defintions
Here is an example of a SQL definition that a state record is populated with.
Here is an example of a SQL definition that references a field in a state record.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
99
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
100
Creating a State Record (continued)
Movement of Values
This diagram illustrates the movement of values between the state record and an Application Engine program:
Slide 61
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
101
Creating a State Record (continued)
%Select and %Bind
This table compares %Select and %Bind:
%Select %Bind
%Select stores values retrieved from a Select statement to the state table.
%Bind retrieves values from the state table for use in SQLstatements.
A %Select is required at the beginning of every Select statement.
The %Bind function can be used anywhere in a SQL statement.
%SELECT(field1, field2, field3)SELECT NAME, ADDRESS, CITY FROM PS_VENDOR_CONTACT WHERE VENDOR_ID = 'ACME'
%SELECT(ITEM_CODE, ITEM_DESCR)
SELECT ITEM_CODE, ITEM_DESCR
FROM PS_ITEM_TBL
WHERE VENDOR_CODE = %BIND(FIELD1)
Slide 62
Student Notes
%Select and %Bind
The preceding syntax for %Select and %Bind is for using the default state record. If you are using another state record, you must fully qualify the field name.
For example:
SELECT ITEM_CODE, ITEM_DESCRFROM PS_ITEM_TBLWHERE VENDOR_CODE = %BIND(STATE_REC2.FIELD1)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
102
Running an Application Engine Program Using the Developer's Shortcut
Developer's Shortcut
A developer's shortcut is a component set up for testing Application Engine programs.
In the classroom, we use the Request AE page with the FASTTEST process definition.
Slide 63
Student Notes
Page Used to Test an Application Engine Program
Page Name Navigation
Application Engine Request PeopleTools, Application Engine, Request AE
Use the Request AE page to test Application Engine programs in class.
On the AE Request page, the run control ID must exactly match the program name.
Change the process frequency to Always.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
103
Select AE Fast Test from the Process List.
You can view the results in Process Monitor.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
104
Note. The AppEngineGeneric test type and the FastTest process are specific to this training environment. They are not delivered by Oracle with your application. As will be shown later on in the course, the run control ID and program name do not always need to be the same.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
105
Activity 7: Passing Information to Programs Using a State Record
In this activity, you will review the activity overview and modify PSU_INACT_2 to use PSU_INACT2_AETas its state table. Specifically, you will:
1. Set the Application Engine program properties.
2. Set the run control.
3. Run the program.
4. Check your results.
Slide 64
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
106
Activity OverviewIn this activity, you will make the necessary modifications to the program properties of PSU_INACT_2 to add PSU_INACT2_AET as the state record for that program. Then you will run the program to test it.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
107
Activity Detailed StepsPerform the detailed steps to complete the activity.
Setting the Application Engine Program Properties
To set the Application Engine program properties:
1. Open the Application Engine program PSU_INACT_2.
2. Open the definition properties by selecting File, Definition Properties (or Alt-Enter or clicking the Properties icon).
3. On the Advanced tab, select the Disable Restart check box.
4. Add PSU_INACT2_AET as the state record.
a. Select the State Records tab.
b. Enter PSU in the Qualify Search field.
c. Click Get List.
d. Double-click PSU_INACT2_AET to add it.
e. Click OK.
5. Save.
Setting the Run Control
To set the run control:
1. Navigate to the Request AE page by selecting PeopleTools, Application Engine, Request AE in the browser.
(UserId/Password: PTTRA/PTTRA)
2. Select the Add a New Value tab.
3. Enter the following information:
Page Element Value or Status
User ID PTTRA
Run Control ID PSU_INACT_2
Program Name PSU_INACT_2
4. Click Add.
This accesses the Application Engine Request page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
108
5. Enter the following information:
Page Element Value or Status
Process Frequency: Always
State Record: PSU_INACT2_AET
Bind Variable Name: APP_REL
Value: 700
6. Click Run.
This displays the Process List.
Running the Program
PSU_INACT_2 is not set up to be selected here directly. Instead, you will use the FASTTEST process to launch it.
To run the program:
1. Select the AE Fast Test check box.
Process Scheduler uses the FASTTEST process to find the program using the name that you provided as the run control ID when you set up your run control.
2. Scroll to the bottom of the page and click OK.
3. Select PeopleTools, Process Scheduler, Process Monitor to access Process Monitor to verify that the program ran successfully.
Checking Your Results
To check your results:
1. In SQL Developer, run the following SQL:
SELECT * FROM PS_PSU_COURSE_TBL WHERE APP_REL < '700'
2. Compare your results to the following results:O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
109
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
110
Modifying Application Engine Programs to Use State Records
Considerations
Consider these questions when creating state records:
• What information does the program need?
• Where is the information located?
• What fields will be needed to store the information in the state record?
• What will the SQL look like to store the information?
• What will the SQL look like to retrieve the information?
Slide 65
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
111
Activity 8: Adding a State Record to PSU_STK_INCIn this activity, you will review the activity overview and add a state record to PSU_STK_INC, then modify the program to use the state record.
Slide 66
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
112
Activity OverviewIn this activity, you will create and build the PSU_STK_INC_AET record, then add it as a state record for your PSU_STK_INC, and test the program.
In addition to the required key field, add a field to the state record to store the value for the increase amount.
You will need to modify PSU_STK_INC to retrieve the increase amount from the state record.
Run the program using AE Request and check your results using SQL Developer.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
113
Activity Detailed StepsTo add a state record to PSU_STK_INC:
1. Check the current prices in PS_PSU_STOCK_TBL by running this SQL statement using SQL Developer:
SELECT * FROM PS_PSU_STOCK_TBL
2. In Application Designer, Create the state record PSU_STK_INC_AET.
a. Select File, New, Record.
b. Select Insert, Field.
c. Type the field name PROCESS_INSTANCE and click Insert button
d. Double-click the field name and select the Key check box to make it a key.
e. Click OK.
f. Type the field name INCREASE_PCT and click Insert button
g. Save the Record.as PSU_STK_INC_AET.
The Change Space dialog box appears.
h. Select PTAPP.PSPTDMO from the Available Space Name-DB Name drop down list.
i. Click OK.
3. Build the record.
a. Select Build, Current Definition.
b. Select the Create Tables check box.
c. Select the Execute SQL Now option.
d. Click Build.
Click yes, if the message "Potentially data destructive settings are active. continue the build process" pops up.
4. Modify the Application Engine program PSU_STK_INC to use the bind variable from your state record.
a. Open the SQL definition in the UPDATE step.
b. Modify the SQL to read:
UPDATE PS_PSU_STOCK_TBL SET PRICE = PRICE + (PRICE * %Bind(INCREASE_PCT)/100.0)
5. In Program Properties update the state record used with the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
114
6. Access the Request AE page.
a. Select PeopleTools, Application Engine, Request AE.
b. Select the Add a New Value tab.
c. Enter the following information:
Page Element Value or Status
User ID PTTRA
Run Control ID PSU_STK_INC
Program Name PSU_STK_INC
7. Click Add.
This accesses the Application Engine Request page.
8. Enter the following information:
Page Element Value or Status
Process Frequency: Always
State Record: PSU_STK_INC_AET
Bind Variable Name: INCREASE_PCT
Value: 10
9. Click Run.
This displays the Process List.
10. Select the AE Fast Test check box.
11. Scroll to the bottom of the page and click OK.
12. Navigate to Process Monitor by selecting PeopleTools, Process Scheduler, Process Monitor.
13. Use Process Monitor to verify that the program ran successfully.
14. Check your results in PS_PSU_STOCK_TBL using SQL Developer.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
115
Adding Sections and Steps to Existing Application Engine Programs
Application Engine Structure
An Application Engine program can be structured in several ways:
Sections Steps Actions
One One One
One One Multiple
One Multiple One per step to Many per step
Multiple One per section to Many per section One per step to Many per step
Slide 67
Student Notes
Benefits of Multiple Sections
Using multiple sections enables you to:
• Organize the program into logical groups.
• Simplify reading of the program.
• Permit sharing of sections by other programs.
• Enhance maintainability—smaller groups of functions can be changed more easily.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
116
Adding Sections and Steps to Existing Application Engine Programs (continued)
PSU_CUST_CHG Table Relationships
PSU_CUST_TBL has two dependencies.
Slide 68
Student Notes
PSU_CUST_CHG Goal
PSU_CUST_CHG goal:
• Update CUSTOMER_ID where required in the PS_PSU_CUST_TBL, PS_PSU_CUST_PROD, and PS_PSU_STUDENT_TBL.
• Demonstrate Call Section.
Note. The whole program could have been written as one section with three steps, each with a SQL update.
Example: Call Section
PSU_CUST_CHG includes a Call Section step.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
117
The program flow for PSU shows a Call Section action followed by two steps from the called section, each containing a SQL action.
Alternative Program Flow
This alternative program flow shows how the program could have been written as a series of three SQL actions.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
118
Section MAIN
Section MAIN updates the PS_PSU_CUST_TBL:
• Step M01 SQL
UPDATE PS_PSU_CUST_TBLSET CUSTOMER_ID=%Bind(TO_CUSTOMER_ID)WHERE CUSTOMER_ID=%Bind(FROM_CUSTOMER_ID)
• Step M02 CALL Section CHILDREN
Section CHILDREN
Section CHILDREN updates the PS_PSU_CUST_PROD, PS_PSU_STUDENT_TBL:
• STEPC01 SQL
UPDATE PS_PSU_CUST_PRODSET CUSTOMER_ID = %BIND(TO_CUSTOMER_ID)WHERE CUSTOMER_ID = %BIND(FROM_CUSTOMER_ID)
• STEPC02 SQL
UPDATE PS_PSU_STUDENT_TBLSET CUSTOMER_ID = %BIND(TO_CUSTOMER_ID)WHERE CUSTOMER_ID = %BIND(FROM_CUSTOMER_ID)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
119
Activity 9: Adding a Log Message to PSU_CUST_CHGIn this exercise, you will review the activity overview and add a Log Message action to PSU_CUST_CHG, then call the section containing the message with a Call Section action.
Slide 69
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
120
Activity OverviewThe PSU_CUST_CHG Application Engine program changes the customer ID in the Customer Table and its dependent tables, PSU_CUST_PROD and PSU_STUDENT_TBL.
In this activity, you will add a message section to PSU_CUST_CHG. The section will contain a step with a Log Message action.
The message has already been created in Message Catalog with a message set of 30000 and a message number of 3.
The text of the message is:
%1 has changed Customer ID %2 to %3.
The parameters of the message are:
Parameter Value Description
%1 %AEProgram This Application Engine meta-variable resolves to the current program name, in quotes: 'PSU_CUST_CHG'
%2 %Bind(FROM_CUSTOMER_ID) %Bind retrieves a value from the state record.
%3 %Bind(TO_CUSTOMER_ID) %Bind retrieves a value from the state record.
You will need to call the message section from the MAIN section.
Test the new program using the Application Engine Request page. For the test, use CONS for the FROM_CUSTOMER_ID and use CONSRV as the TO_CUSTOMER_ID.
View the log file using Process Monitor to verify that the Log Message action ran properly.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
121
Activity Detailed StepsTo complete this activity, you will:
1. Add a Log Message action in a callable section.
2. Add an action to call the MESSAGE section.
3. Run PSU_CUST_CHG using the AE Request page.
4. View the log file.
Adding a Log Message Action in a Callable Section
To add a Log Message action in a callable section:
1. Open the Application Engine program PSU_CUST_CHG.
2. Insert a new section.
Name the section MESSAGE.
3. In the MESSAGE section, insert a Step/Action.
4. Set the action to Log Message.
5. Enter the following information:
Page Element Value or Status
Message Set: 30000
Message Number 3
Parameters: %AEProgram, %BIND(FROM_CUSTOMER_ID), %BIND(TO_CUSTOMER_ID)
Adding an Action to Call the MESSAGE Section
To add an action to call the MESSAGE section:
1. In the MAIN section, highlight StepM02.
2. Insert a Step/Action.
3. Set the action to Call Section.
4. For Section Name select MESSAGE.
5. Save.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
122
Running PSU_CUST_CHG Using the AE Request Page
To run PSU_CUST_CHG using the AE Request page:
1. Navigate to the Request AE page by selecting PeopleTools, Application Engine, Request AE..
2. Click Search.
3. Select PSU_CUST_CHG run control from the list.
This accesses the Application Engine Request page, which has been pre-populated with the following information:
Page Element Value or Status
Process Frequency: Always
State Record: PSU_CUSTID_AET
Bind Variable Name: FROM_CUSTOMER_ID
Value: CONS
Bind Variable Name: TO_CUSTOMER_ID
Value: CONSRV
4. Click Run.
This displays the Process List.
5. Select the AE Fast Test check box.
6. Scroll to the bottom of the page and click OK.
Viewing the Log File
To view the log file:
1. Navigate to Process Monitor by selecting PeopleTools, Process Scheduler, Process Monitor..
2. When the process shows a status of Success, click the Details link.
3. Click the Message Log link.
4. Compare your results with the following results.
Results
The Message Log should reflect the changed customer ID.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
123
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
124
Using Meta-SQL in Application Engine Programs
Meta-SQL
Meta-SQL:
• Expands to platform-specific SQL substrings.
• Causes another function to be called.
• Substitutes a value.
• Is used in PeopleCode, Application Engine, and COBOL.
Slide 70
Student Notes
Meta-SQL
• %SQL is meta-SQL used to access SQL definitions and pass values to them.
• Syntax:
%SQL(SQL Definition [, paramlist])
• In Application Engine, the parameters in the %SQL can be:
• %Bind(fieldname).
• Literals
PeopleSoft SQL definitions store SQL used in PeopleSoft applications.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
125
In Application Engine, this statement:
UPDATE PS_PSU_CUST_TBLSET CUSTOMER_ID = %BIND(TO_CUSTOMER_ID)WHERE CUSTOMER_ID = %BIND(FROM_CUSTOMER_ID)
Can become:
%SQL(UPD_CUST_ID, PS_PSU_CUST_TBL)
Note that the name of the SQL definition, UPD_CUST_ID, is the first parameter of the %SQL statement.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
126
Activity 10: Adding %SQL Meta-SQL to PSU_CUST_CHGIn this activity, you will review the activity overview and modify the PSU_CUST_CHG program to use %SQL meta-SQL to access SQL definitions.
Slide 71
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
127
Activity OverviewIn this activity, you will create a SQL definition that can be used by the program's SQL actions to perform table updates.
• Name your new SQL definition UPD_CUST_ID.
You will access this SQL definition from several different SQL actions.
• Modify the SQL in the three SQL actions to use the new SQL definition.
• Then modify the PSU_CUST_CHG program to update two more tables:
• PSU_ORDER_HDR
• PSU_ORDER_DTL
Run PSU_CUST_CHG using the AE Request page.
Use SQL Developer to check your results.
On your workstation is a script with the following code for this activity:
C:\labs\0411_AppEngine\Scripts\Activity10.txt
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
128
Activity Detailed StepsIn this activity, you will:
• Create a new SQL definition.
• Convert SQL actions to use meta-SQL.
• Add actions to update additional tables.
• Test the program.
• Check whether the new tables were updated correctly.
Create a New SQL Definition
To create a new SQL definition:
1. In Application Designer, select File, New, Definition Type: SQL.
2. Enter the following SQL:
UPDATE %P(1)SET CUSTOMER_ID = %BIND(TO_CUSTOMER_ID)WHERE CUSTOMER_ID = %BIND(FROM_CUSTOMER_ID)
3. Save.
Name the SQL definition UPD_CUST_ID.
Converting SQL Actions to Use Meta-SQL
To convert SQL actions to use meta-SQL:
1. In Application Designer, open the Application Engine program PSU_CUST_CHG.
2. With your cursor in the MAIN section, StepM01, the SQL action, right-click and select View SQL.
3. Replace the SQL with the following SQL statement:
%Sql(UPD_CUST_ID, PS_PSU_CUST_TBL)
4. Click Save.
5. Replace the SQL in the two SQL actions in the CHILDREN section. Change the name in each action to update the appropriate table.
Use the following SQL statements:
%Sql(UPD_CUST_ID, PS_PSU_CUST_PROD)%Sql(UPD_CUST_ID, PS_PSU_STUDENT_TBL)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
129
Adding Actions to Update Additional Tables
In this task, you will update these tables:
• PS_PSU_ORDER_HDR
• PS_PSU_ORDER_DTL
To add actions to update the tables:
1. Highlight StepC02.
2. Insert another Step/Action.
3. Right-click the SQL action and select View SQL.
4. Add the following SQL:
%Sql(UPD_CUST_ID, PS_PSU_ORDER_HDR)
5. Click Save.
6. Add another Step/Action to update PS_PSU_ORDER_DTL.
7. Add the following SQL:
%Sql(UPD_CUST_ID, PS_PSU_ORDER_DTL)
Testing the Program
To test the program:
1. Navigate to the Request AE page by selecting PeopleTools, Application Engine, Request AE
2. Use PSU_CUST_CHG as the program name.
3. Enter the following information:
Page Element Value or Status
Process Frequency: Always
State Record: PSU_CUSTID_AET
Bind Variable Name: FROM_CUSTOMER_ID
Value: FLE
Bind Variable Name: TO_CUSTOMER_ID
Value: LITTLE
4. Run the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using State Records Lesson 4
130
Checking Whether the New Tables Were Updated Correctly
Use SQL Developer to check the results of this activity in PS_PSU_ORDER_HDR and PS_PSU_ORDER_DTL.
Compare your results with the following results.
Results
Your results should look something like this.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 4 Using State Records
131
Review
In this lesson, you learned that:
• A state record is the method by which you allocate variables for your Application Engine program.
• A state record must be defined with the following criteria:
• The name of the record must end in AET.
• The record contains only one key that must be PROCESS_INSTANCE.
• All other fields on the state record are designed to meet the needs of the program.
• Developers can create a custom run control page using the FASTTEST process as a shortcut to run Application Engine programs for testing.
• Application Engine programs use %Select and %Bind to store values to state records and retrieve values from state records.
• Multiple Application Engine programs can access the same SQL definitions.
• %SQL can be used retrieve SQL from SQL definitions for use in SQL actions.
Slide 72
Student Notes
Additional Resources
This table lists additional resources that provide more details about the topics that we have discussed in this lesson:
Topic Cross-Reference
State records PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Developing EfficientPrograms"
Meta-SQ PeopleTools 8.50 PeopleBook: PeopleCode Reference, "Meta-SQL"
PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide, "Introducing the SQL Editor"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
133
Lesson 5
Testing and Debugging
Objectives
By the end of this lesson, you will be able to:
• Test Application Engine programs.
• Use Process Monitor.
• Trace Application Engine programs.
• Use the Application Engine Debugger.
• Test with Application Engine restart.
Slide 74
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
134
Testing Application Engine Programs
Application Engine Testing Tools
Several common Application Engine testing tools are available to you:
• The Process Monitor.
• The Application Engine Trace file.
• The Application Engine interactive debugger.
• The PeopleCode Debugger.
Slide 75
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
135
Using Process Monitor
Process Monitor
For programs run through Process Scheduler, Process Monitor tracks the status of the programs during and after execution.
Slide 76
Student Notes
Pages Used to Monitor Processes
Page Name Navigation
Process Monitor PeopleTools, Process Scheduler, Process Monitor
Process Detail Select the Process Monitor: Details link.
Process Request Parameters Select the Process Detail: Parameters link.
Message Log Select the Process Detail :Message log link.
• Use Process Monitor for troubleshooting Application Engine processes.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
136
• The Details link accesses the Process Detail page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
137
• The Process Request Parameters page displays the command line that was used to run the Application Engine program along with which users are authorized to view the output of the Application Engine program and placed in the report repository.
• The Message Log page displays the page where output from Log Message steps is captured.
In addition to messages from the Application Engine program's Log Message actions, you see messages produced by the internal application messaging and the distribution agent (the last two messages on this screen).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
138
Using Process Monitor (continued)
Other Links
Other links on the Process Monitor, Process, and Process Detail pages include:
• View Locks
• Batch Timings
• View Log/Trace
Slide 77
Student Notes
View Locks
If you use any temporary tables in your program, they will be listed here during execution. Lesson 9 discussestemporary tables.
Batch Timings
The Batch Timings report contains a set of statistics that system administrators can use to improve performance. This report relates specifically to PeopleSoft Application Engine program performance.
You can set up your Application Engine trace files to store statement timings traces to a table, which can be viewed from this link.
The Batch Timings link is available only for process requests with a process type of Application Engine.
View Log/Trace
When you click the View Log/Trace link, a new page appears, with links that enable you to view the messagelog and trace file in a browser. The View Log/Trace link appears on the Process Monitor Detail page when at least one of the following conditions is met:
• The output destination for the process request is Web, and the report and the Distribution Agent successfully posted log files to the Report Repository.
• The process has run successfully.
• If the report hasn't been transferred to the Report Repository, the run status of the process request is Not Posted and the View/Log link is not visible.
• If the status of the request remains Posting, check the message log for messages from the Distribution Agent indicating that problems occurred while transferring files to the Report Repository.
• The process request ran from a PeopleSoft Process Scheduler Server Agent that was set up using the Server Definition page with a distribution node.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
139
You must have also selected to transfer log files to the Report Repository when you set up the preferences on this page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
140
Using Application Engine Traces
Trace Options
For processes running on Windows, trace options are set in the Configuration Manager.
These settings are valid only when the Application Engine program is run on the client from Application Designer or from the command line.
Slide 78
Student Notes
Page Used to Set Application Engine Traces
Definition Name Navigation
Configuration Manager Trace People Tools folder in the desktop.
Use the Trace tab in Configuration Manager to set Application Engine Trace settings.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
141
Application Engine Trace Settings
The Application Engine Trace settings are in the upper right corner of the panel.
You will do all of your tracing in two-tier because this will place the trace files on your workstations. Once you have learned how to create run control pages and process definitions, you can run traces over the Internet.
The check boxes in configuration manager equate to numerical values in the server configuration files.
Changing the TraceAE values in the Server Agent configuration file affects all Application Engine programs initiated by that server agent.
Changing the TraceAE values in the Application Server configuration file affects all Application Engine programs invoked by PeopleCode (CallAppEngine) that are run on that Application Server.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
142
Trace Checkbox Descriptions
Step Reports each step name that is performed, along with a timestamp, the DO level, and the statement type.
SQL This is the same as step, plus it reports formatted SQL processes including COMMITs, ROLLBACKs, and restarts.
Ded. Temp. Table Writes the details of the temporary tables used to the trace file. You will see this in action in both the temporary tables lesson and the performance tuning lesson later in the class.
Statement Timings (file) Initiates the Application Engine timings trace, which monitors the execution timing of each statement and is written to the bottom of the Application Engine Trace file.
Statement Timings (table)
Writes the Statement Timings traces to the PS_BAT_TIMINGS_LOG and PS_BAT_TIMINGS_DTL tables so that you can store historical data in the database and do custom reporting. A delivered report comes from these tables, which can be found on the internet in PeopleTools, Process Scheduler, Batch Timings. The report can be generated as a detail report for a specific process instance or as a summary report for a run control ID.
PeopleCode Detail Timings
Initiates the PeopleCode Detail Timings trace, which monitors the timing of PeopleCode execution and is written at the bottom of the Application Engine tracefile.
DB Optimizer (file) Reveals the execution/query plan for the SQL that your Application Engine program generates.
DB Optimizer (table) Writes the DB Optimizer traces to a table so that you can store historical data in the database and do custom reporting.
DB Optimizer Trace
With the DB Optimizer trace you can write the trace to a file or a table. The DB Optimizer trace reveals the execution/query plan for the SQL that your Application Engine program generates. Each SQL statement gets traced only once.
How you view the results of this trace depends on the type of RDBMS you're currently using. For instance, on some platforms only the trace to file option is available, whereas on others only the trace to table option is available. The following table shows the options available for each of the platforms that Oracle supports.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
143
RDBMS File Table
Microsoft SQL Server X X
DB2 FOR OS/390 X
DB2 for UDB (AIX, Solaris, NT) X
Oracle X X
Informix X
Sybase
Trace File Name
The name of the trace file depends on whether you specify a process instance number for the process run.
Process Instance Name of File
Without a Process Instance AE_<Date/Time_Stamp>_<OS_PID>.AET Where: <Date/Time_Stamp> is in the format <mmddhhmmss> <OS_PID> is the operating system process ID
With a Process instance AE_<Program_name>_<Process_Instance>.AET
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
144
Activity 11: Tracing PSU_CUST_CHGIn this activity, you will review the activity overview and run two Application Engine traces. Specifically, you will:
1. Set the Step Trace Setting in Configuration Manager.
2. Add the SQL trace setting.
Slide 79
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
145
Activity OverviewYou will run PSU_CUST_CHG twice using Configuration Manager Application Engine traces. The first run will use the Step trace setting, and the second will additionally use the SQL trace setting.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
146
Activity Detailed StepsPerform the detailed steps to complete the activity.
Setting the Step Trace Setting in Configuration Manager
To set the step trace setting in Configuration Manager:
1. Open the PeopleTools folder on the desktop.
2. Double-click the Configuration Manager shortcut.
3. Select the Trace tab.
4. In the Application Engine Trace group, select the Step check box.
5. Click Apply.
Do not click OK. Leave Configuration Manager open because you will use it again.
6. In Application Designer, open the Application Engine program PSU_CUST_CHG.
7. Select Edit, Run Program to run the program, or click the Traffic Light button.
8. When the Run dialog appears, enter PSU_CUST_CHG as the run control ID.
9. Click OK to run.
10. Use Windows Explorer to navigate to and open the trace file.
In the classroom, the file will be in:
C:\Temp
The file name will be in the format AE_mmddhhmmss_<os process id>.AET
For example:
C:\Temp\AE_0312170736_9384.AET Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
147
11. Double-click the file to open it in Notepad.
The file should look something like this:
-- PeopleTools 8.50-901-R1 -- Application Engine
-- Copyright (c) 1988, 2009, Oracle.
-- All rights reserved.
-- Database: T1B85001 (Oracle)
-- 10.10.06 2009-07-31 Tracing Application Engine program PSU_CUST_CHG Change Customer ID
-- 10.10.06 .(PSU_CUST_CHG.MAIN.StepM01) (SQL)
-- 10.10.07 .(PSU_CUST_CHG.MAIN.StepM02) (Call Section PSU_CUST_CHG.CHILDREN) 10.10.07 ..(PSU_CUST_CHG.CHILDREN.StepC01) (SQL)
-- 10.10.07 ..(PSU_CUST_CHG.CHILDREN.StepC02) (SQL)
-- 10.10.07 ..(PSU_CUST_CHG.CHILDREN.StepC03) (SQL)
-- 10.10.07 ..(PSU_CUST_CHG.CHILDREN.StepC04) (SQL)
-- 10.10.07 .(PSU_CUST_CHG.MAIN.StepM03) (Call Section PSU_CUST_CHG.MESSAGE)
-- 10.10.07 ..(PSU_CUST_CHG.MESSAGE.Step01) (Log Message)
-- 10.10.08 Application Engine program PSU_CUST_CHG ended normally
-- 10.10.08 Application Engine ended normally
-- 19.28.51 Application Engine ended normally
Each line of the trace shows:
• Time
• Program Name
• Section Name
• Step Name
• Action type
You can see, progressively, in the trace:
• SQL execution in MAIN.StepM01 (the 1st SQL Update).
• The call to the CHILDREN Section from MAIN.StepM02
• Execution of SQL in CHILDREN.StepC01
• Execution of SQL in CHILDREN.StepC02
• Execution of SQL in CHILDREN.StepC03
• Execution of SQL in CHILDREN.StepC04
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
148
• Going back to MAIN.StepM03 to call the MESSAGE Section
• Execution of a Log Message in MESSAGE.Step01.
This program is simple with unconditional execution.
Adding the SQL Trace Setting
To add the SQL trace setting:
1. In Configuration Manager, on the Trace panel, select the SQL check box in the Application Engine Trace group box and click Apply.
2. In Application Designer, Select Edit, Run Program to run the program or click the Traffic Light button.
3. When the Run dialog appears, enter PSU_CUST_CHG as the run control ID.
4. Click OK to run.
5. Use Windows Explorer to navigate to and open the trace file.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
149
6. Double-click the file to open it in Notepad.
The trace file will look something like this:
-- PeopleTools 8.50-901-R1 -- Application Engine
-- Copyright (c) 1988, 2009, Oracle.
-- All rights reserved.
-- Database: T1B85001 (Oracle)
-- 10.18.24 2009-07-31 Tracing Application Engine program PSU_CUST_CHG Change Customer ID
-- 10.18.24 .(PSU_CUST_CHG.MAIN.StepM01) (SQL)
UPDATE PS_PSU_CUST_TBL SET CUSTOMER_ID = 'LITTLE' WHERE CUSTOMER_ID = 'FLE'
/
-- Row(s) affected: 0
-- 10.18.24 .(PSU_CUST_CHG.MAIN.StepM02) (Call Section PSU_CUST_CHG.CHILDREN)
-- 10.18.24 ..(PSU_CUST_CHG.CHILDREN.StepC01) (SQL)
UPDATE PS_PSU_CUST_PROD SET CUSTOMER_ID = 'LITTLE' WHERE CUSTOMER_ID = 'FLE'
/
-- Row(s) affected: 0
-- 10.18.24 ..(PSU_CUST_CHG.CHILDREN.StepC02) (SQL)
UPDATE PS_PSU_STUDENT_TBL SET CUSTOMER_ID = 'LITTLE' WHERE CUSTOMER_ID =
'FLE'
/
-- Row(s) affected: 0
-- 10.18.24 ..(PSU_CUST_CHG.CHILDREN.StepC03) (SQL)
UPDATE PS_PSU_ORDER_HDR SET CUSTOMER_ID = 'LITTLE' WHERE CUSTOMER_ID = 'FLE'
/
-- Row(s) affected: 0
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
150
-- 10.18.24 ..(PSU_CUST_CHG.CHILDREN.StepC04) (SQL)
UPDATE PS_PSU_ORDER_DTL SET CUSTOMER_ID = 'LITTLE' WHERE CUSTOMER_ID = 'FLE'
/
-- Row(s) affected: 0
-- 10.18.24 .(PSU_CUST_CHG.MAIN.StepM03) (Call Section PSU_CUST_CHG.MESSAGE)
-- 10.18.24 ..(PSU_CUST_CHG.MESSAGE.Step01) (Log Message)
COMMIT
/
-- 10.18.24 Application Engine program PSU_CUST_CHG ended normally
-- 10.18.24 Application Engine ended normally
Notice that the trace has now expanded so that each SQL step includes the SQL that was run and the number of rows that were affected.
Did you notice that no rows were affected? You have already run the program with values that are currently in the state record.
In summary, what you are looking for is:
• Step Program Flow. Are the steps being run in the correct order?
• SQL Syntax, Data Integrity. What tables are being manipulated and how?
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
151
Using the Application Engine Debugger
Application Engine Debugger
To start the Application Engine Debugger:
1. Launch Configuration Manager.
2. Select the Profile tab.
3. Highlight the Default profile.
4. Click the Edit button.
5. Select the Process Scheduler tab.
6. In the Application Engine group box, select the Debug check box.
Slide 80
Student Notes
Setting Application Engine Debugger.
Application Engine Debug is activated in Configuration Manager.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
152
When the debugger is activated, this screen appears when you launch a program from Application Designer:
To display options and commands available in the Application Engine, enter ? and press Enter.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
153
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
154
Activity 12: Debugging PSU_CUST_CHGIn this activity, you will review the activity overview and run the PSU_CUST_CHG program using Application Engine debug. Specifically, you will:
• Change Configuration Manager settings.
• Launch PSU_CUST_CHG with the debugger active.
Slide 81
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
155
Activity OverviewIn this activity, you will change the Configuration Manager settings to activate the debugger. You will leave the SQL and Step traces active.
Then you will launch PSU_CUST_CHG from Application Designer and use the debugger to look at the values in the state record.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
156
Activity Detailed StepsPerform the detailed steps to complete the activity.
Changing Configuration Manager Settings
To change Configuration Manager settings:
1. Open Configuration Manager.
2. Select the Profile tab.
3. Highlight the Default profile.
4. Click the Edit button.
5. Select the Process Scheduler tab.
6. Select the Debug check box.
7. Click OK.
Launching PSU_CUST_CHG with the Debugger Active
To launch PSU_CUST_CHG with the debugger active:
1. In Application Designer, open PSU_CUST_CHG.
2. Run the PSU_CUST_CHG program by selecting Edit, Run Program.
3. For Run Control ID, enter PSU_CUST_CHG.
4. Click OK.
5. In the Debugger, enter L, then press Enter.
6. Press Enter twice to accept the defaults and display the state record.
Note. To view the Application Engine debugger commands, enter ?, and press Enter.
7. Enter I and press Enter repeatedly, to enter each step in turn, until the program finishes.
8. Repeat the run, trying other Debugger command options.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
157
Testing with Application Engine Restart
Restart
Using Application Engine Restarts is key to protecting data integrity and saving time when Application Engine programs fail and need to be restarted.
Restart permits work that has already been completed to be skipped.
A process can be restarted without danger of processing the same rows again.
Slide 82
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
158
Testing with Application Engine Restart (continued)
Commit Settings
When using Application Engine Restart, you can select several program-level commit settings to make a program restartable:
• Commit after each step in that section.
• Require commits after a specific step.
• Commit frequency within a step or n iterations for looping actions.
Slide 83
Student Notes
Auto Commit
You can specify auto commit at the section level.
You can specify commit frequency at the step level.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
159
Testing with Application Engine Restart (continued)
Enabling Restart
When Restart is enabled, a checkpoint is performed prior to any program level commit.
In the event of failure, when restarted, the program ignores the steps that have already finished up to the last successful commit.
Slide 84
Student Notes
Enabling Restart
Restart information is stored in the AERUNCONTROL table.
To enable restart, clear the Disable Restart check box on the Program Properties, Advanced tab.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
160
The following screen shows the three program level commits: Auto Commit After Step at the section level, Commit After option at the step level, and the Frequency option at the step level.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
161
Activity 13: Testing Restart Using AETESTPROG In this activity, you will review the activity overview and use Application Engine to simulate a restart while running AETESTPROG. Specifically, you will:
1. Activate Application Engine debugging.
2. Run AETESTPROG.
3. Examine the state record and run control record.
4. Run from the Request AE page.
5. Restart AETESTPROG from the command line.
Slide 85
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
162
Activity OverviewPeopleSoft software has a test program called AETESTPROG. This program is designed to test some of the features that can be used with Application Engine.
When you design your programs to restart, you will also want to test that your restart is working as designed. Using the Application Engine Debugger, you can simulate an abend. You will do this with the AETESTPROG program and examine the changes in the run control table PS_AERUNCONTROL and the state table PS_AE_TESTPROG_AET.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
163
Activity Detailed StepsPerform the detailed steps to complete the activity:
Activating Application Engine Debug
To activate Application Engine Debug:
1. Launch Configuration Manager, or access it if is still open.
2. Select the Profile tab.
3. Highlight the Default profile.
4. Click the Edit button.
5. Select the Process Scheduler tab.
6. In the Application Engine group box, select the Debug check box if it is cleared.
7. Click Apply.
Running AETESTPROG
To run AETESTPROG:
1. In Application Designer, open the Application Engine program AETESTPROG.
2. Select Edit, Run Program or use the Traffic Light icon to run the program.
3. For Run Control ID, enter AETESTPROG.
4. Click OK.
5. In the debugger, enter I, then press Enter to enter the first step.
6. Enter S, then press Enter to step through the Do Select.
7. Enter S, then press Enter to step through the Call section.
8. Enter S, and press Enter to step through the Do Select again.
9. Enter S and press Enter to step through the Call section.
10. Enter L, then press Enter
11. Press Enter two more times to display the contents of the state record.
12. Enter S, then press Enter to step back through the Do Select.
13. Enter S, then press Enter to step back through the Call Section.
14. Enter Q, then press Enter to terminate the program.
You should see something like the following results.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
164
15. Enter Y when prompted to terminate the program and press Enter.
Results
Your results should look something like this.
Examining the State Record and Run Control Record
In the run of the preceding program, you ran the call section three times, each time updating the tables. In the trace, PSU_ARCH_RL was the last value successfully processed. Anything after that should not have been saved, because the program was terminated before the checkpoint.
The state record and PS_AERUNCONTROL contain values that indicate what progress AETESTPROG made before it was terminated, and capture the final state of processing after the last checkpoint that was run. You will look at them now.
To examine the state record and run control record:
1. In SQL Developer, enter the following SQL statement and view the results.
SELECT * FROM PS_AERUNCONTROL
This displays the runtime information that was passed to AETESTPROG when it was invoked.
2. Similarly, examine the state record using this statement:
SELECT * FROM PS_AE_TESTPROG_AET
3. Write down the Process Instance. You will need it to restart the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
165
4. Examine the trace file for the program.
The trace file is located in C:\Temp.
The Trace file will be located in the path pointed by %TEMP%\PS\T1B85001. Click Start -> Run and provide %TEMP%\PS\T1B85001 and click Ok to open the temp folder.
Notice that before the program was terminated, the last value of AE_APPLID processed was PSU_ARCH_RL. The work done for this value was rolled back to the checkpoint performed after PSU_ARCH_RL was processed.
The last portion of the trace file will look something like this:
-- 11.46.55 ..(AETESTPROG.STATS.STMTS) (SQL)%Select(AE_INT_7) SELECT COUNT(*) FROM PSAESTMTDEFN WHERE AE_APPLID = 'PSU_ARCH_RL'/-- Buffers:-- 1) 6/ /Restart Data CheckPointed/COMMIT/
-- 11.46.55 ..(AETESTPROG.STATS.MSG) (Log Message)/ /Restart Data CheckPointed/COMMIT/
The rollback is not visible because the program was terminated in the debugger.
Running from the Request AE Page
You will first try to run AETESTPROG using the Request AE page. Then you will look at the status of the AETESTPROG program using the Process Monitor. While restarting the program there is possible, you will rerun it from the command line.
To run from the Request AE page:
1. Select PeopleTools, Application Engine, Request AE.
2. Select the run control ID AETESTPROG, with the program name AETESTPROG.
3. Click RUN.
4. On the Process Scheduler Request page, select the check box next to AETESTPROG. Scroll to the bottomand click OK.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Testing and Debugging Lesson 5
166
5. Navigate to the Process Monitor to check program status.
Select PeopleTools, Process Scheduler, Process Monitor.
The Run Status should be No Success.
When you ran AETESTPROG two-tier, it did not appear in the Process Monitor, but the PS_AERUNCONTROL table was updated, so the program could not be submitted.
6. Examine the Message Log:
a. Click the Details link.
b. Click the Message Log link.
Restarting AETESTPROG from the Command Line
To restart AETESTPROG from the command line:
Because the process was started in two-tier outside of the Process Scheduler, you need to use the command line to launch it so that it can restart and complete the request.
1. Edit the file C:\labs\0411_AppEngine\Bat\AETESTPROG.bat.
You will see the following text:
<PSHOME>\BIN\CLIENT\WINX86\PSAE -CT ORACLE -CD <database> -CO PTTRA -CP PTTRA -R AETESTPROG -AI AETESTPROG -I <pi>
Note. Your instructor will provide the value for <PSHOME> in your classroom (for instance, C:\PeopleTools).
2. Change <database> to your database name (for instance, T1B85001).
3. Change <pi> to the process instance that you wrote down.
4. Highlight the command line and copy it by selecting Edit, Copy
5. Open a command window.
Select Start, Programs, Accessories, Command Prompt.
6. Right-click in the Command Window to paste your statement, and press Enter.
7. Enter L to display values from the checkpoint on the state record.
8. Enter G to complete the program run.
9. When the run is complete, use SQL Developer to again check PS_AE_TESTPROG_AET, and PS_AERUNCONTROL. They should return 0 rows.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 5 Testing and Debugging
167
Review
In this lesson, you learned that:
• You can test Application Engine programs using Process Monitor, the Application Engine trace file, the Application Engine debugger, and the PeopleCode debugger.
• Process Monitor enables you to check Application Engine program status, access run time information, and restart programs initiated in the Process Scheduler.
• You start an Application Engine trace from Configuration Manager, on the Trace tab.
• The Application Engine Debug tool enables you to run a program in step mode, view the state record when it changes and set breakpoints to permit you to determine exactly what your application is doing.
• Restart enables you to both debug an application during development and restart a failed production run.
Slide 86
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic Cross-Reference
Process Monitor Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler, "Using Process Monitor"
Application Engine Traces PeopleTools 8.50 PeopleBook: Data Administration Tools, "PeopleSoft Configuration Manager"
Debugging PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Debugging Application Engine Programs"
Testing Application Engine Restart PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Managing Application Engine Programs"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
169
Lesson 6
Using the Do Select Action
Objectives
By the end of this lesson, you will be able to:
• Describe Do Select.
• Use Select and Fetch.
• Use Reselect.
• Use Restartable.
• Develop an Application Engine program using Do Select.
• Build PSU_CRS_INS.
Slide 88
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
170
Describing Do Select
Do Select
Do Select:
• Is the equivalent of a For loop in an Application Engine program.
• Is driven by a %Select statement SQL.
• Populates a state record with values to be used by other actions.
• Controls execution of subsequent actions in a step.
Slide 89
Student Notes
Do Select
The Do Select action is a Select statement that runs subsequent actions in the step once for every row of data that the Do Select produces. In other words, the subsequent actions within the step are run in a loop based on whether the Select statement in the Do Select action has returned a row. This is equivalent to a For loop.
When the Do Select runs, the first row matching the criteria is loaded into the state record. Then the program proceeds to the next action in the step. When the subsequent actions are completed, the Do Select stores the next row to the state record as specified in the Do Select SQL. Each row of data in the database meeting the criteria is loaded into the state record and processed within the loop.
When no more rows meet the criteria, the program moves to the next step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
171
Describing Do Select (continued)
Do Select Flow Chart
This flow chart illustrates how Do Select creates the equivalent of a For loop in an Application Engine program.
Slide 90
Student Notes
Do Select SQL
The Do Select stores the row in the state record as specified in the Do Select SQL.
Example:
%Select (COURSE, EFFDT, EFF_STATUS, TOOLS_REL) SELECT COURSE, EFFDT, EFF_STATUS, TOOLS_REL FROM PS_PSU_COURSE_TBL WHERE EFF_STATUS = 'I'
Each row of data in the database meeting the criteria is loaded (one loop per row) into the state record and processed in a loop. When no more rows meet the criteria, the program moves to the next step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
172
Describing Do Select (continued)
Do Select Actions
Do Select controls the execution of task-oriented actions: PeopleCode, SQL, Call Section, and Log Message.
This table shows the relationship between Do Select actions and roles:
Action Role
Do When Test Condition
Do While Test Condition
Do Select Test Condition
Slide 91
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
173
Describing Do Select (continued)
Do Select Actions (continued)
Action Role
PeopleCode Run PeopleCode
SQL Run SQL Tasks: Insert, Update, Delete, Meta-SQL
Call Section Call another section
Log Message Issue message to the message log.
Do Until Test Condition
Slide 92
Student Notes
Do Select Actions
When Do Select finds a row, the Application Engine program runs whatever additional actions are part of the step. A very common application of this is to follow the Do Select with a Call Section action to a different section that performs the processing.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
174
Describing Do Select (continued)
Do Select Types
The three Do Select types are:
• Select/Fetch
• Reselect
• Restartable
The Do Select types are differentiated by:
• Cursor handling.
• Checkpointing and commit handling.
Slide 93
Student Notes
Do Select Differences
Differences can be summarized in:
• How the Do Select type handles cursors.
• Whether the Do Select type performs checkpointing.
What Is a PeopleSoft Application Engine Checkpoint?
This can be confusing, because many database systems use checkpoint to describe a timestamp that allows theRDBMS to control rollbacks, and perform specific actions such as updating tables from its workspace and writing information to the database log.
With PeopleSoft Application Engine, a checkpoint in an Application Engine program is the point at which restart information is written out to the PS_AERUNCONTROL table. This is used with restartable programs to allow them to determine where to start processing when they resume after a failure.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
175
Describing Do Select (continued)
Cursors
A cursor is a temporary workspace used by the RDBMS to exchange information with a program.
A cursor is created and opened whenever a SQL statement is sent to the RDBMS.
A cursor's memory buffer can contain multiple rows, retrieved in turn individually by a fetch.
Work done on rows in a cursor is conditional until a commit is carried out.
Rollback discards work done in a cursor back to the last commit.
An Application Engine can have many cursors open simultaneously, and many can be opened and closed during the course of program execution.
Slide 94
Student Notes
Defining a Cursor
Anytime a SQL statement is sent to the database, a cursor must be opened on the database. The cursor is the avenue by which the database communicates the results of that specific request back to the requester. The requester could be an online PeopleSoft page, a SQL query tool, or an Application Engine program; and the results might be that of a SELECT statement, or perhaps other statements such as an UPDATE or INSERT.
While an Application Engine program is running, many cursors can open. Each cursor is responsible for carrying out a specific SQL statement. Cursors are frequently opened and closed during the program's execution. Looping techniques work with many cursors.
Select Statements
When a Select statement is carried out through a cursor, the rows retrieved will be placed into a memory buffer on the database for that cursor. From there, a Fetch is issued to retrieve the rows from the memory buffer as needed. If multiple rows are in the memory buffer, Application Engine can be made to Select then Fetch the rows one at a time from the memory buffer in a loop.
Cursors and Commits
When a cursor is opened and work is performed, it is done so on a conditional basis and has the potential to be undone. If and when a Commit statement is issued to the database, this conditional work is now permanentand cannot be undone.
Within an Application Engine program Commit can be issued during the middle of the program's run. When the Commit is issued, it will be issued across all cursors. This means that any work that has been performed on any cursors that have been opened and closed, or cursors that still remain open, will be permanent changes. Once work is committed, it cannot be undone.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
176
Rollback and the Cursor
A rollback is simply taking all the data that all the cursors have accomplished for your program, and undoing it. When issued, a rollback is done back to the last commit issued. Once a rollback is issued, a commit that immediately follows would have nothing to commit.
A PeopleTools Trace can be configured to display opening and closing cursors by the connect and disconnect commands.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
177
Using Select and Fetch
Select/Fetch Flow
This flow chart illustrates the flow for Select/Fetch:
Slide 95
Student Notes
Select/Fetch Flow
This is the flow for Select/Fetch:
• Select/Fetch opens a cursor to the database and populates it with all rows that meet the SQL select conditions.
• Then it fetches the first row from the cursor.
• If no rows are found, the subsequent actions in the same step are skipped and the next step is run.
• If a row is found, other actions within the same step are run.
• Then it returns to the open cursor to fetch the next row.
• This process repeats for every row in the cursor
• Any commits or checkpoints contained within the loop will be ignored
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
178
Commit Frequency
This diagram assumes that the programmer has set the commit frequency field to 1, for a commit after each iteration of the loop, and that a commit after the step has been added.
This table relates commits and restarts:
State Select/Fetch
Disable Restart Commit
Restartable Ignore
If you make a program restartable, PeopleTools handles the restart (you still need to program for it).
With Disable Restart, commits are performed. This can be dangerous because Application Engine will not do checkpoints. The Application Engine program will not determine where the program ended. The developer assumes all responsibility.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
179
Using Select and Fetch (continued)
Commit Processing
Programs with a Do Select type of Select/Fetch are not restartable from within the loop.
No checkpoints are performed within the loop.
Commits are issued if the program is not restartable.
Select/Fetch commit processing follows these rules:
• If restart is enabled (the default), all commits carried out within Do Select loops are ignored, for example, commits on steps in called sections.
• A COMMIT setting ignored message is written to the trace file for any commits within a Do Select loop.
• If Restart is disabled, commits are not ignored
Slide 96
Student Notes
Disable Restart
Disabling restart is a simple way of telling the application that you are freeing it of the responsibilities of knowing where to restart. That responsibility is now yours via a switch field or an Order By clause.
Commits within the loop are ignored is because of limitations of the checkpoint written to the PS_AERUNCONTROL table. The checkpoint has no way of recording where inside a loop the process stopped. Therefore, a restart at the exact point within the loop is impossible.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
180
Activity 14: Examining PSU_ARCH_SF with Select/FetchIn this activity, you will review the activity overview and trace the program flow for the PSU_ARCH_SF program, examining program flow and the effect of Do Select settings on program execution. Specifically, you will:
1. Examine the program flow for PSU_ARCH_SF.
2. Run PSU_ARCH_SF.
3. Examine the trace.
Slide 97
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
181
Activity OverviewThis activity has two parts. First you will examine the program flow of PSU_ARCH_SF. Then you will run the program and examine what it did, and how it did it.
Specifically, you will look at:
• Program flow.
• Do Select settings.
• Task-oriented actions run by the Do Select.
Then you will run the program and:
• Examine the trace file to see what work was done.
• Verify the program processing in the database.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
182
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining the Program Flow for PSU_ARCH_SF
To examine the program flow for PSU_ARCH_SF:
1. In Application Designer, open the Application Engine program PSU_ARCH_SF.
2. Select the Program Flow tab.
Note the program flow:
Section Step Action Description
MAIN StepM01 Do Select
* * Call Section INSERT
INSERT StepI01 SQL Insert
MAIN StepM02 Log Message 30000, 1
3. Select the Definition tab and expand the MAIN section.
Answer the following questions:
Question Answer
What is the commit frequency?
What is the Do Select type?
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
183
4. Double-click the shaded section of the Do Select action to open the SQL.
The following code appears:
%Select (COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_REL) SELECT COURSE , EFFDT , EFF_STATUS , DESCR , COURSE_TYPE , LENGTH_DAYS , TRAINING_UNITS , ONSITE , INSTRUCTOR , APP_REL , TOOLS_REL FROM PS_PSU_COURSE_TBL WHERE EFF_STATUS = 'I' AND COURSE_TYPE = 'F' ORDER BY COURSE, EFFDT
5. Answer the following question:
Question Answer
What record is being populated by the %Select?
6. Close the Do Select SQL window.
7. Expand the INSERT section.
8. Double-click the shaded section of the SQL action in StepI01.
The following code appears:
INSERT INTO PS_PSU_COURSE_ARCHVALUES (%Bind(COURSE), %Bind(EFFDT), %Bind(EFF_STATUS), %Bind(DESCR), %Bind(COURSE_TYPE), %Bind(LENGTH_DAYS), %Bind(TRAINING_UNITS), %Bind(ONSITE), %Bind(INSTRUCTOR), %Bind(APP_REL), %Bind(TOOLS_REL))
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
184
9. Answer the following question:
Question Answer
What record is providing the values for %Bind(COURSE) and %Bind(EFFDT)?
10. Close the SQL action, SQL window.
11. Answer the following question:
Question Answer
What determines whether the Insert SQL is run?
Running PSU_ARCH_SF
To run PSU_ARCH_SF:
1. Check the data first.
In SQL Developer, run this statement:
SELECT * FROM PS_PSU_COURSE_ARCH
Answer the following question:
Question Answer
How many rows were returned?
2. Select Edit, Run Program or click the traffic light icon to run the program from Application Designer using the Run Request dialog.
3. If the Debugger is active, enter G to run the program.
Examining the Trace
To examine the trace:
1. Open the trace file in C:\temp.
The Trace file will be located in the path pointed by %TEMP%\PS\T1B85001. Click Start -> Run and provide %TEMP%\PS\T1B85001 and click OK to open the temp folder.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
185
2. Answer the following questions:
Question Answer
For each loop of the Do Select, what actions are performed?
How many rows are processed?
How many commits are run, and where?
3. In SQL Developer, run this statement again:
SELECT * FROM PS_PSU_COURSE_ARCH
Answer the following question:
Question Answer
How many rows were returned?
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
186
Using Reselect
Reselect
This flow chart shows the Reselect flow if restart and commits are enabled:
Slide 98
Student Notes
Reselect
This is the flow for Reselect:
• Reselect opens a cursor to the database and populates it with all rows that meet the SQL Select conditions.
• It then fetches the first row from the cursor and then closes the cursor.
• If no rows are found, the subsequent actions in the same step are skipped and the next step is run.
• If a row is found, other actions within the same step are run.
• Then it opens another cursor, reruns the SQL, and repeats the loop.
• This process repeats until the select does not return any rows.
• Any Commits or checkpoints contained within the loop are performed.
Reselect opens and closes a cursor for each row to be retrieved.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
187
Warning! With this type of fetch, you will typically want some aspect of the loop to eventually cause the Select to return no rows. Otherwise, no mechanism is in place by which to exit the loop. This type of Do Select is restartable.
Commit Processing with Reselect
If used, commits are not ignored and will be committed in a Reselect loop.
Program Restart is possible because checkpoints are saved in PS_AERUNCONTROL.
To enable restart:
• Identify the rows to be processed.
• Process Flag.
• Delete rows.
• Order the data values.
• Place commits in the appropriate sections or steps.
Note. The last section and step committed is listed in the AE_RUN_DATA column PS_AERUNCONTROL.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
188
Activity 15: Examining PSU_ARCH_RL using ReselectIn this activity, you will review the activity overview and run the PSU_ARCH_RL program using Do Select with a type of Reselect. Then you will examine the trace file and compare these results with the PSU_ARCH_SF program. Specifically, you will:
1. Examine the program flow for PSU_ARCH_RL.
2. Run PSU_ARCH_RL.
3. Examine the trace.
Slide 99
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
189
Activity OverviewThis activity is very similar to the previous activity.
First, you will examine the program flow of PSU_ARCH_RL. Then you will run the program and examine what it did, and how it did it.
Specifically, you will look at:
• Program flow.
• Do Select settings.
• Task-oriented actions run by the Do Select.
Then you will run the program and:
• Examine the trace file to see what work was done.
• Verify the program processing in the database.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
190
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining the Program Flow for PSU_ARCH_RL
To examine the program flow for PSU_ARCH_RL:
1. In Application Designer, open the Application Engine program PSU_ARCH_RL.
2. Select the Progra Flow tab.
Note the program flow:
Section Step Action Description
MAIN StepM01 Do Select
Call Section INSERT
INSERT StepI01 SQL Insert
StepI02 Call Section DELETE
DELETE StepD01 SQL Delete
MAIN StepM02 Log Message 30000, 1
3. Select the Definition tab and expand the MAIN section.
Answer the following questions:
Question Answer
What is the commit frequency
What is the Do Select type? Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
191
4. Double-click the shaded section of the Do Select action to open the SQL.
The following code appears:
%Select (COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_REL)SELECT COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_RELFROM PS_PSU_COURSE_TBLWHERE EFF_STATUS = 'I'AND COURSE_TYPE = 'H'ORDER BY COURSE, EFFDT
5. Close the Do Select SQL window.
6. Expand the INSERT section.
7. Double-click the shaded section of the SQL action in StepI01.
The following code appears:
INSERT INTO PS_PSU_COURSE_ARCHVALUES (%Bind(COURSE), %Bind(EFFDT), %Bind(EFF_STATUS), %Bind(DESCR), %Bind(COURSE_TYPE), %Bind(LENGTH_DAYS), %Bind(TRAINING_UNITS), %Bind(ONSITE), %Bind(INSTRUCTOR), %Bind(APP_REL), %Bind(TOOLS_REL))
8. Expand the DELETE section.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
192
9. View the SQL.
The following code appears:
DELETEFROM PS_PSU_COURSE_TBLWHERE COURSE = %Bind(COURSE)AND EFFDT = %Bind(EFFDT)AND EFF_STATUS = %Bind(EFF_STATUS)
10. Answer the following question:
Question Answer
In what order are the three sections run?
Running PSU_ARCH_RL
To run PSU_ARCH_RL:
1. In SQL Developer, run this statement to check the data:
SELECT * FROM PS_PSU_COURSE_ARCH
Answer the following question:
Question Answer
How many rows were returned?
2. Run the program from Application Designer using the Run Request dialog box.
3. Select Edit, Run Program or click the traffic light icon.
4. If the Debugger is active, enter G to run the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
193
Examining the TraceTo examine the trace:
1. Open the Trace file created in C:\temp .
2. Answer the following questions.
Question Answer
Where do commits occur?
How many commits are carried out, and how often?
What is done immediately prior to each commit?
3. In SQL Developer, run this statement again:
SELECT * FROM PS_PSU_COURSE_ARCH
Answer the following question:
Question Answer
How many rows were returned?
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
194
Using Restartable
Do Select Loop with Restart Enabled
This flow chart illustrates a Do Select loop with Restart enabled.
Slide 100
Student Notes
Restartable
This is the flow for Restartable:
• Restartable opens a cursor to the database and populates it with all rows that meet the SQL Select conditions.
• Then it fetches the first row from the cursor.
• If no rows are found, the subsequent actions in the same step are skipped and the next step is run.
• If a row is found, other actions within the same step are run.
• Then Restartable returns to the open cursor to fetch the next row.
• This process repeats for every row in the cursor.
• Any Commits or checkpoints contained within the loop are performed.
Restartable performs the same as Select/Fetch, except that a checkpoint is issued.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
195
Warning! Developers need to make sure that the SQL they include within this action is such that, upon restart, it recognizes where the previous run failed and where to restart processing. Various techniques are available that you can use to achieve this, such as employing a processed switch, or to base the next Select onthe key.
This diagram assumes that the programmer has set the commit frequency field to 1 for a commit after each iteration of the loop, and that a commit after the step has been added.
When an Application Engine program starts, it inserts a row in the state record for the assigned process instance. Any %Select meta SQL in the program performs a SQL Update to the referenced state record. If youuse the Order By technique to make your program restartable, your state record needs to be a SQL table to keep the values it needs for restart stored on the database.
Updating the State Record
Application Engine automatically performs all state record updates. When an Application Engine program starts, it inserts a row in the state record for the assigned process instance. Application Engine then updates it whenever it performs a commit to store values in the database.
Commits in Restartable
If commits are used, Restartable commits inside the Do Select loop.
Checkpoints are written to the PS_AERUNCONTROL table.
Restart information is retained in the AERUNCONTROL and state records, provided state records are permanent tables and not derived/work records.
Important! Information is not saved unless the state record is a SQL table.
Program-Level Considerations
The state record where the looping values are recorded must be a SQL table.
Disable Restart must not be checked on the program properties.
If run in two-tier, Disable Restart must not be selected in Configuration Manager on the Process Scheduler tab.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
196
Using Restartable (continued)
Ensuring That Rows Are Not Processed Twice
You need to have some conditions that reduce the answer set returned by the Do Select to ensure that the program does not process rows again if restart is necessary.
Options include:
• Delete processed rows.
• Add a switch to the selected table.
• Add an order by clause.
Slide 101
Student Notes
Example of a SwitchSELECT COLUMN1, COLUMN2,FROM PS_TABLE1WHERE PROCESSING_SWITCH = 'N'
Example of an Order by Clause%SELECT(FIELD1)SELECT FIELD1FROM PS_SOME_RECORD WHERE FIELD1 > %BIND(FIELD1)ORDER BY FIELD1
Example
Here is an example from PSU_ARCH_RB:O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
197
%Select (COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_REL) SELECT COURSE , EFFDT , EFF_STATUS , DESCR , COURSE_TYPE , LENGTH_DAYS , TRAINING_UNITS , ONSITE , INSTRUCTOR , APP_REL , TOOLS_REL FROM PS_PSU_COURSE_TBL WHERE EFF_STATUS = 'I' AND (COURSE_TYPE = 'T'AND COURSE > %Bind(COURSE) OR (EFF_STATUS = 'I' AND COURSE = %Bind(COURSE) AND EFFDT > %Bind(EFFDT))) ORDER BY COURSE, EFFDT
Effective-Date Logic
The slightly more complex condition needs to be added because PSU_COURSE_TBL is an effective-dated table.
Suppose several rows existed for course 1001:
1001 01/01/93
1001 01/01/96
1001 01/01/98
If the program ended abnormally, the where clause would need to pick up the next effective-dated row.
In this example, we commit and checkpoint at a frequency of 2.
1 (row processed)2 (row processed)(Commit and checkpoint)3 (row processed)4 (row processed)(Commit and checkpoint)5 (row processed)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
198
Using Restartable (continued)
AE_STEP_DONE
The AE_STEP_DONE column on the PS_AERUNCONTROL table tracks step processing.
• Set to 'Y' once the entire step, all loops, is complete.
• Set to 'N' if the program terminates in the middle of a step.
Slide 102
Student Notes
AE_STEP_DONE
By checking this column, once restarted, the program knows whether to reprocess the step, to pick up unprocessed rows in the unfinished loop, or to do the step right after the one listed in the AE_RUN_DATA column.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
199
Activity 16: PSU_ARCH_RB Using RestartableIn this activity, you will review the course overview and run the PSU_ARCH_RB Application Engine program using a Do Select with a type of Restartable. Specifically, you will:
1. Examine the program flow for PSU_ARCH_RB.
2. Create test data.
3. Run the program and force an abend.
4. Examine the trace file, state record, and run control.
5. Restart the program to complete processing.
Slide 103
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
200
Activity OverviewYou will run the PSU_ARCH_RB Application Engine program using a Do Select with a type of Restartable.
You will deliberately cause a program failure to observe the state of the environment when an abend occurs.
After running the program, you will examine the trace file to review the program's behavior and compare these results to those of the previous activities.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
201
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining the Program Flow for PSU_ARCH_RB
To examine the program flow for PSU_ARCH_RB:
1. In Application Designer, open the Application Engine program PSU_ARCH_RB.
2. Select the Program Flow tab.
Note the program flow:
Section Step Action Description
MAIN Step 1: ERROR SQL Insert the error row
* Step 2: StepM01 Do Select
* * Call Section INSERT
INSERT Step 1: StepI01 SQL Insert
MAIN Step 3: StepM02 Log Message 30000, 1
3. Select the Definition tab and expand the MAIN section.
Answer the following questions:
Question Answer
What is the commit frequency?
What is the Do Select type?
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
202
4. Double-click the shaded section of the Do Select action to open the SQL.
The following code appears:
%Select (COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_REL)SELECT COURSE, EFFDT, EFF_STATUS, DESCR, COURSE_TYPE, LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_RELFROM PS_PSU_COURSE_TBLWHERE EFF_STATUS = 'I'AND (COURSE_TYPE = 'T'AND COURSE > %Bind(COURSE)OR (COURSE_TYPE = 'T'AND COURSE =%Bind(COURSE)AND EFFDT > %Bind(EFFDT)))ORDER BY COURSE, EFFDT
5. Close the Do Select SQL window.
6. Expand the INSERT section.
7. Double-click the shaded section of the SQL action in StepI01.
The following code appears:
INSERT INTO PS_PSU_COURSE_ARCHVALUES (%Bind(COURSE), %Bind(EFFDT), %Bind(EFF_STATUS), %Bind(DESCR), %Bind(COURSE_TYPE), %Bind(LENGTH_DAYS), %Bind(TRAINING_UNITS), %Bind(ONSITE), %Bind(INSTRUCTOR), %Bind(APP_REL), %Bind(TOOLS_REL))
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
203
Creating Test Data
Some bad data needs to be inserted into the database for this activity.
To create test data:
1. Expand the main section.
2. Double-click the shaded section of the SQL action in the Error step.
The following code appears:
INSERT INTO PS_PSU_COURSE_ARCHVALUES ('1018', '1998-02-01', 'I', 'Reporting with Crystal', 'T', 2.0, 2.0, 'Y', 'SLT', 700, 700)
This code inserts a row into the archive table that the program will later also try to insert, thus causing the program to end abnormally.
Running the Program and Forcing an Abend
To run the program and force an abend:
1. Check the Data first.
In SQL Developer, run this statement:
SELECT * FROM PS_PSU_COURSE_ARCH
2. Answer the following question:
Question Answer
How many rows were returned?
3. Run the program PSU_ARCH_RB from Application Designer using the Run Request dialog box.
4. Select Edit, Run Program or click the traffic light icon.
5. If the Debugger is active, enter G to run the program.
The program should end abnormally.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
204
Examining the Trace File, State Record, and Run Control
To examine the trace file, state record, and run control:
1. Open the trace file in C:\temp.
Note. The Trace file will be located in the path pointed by %TEMP%\PS\T1B85001. Click Start -> Run and provide %TEMP%\PS\T1B85001 and click Ok to open the temp folder.
Most of the information here is similar to the Select/Fetch and Reselect traces captured earlier. The main difference is at the end of the program. You should see something like this:
You can now examine the contents of the state record, PS_PSU_CRACH_AET, and the PS_AERUNCONTROL record.
2. In SQL Developer, run the following statements:
SELECT * FROM PS_AERUNCONTROLSELECT * FROM PS_PSU_CRACH_AET
3. Answer the following question:
Question Answer
What is the PROCESS_INSTANCE number displayed in SQL Developer
This is required to restart the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
205
4. In SQL Developer, run this statement to fix the data error that caused the PSU_ARCH_RB program to end abnormally:
DELETE FROM PS_PSU_COURSE_ARCH WHERE COURSE = '1018'
Restarting the Program to Complete Processing
Because the program was initiated in two-tier using Application Designer, it cannot be restarted using the Process Monitor. A batch file is provided that you will use to restart PSU_ARCH_RB from the command prompt.
1. Using Notepad, right-click and select edit on the file C:\labs\0411_AppEngine\Bat\PSU_ARCH_RB.bat.
2. Change <PSHOME> to the appropriate path for your environment.
3. Change the <database> item to be your database name.
4. Change the <pi> item to be the PROCESS_INSTANCE that you recorded previously.
5. If necessary, verify and change the -R parameter to the Run Control that you used to run the program.
6. Save the file.
7. Close the file
8. Double-click it to run the file.
9. If the debugger appears, press G to continue execution.
10. Compare your results to the following results below.
11. Examine your trace file again.
No errors should occur in the trace file.
12. Examine PS_PSU_CRACH_AET and PS_AERUNCONTROL. They should contain 1 row.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
206
Results
This concludes the activity. Please do not continue.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
207
Developing an Application Engine Program Using Do Select
Phase 1: Design
The first phase in developing an Application Engine program is to analyze and design the application:
1. Determine your data sources.
• Application Designer object references.
• Data models.
• Record Cross Reference page.
2. Develop and process logic pseudocode and program source.
3. Decide whether the program needs to be restartable.
Slide 104
Student Notes
Summary
When developing a program using Do Select, consider this summary:
Do Select Type Definition
Restartable from inside the Do Select loop?
Are program level commits performed inside the Do Select loop? (for restartable Application Engine programs)
Do you need to reduce the result set of the Do Select loop? (by deleting rows or including a processed flag or using an order byclause)
Select/Fetch Opens the cursor once and performs a fetch for each iteration of the loop.
No No No
Reselect Opens a new cursor for each iteration and selects the 1st row that meets the select criteria.
Yes (provided that you code it that way)
Yes Yes
Restartable Opens the cursor once and performs a fetch for each iteration of the loop.
Yes (provided that you code it that way)
Yes Not for standard processing but Yes for restarting.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
208
Developing an Application Engine Program Using Do Select (continued)
Phase 2: Develop and Build Your Application
The second phase in developing an Application Engine program is to create and test your SQL statements:
1. Write and test your SQL statements.
• SQL Tool.
• PeopleSoft Query.
2. Fine-tune your SQL statements for performance.
This is an iterative process. Work with a database administrator (DBA) using Application Engine statistics and traces. Use user optimizers (rule-based or cost-based).
Slide 105
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
209
Developing an Application Engine Program Using Do Select (continued)
Phase 2B. Build Related Definitions
Phase 2B in developing an Application Engine program is to build the following related definitions:
• State records (Application Designer).
• Messages (Message Catalog).
• Method for the user to run the program:
• Process definitions (Process Scheduler).
• Radio buttons (Application Designer).
• Batch files (Text Editor).
Phase 2C in developing an Application Engine program is to create the program in Application Designer:
Slide 106
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
210
Developing an Application Engine Program Using Do Select (continued)
Phase 3. Test and Validate the Program
The third phase in developing an Application Engine program is to test and validate the program:
1. Design your tests.
2. Initialize your data (script for retesting).
3. Test and debug.
4. Validate success.
5. Test for restart capability, if applicable.
Slide 107
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
211
Developing an Application Engine Program Using Do Select (continued)
PSU_CRS_INS
You apply these steps to build PSU_CRS_INS:
1. Analyze and design the application.
2. Develop and build the application.
3. Test the new application.
Slide 108
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
212
Building PSU_CRS_INS
Analyze and Design
Before writing the program, research the data.
Slide 109
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
213
Building PSU_CRS_INS (continued)
Analyze and Design (continued)
Create the program pseudocode.
Slide 110
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
214
Building PSU_CRS_INS (continued)
Develop and Build the Application
Create and test your SQL
1. Use SQL Developer to build SQL.
2. Develop a Select that will result in the row values you want for the Insert (that is, current Financial courserows).
3. Test by hard-coding literal values in your Select to set up the required values.
Slide 111
Student Notes
SQL
Note. To help you create SQL for the lesson exercise, sample SQL is available in this script file: C:\labs\0411_AppEngine\Scripts\ACTIVITY17.txt
Here is the Select statement from ACTIVITY17.txt.
Here is the same Select statement with hard-coded values.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
215
Building PSU_CRS_INS (continued)
Develop and Build the Application (continued)
Build related definitions.
Define a state record (PSU_COURSE_AET):.
1. Insert PROCESS_INSTANCE as the first field in the record.
2. Set PROCESS_INSTANCE as a key.
3. Add any other fields that will be used.
4. Set any date fields (EFFDT) as not required.
5. Save and build the record, creating the SQL table.
6. Verify that the record was built (using SQL Developer).
Slide 112
Student Notes
Documenting Properties
Important! Documenting is not required but is a good practice. Click the Properties button and enter a description and comments.
Warning! If a date field is Required, the build sets Not Null as a default for the field in the database. Application Engine does not know this and tries to insert a blank, which causes the program to end abnormally. Remember: do not set date fields for state records as Required.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
216
Building PSU_CRS_INS (continued)
Develop and Build the Application (continued)
Build the Application Engine program.
Section Step Action Type Statement
MAIN STEPM1 Do Select Type: Select/ Fetch
%SELECT(COURSE, EFF_STATUS, DESCR,LENGTH_DAYS)
SELECT A.COURSE, A.EFF_STATUS, A.DESCR
* * Call Section INSERT
INSERT STEPI1 SQL INSERT INTO PS_PSU_COURSE_TBL VALUES (%BIND(COURSE), %BIND(EFFDT), ?
* STEPI2 Log Message Message Set = 30000 Message Number = 4 Param. = %BIND(COURSE), %BIND(EFFDT)
Slide 113
Student Notes
SQL, Sections, Steps, and Actions
Here is the SQL along with the sections, steps, and actions for PSU_CRS_INS.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
217
Section Step Action Type StatementScript Section #
MAIN STEPM1 Do Select Type: Select/ Fetch
%SELECT(COURSE, EFF_STATUS, DESCR,LENGTH_DAYS, TRAINING_UNITS, ONSITE, INSTRUCTOR, APP_REL, TOOLS_REL)
SELECT A.COURSE, A.EFF_STATUS, A.DESCR, A.LENGTH_DAYS, A.TRAINING_UNITS, A.ONSITE, A.INSTRUCTOR, '850', '850'
FROM PS_PSU_COURSE_TBL A
WHERE A.EFFDT = (SELECT MAX(EFFDT) FROM
PS_PSU_COURSE_TBL
WHERE A.COURSE = COURSE
AND EFFDT <= %CURRENTDATEOUT)
AND A.EFF_STATUS = 'A'
AND A.COURSE_TYPE=%BIND(COURSE_TYPE)
2.1
* * Call Section INSERT None
INSERT STEPI1 SQL INSERT INTO PS_PSU_COURSE_TBL VALUES (%BIND(COURSE), %BIND(EFFDT), %BIND(EFF_STATUS), %BIND(DESCR), %BIND(COURSE_TYPE), %BIND(LENGTH_DAYS), %BIND(TRAINING_UNITS), %BIND(ONSITE), %BIND(INSTRUCTOR), %BIND(APP_REL), %BIND(TOOLS_REL))
2.2
* STEPI2 Log Message Message Set = 30,000 Message Number = 4 Param. = %BIND(COURSE), %BIND(EFFDT)
None
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
218
Building PSU_CRS_INS (continued)
Develop and Build the Application (continued)
Test the Application Engine program.
Slide 114
Student Notes
Page Used to Test the Application Engine Program
Page Name Navigation
Request AE PeopleTools, Application Engine, Request AE
Use the Application Engine Request page to test an Application Engine program.
Use the Message Log subpage from Process Monitor to view messages.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
219
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
220
Activity 17: Creating PSU_CRS_INSIn this activity, you will review the activity overview and build and test the PSU_CRS_INS program. Specifically, you will:
1. Create PSU_CRS_INS.
2. Create the state table.
3. Create the program.
4. Build the sections.
Slide 115
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
221
Activity OverviewYou have done some preliminary preparation together as a class. Now it is time to put the analysis to work, building and testing the PSU_CRS_INS program.
All of the current courses have been updated to PeopleTools 8.50 by course type. Your responsibility is to create an Application Engine program that will update the PSU_COURSE_TBL to insert a new effective-dated rows for courses based on the current class, for a specified course type. The new row will reflect PeopleSoft Application Release 8.50 and PeopleSoft PeopleTools Release 8.50, with an effective date supplied by the user.
You will use Do Select to select the rows into the state record, then insert the new effective-dated rows into PSU_COURSE_TBL row-by-row.
For your convenience, the SQL for this activity is in the following file:
C:\labs\0411_AppEngine\Scripts\ACTIVITY17.txt
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
222
Activity Detailed StepsPerform the detailed steps to complete the activity.
Creating the State Table
To create the state table, create PS_PSU_COURSE_AET by cloning PSU_COURSE_TBL:
1. Open the PSU_COURSE_TBL record.
2. Select File, Save As and name the new record PSU_COURSE_AET. When cloning, a good practice is to do a Save As immediately to protect the original record.
a. Select No when asked if you want to save the PeopleCode.
b. Clicking the Properties button and entering a description and comments for your record is also a good practice.
3. Insert the field PROCESS_INSTANCE as the first field in the record.
4. Right-click the PROCESS_INSTANCE field and select Record Field Properties.
5. Select the Key check box.
6. For existing key fields disable the Key attribute.
PROCESS_INSTANCE should be the only key in the state record.
7. Make EFFDT not required.
Double-click the field, select the Edit tab, and clear the Required check box.
8. Save.
9. Select Build, Current Definition.
a. Select the Create Tables check box and the Execute SQL Now option.
b. Click Build.
10. In SQL Developer, test to ensure that the state record was built.
Use the following SQL statement:
Select * from PS_PSU_COURSE_AET
Creating the Program
To create a new Application Engine program:
1. Select File, New, App Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
223
2. Open the program properties by selecting Select File, Definition Properties or clicking the Properties button.
3. On the General tab, in the Description field, enter Insert New Courses.
4. On the State Record tab, add PSU_COURSE_AET.
5. On the Advanced tab, select the Disable Restart check box.
6. Save the program as PSU_CRS_INS.
Building the Sections
To build the sections:
1. In the MAIN section, in the Description field, enter Select Current Courses.
2. Change the name of Step01 to StepM01.
3. Insert an action.
For the action type, select Do Select.
4. Double-click the Do Select action to open the SQL definition.
5. Copy and paste the SQL from the file in C:\Labs\0411_AppEngine\Scripts\ACTIVITY17.txt.
6. Save.
7. Insert a new section.
a. Name the new section INSERT.
b. For the description, enter Insert New Courses.
8. Insert a Step/Action.
a. Name the Step STEPI01.
b. For Action Type, select SQL.
9. Copy and paste the Insert statement from C:\labs\0411_AppEngine\Scripts\ACTIVITY17.txt into the SQL definition.
INSERT INTO PS_PSU_COURSE_TBL VALUES (%BIND(COURSE), %BIND(EFFDT), %BIND(EFF_STATUS), %BIND(DESCR), %BIND(COURSE_TYPE), %BIND(LENGTH_DAYS), %BIND(TRAINING_UNITS), %BIND(ONSITE), %BIND(INSTRUCTOR),%BIND(APP_REL), %BIND(TOOLS_REL))
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
224
10. Insert another Step/Action.
a. For Action Type, select Log Message.
b. For Message Set, enter 30000.
c. For Number, enter 4.
d. For Parameters, enter %Bind(COURSE), %Bind(EFFDT).
11. Save.
12. Return to MAIN and insert a new action under the Do Select action.
13. For Action Type, select Call Section.
14. For Section Name, select INSERT.
15. Save.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
225
Testing the ProgramTo test the program using the Request AE page:
1. Select PeopleTools, Application Engine, Request AE.
2. Add a new value.
a. For Run Control ID, enter PSU_CRS_INS.
b. For Program Name, enter PSU_CRS_INS.
c. Click Add.
3. On the Application Engine Request page, enter the following information:
Page Element Value or Status
Process Frequency Always
State Record PSU_COURSE_AET
Bind Variable Name COURSE_TYPE
Value F
4. Add another row of parameters.
5. Enter the following information:
Page Element Value or Status
State Record PSU_COURSE_AET
Bind Variable Name EFFDT
Date <Today's Date>
6. Click Run.
7. On the Process Scheduler Request page, select AE Fast Test.
8. Click OK.
9. Navigate to Process Monitor to verify that the process ran successfully.
10. Select PeopleTools, Process Scheduler, Process Monitor.
11. Use SQL Developer to test the table using this SQL statement:
SELECT * FROM PS_PSU_COURSE_TBLWHERE TOOLS_REL = '850'
12. Compare your results to the following results:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
226
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 6 Using the Do Select Action
227
Review
In this lesson, you learned that:
• The Do Select action is a Select statement that runs subsequent actions once for every row of data that the Do Select produces.
• The type of Do select determines the specific looping rules.
• Select/Fetch opens the cursor and retrieves the first row that meets the SQL criteria, performs the subsequent actions, then fetches the next row meeting the criteria. This process continues until no more rows meet the criteria, at which time the cursor is closed and the program continues to the next step.
• Reselect opens and closes the cursor on each iteration of the loop.
Slide 116
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using the Do Select Action Lesson 6
228
Review (continued)
In this lesson, you learned that:
• Restartable acts the same as the select and fetch, except that it commits inside the loop, thus allowing a checkpoint.
• To develop an Application Engine program one needs to:
1. Analyze and design the application.
2. Develop and build the application.
3. Test and validate the program.
Slide 117
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic Cross-Reference
Do Select Types PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
Select and Fetch PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
Using Restartable PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Managing Application Engine Programs"
Steps to Create an App Engine PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs" O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
229
Lesson 7
Incorporating Conditional Processing
Objectives
By the end of this lesson, you will be able to:
• Define Do actions.
• Explain conditional statements in SQL.
• Explain Do action program flow.
• Design a program using conditional processing.
• Use Application Engine libraries.
Slide 119
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
230
Defining Do Actions
Do Actions
The Do actions include:
• Do Select
• Do When
• Do While
• Do Until
Slide 120
Student Notes
Do Actions
The four Do actions—Do Select, Do When, Do While, and Do Until—act as SQL conditions for the carrying out of the other actions: PeopleCode, SQL, Call Section, and Log Message. We looked at Do Select previously, now we will examine the other three Do conditional actions.
Do Select is used as a For loop. Use Do Select to select the rows from the database that you want to process.
The conditional Do actions enable us to process the selected rows based on some specific criteria, or to terminate the loop at a specific time.
The test condition needs to be put in a SQL statement. We will look at how to do that later. We want to reinforce now that these are SQL statements.
Action Continues within step when:
Do When TRUE
Do While TRUE
Do Select TRUE
Do Until FALSE. Opposite-looking for FALSE to continue.
Important! TRUE = row returned, FALSE = no row returned.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
231
Defining Do Actions (continued)
Do When Process Flow
This diagram shows that Do When runs once and allows the next action to run if the test condition is TRUE.
Slide 121
Student Notes
Do When
Do When:
• Contains SQL that tests for a condition.
• Comes first in the order in which it is run within a step.
• Is a Select statement that allows subsequent actions to be run if any rows of data are returned (if TRUE).
• Terminates the entire step when FALSE. No other actions in the step are run.
Do When is similar to an If statement in a programming language. A Do When statement runs before any other actions in the step. If the Do When statement returns any rows, the next action is run. If the Do When conditions are not met, the remaining actions within that step are not run. A Do When action is run just once when a step is run.
Think "Do once if true."
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
232
Defining Do Actions (continued)
Do While Process Flow
As this diagram shows, Do While loops as long as the condition is TRUE.
Slide 122
Student Notes
Do While
Do While:
• Contains SQL that tests for a condition.
• Runs after a Do When, if present, in processing order.
• Is a Select statement that allows subsequent actions to be run if any rows of data are returned.
• Loop continues as long as the condition tests TRUE.
• Terminates the step when FALSE. No further actions in the step are run.
The Do While action is a Select statement that runs before subsequent actions of the step. If the Do While returns any rows of data, the subsequent actions in the step are run. The Do While action runs each time before the next action is repeated. If no rows are returned, Application Engine moves to the next step or section.
The Do While is identical to the WHILE function in other programming languages.
In short, if the Do While does not return any rows, the step is complete.
Do While works the same as a Do Select with the Reselect option in that the cursors open and close on every iteration of the loop. This causes the SQL to be compiled and run on each iteration of the loop.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
233
If the counter is less than 1000, the condition is TRUE and the action is run. In this case, the action is to add 1to the counter. The loop continues adding until the counter reaches 1000.
When the counter equals 1000, the Do While is FALSE and the program moves to the next step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
234
Defining Do Actions (continued)
Do Until Process Flow
As this diagram shows, Do Until loops as long as the condition is FALSE.
Slide 123
Student Notes
Do Until
The Do Until action:
• Contains SQL that tests for a condition.
• Runs after all other actions in the step.
• Runs actions in the step at least once prior to testing the condition.
• Loop continues as long as the condition tests false (SQL returns 0 rows).
• Terminates the step when TRUE.
A Do Until action is a Select statement that runs after each action within a step. If the Select returns any rows of data, the step terminates.
Use a Do Until if you want the processing actions to run at least once, and to run over and over until a certain condition is true, for example, until a Select returns some rows.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
235
You can also use a Do Until to stop a Do Select prematurely. For example, if the Select for the Do Until does not return any rows, then the actions in the step are repeated (except if a Do When appears in the step). Normally, a DO Select continues until no rows are returned. If any rows of data are returned, the DO Until stops and the actions in the step are not repeated.
A Do Until loops as long as the condition is FALSE.
This is the same as a REPEAT UNTIL loop in other programming languages.
Use a Do Until if you want the processing actions to run at least once, then run over and over until a certain condition is true, for example, until a Select returns some rows.
Because the task action is performed before the Do Until, it always runs at least once.
The condition is checked. If it is TRUE, that is, the counter is greater than 1000, then the next step is run. If the condition is FALSE, then the loop continues until it is true.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
236
Explaining Conditional Statements in SQL
Test for a Condition
To test for a condition, a SQL statement returns TRUE if a row is returned or FALSE if no row is returned.
For example:
SELECT 'X' FROM PS_INSTALLATION WHERE %Bind(COUNTER) < 1000;
• Returns X (True) if COUNTER in the state record is less than 1000.
• Returns nothing (False) if the value is equal to or greater than 1000.
Slide 124
Student Notes
SQL Test for a Condition
When a condition is TRUE in a SELECT statement, SQL does not need to return an actual field value:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
237
Coding SQL to Return TRUE or FALSE
You may understand the principles of the Do action looping constructs, but how do you code for this in SQL to return TRUE or FALSE when we want to test for Counter < 1000?
In PeopleCode, you could use an IF statement, but because Application Engine Do statements use SQL, you need to be creative.
You may notice that PeopleSoft-supplied programs use the PS_INSTALLATION table to determine TRUE or FALSE.
For instance:
Select 'X' from PS_INSTALLATION
This SQL select always returns true because one row is always in PS_INSTALLATION.
Just use the literal X to indicate whether at least one row was returned. You could get multiple rows, but you need only one row to satisfy the condition.
You can use this example online to check it.
ExampleSELECT STATE FROM PS_STATE_TBL where STATE = 'CA'
Returns one row: CA. So this translates to TRUE.
Select 'X' FROM PS_STATE_TBL where STATE = 'CA'
Returns 'X'. This also translates to TRUE.
SELECT STATE FROM PS_STATE_TBL where STATE = 'mm'
No rows are returned. This translates to FALSE
Because your condition is being tested by the WHERE clause of your SQL statement, in some cases which table you select from does not matter.
For instance, if you are checking a condition on your state record using %Bind to read a value from it, the FROM table is irrelevant.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
238
Because you need only one 'X' returned if your condition is TRUE, any one-row table suffices in your FROMclause.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
239
Explaining Conditional Statements in SQL (continued)
SQL State Record
The following table shows the interaction between the SQL test condition and the state record.
SQL Result
%SELECT(TEMP_FLD) Meta-SQL to write 'X' to state record
SELECT 'X' If 'X' is returned, this equals TRUE
FROM PS_INSTALLATION Fulfills the SQL Syntax requirement for a FROM table
WHERE %BIND(COUNTER) > 10 Condition to be tested, value (%BIND) from the state record.
Slide 125
Student Notes
%Select
All SQL Select statements in an Application Engine action must be preceded by a %Select to write the value to the state record. You generally use the TEMP_FLD to write the value to, which acts as a container for the 'X' retrieved from the database if your condition is TRUE. Once the 'X' is written to the field, you do not needit. A subsequent Select 'X' statement in your Application Engine program overwrites it, and generally the character is not used in your processing.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
240
Explaining Do Action Program Flow
Do Action Program Flow
This diagram shows that the order of your actions determines what is run.
Slide 126
Student Notes
Order of Execution
Multiple action types must run consistently with another, so the order in which actions run is significant. At runtime, actions defined for a given step are evaluated based on their action type. All of the actions types exist within a strict hierarchy of execution. (For example, if both a Do When and PeopleCode action exist within a given step, the Do When is always run first.)
The order of execution within a step is:
• Do When
• While
• Select
• PeopleCode
• SQL
• Log Message
• Do Until
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
241
• XSLT
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
242
Designing a Program Using Conditional Processing
Steps of Program Construction
The steps of program construction are:
1. Design application.
2A. Create and test SQL steps.
2B. Build related definitions.
2C. Write application.
3. Test application.
Slide 127
Student Notes
Steps of Program Construction
The steps of program construction are:
1. Design application.
1. Determine output and data sources.
2. Determine program flow, pseudocode.
3. Determine additional definitions needed.
This is when you determine your outputs and data sources, how the application will function (you can start with pseudocode), and any additional definitions that you may need to build to support your application. One aspect of planning and design that gets skipped is the form of the output. Clearly defining the end result simplifies the process of getting there.
2A. Create and test SQL steps.
1. Build your SQL.
2. Test SQL.
Use your third-party SQL tools to build your SQL. Test the SQL to determine whether it is functioning properly and also test with the tuning tools of your database platform to ensure that the SQL is as efficient as possible.
2B. Build related definitions, including:
1. State record.
2. Temporary tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
243
3. Messages.
4. Process definitions.
Build any of the supporting definitions you will need for your program (for example, state record, temporary tables, messages, process definitions).
2C. Write application.
Define the Application Engine program in the Application Designer. Actually creating the individual sections, steps, and actions for the Application Engine Program is minor compared to the work that should getput into the other steps. This step should be a "connect the dots" exercise, plugging in the pieces you built earlier, translating the pseudocode into program sections, steps, and actions, and plugging in SQL, message numbers, and so forth.
3. Test application.
Test, Test, test! Use tracing, the Debugger, sample data, and so on, to make sure the new application performsas specified.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
244
Designing a Program Using Conditional Processing (continued)
Step 1: Application Design
In step 1, you will design a program that will increment a counter if the number of students enrolled in a course session exceeds the maximum enrollment for that session.
A message should be issued if the counter reaches a certain number.
Slide 128
Student Notes
Data Model
The following data model shows the data sources for the WAITLIST program.
Pseudocode
Here is possible pseudocode for the WAITLIST program:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
245
01) Begin Program02) For each course session03) determine max enrollment04) determine enrollment count 05) if enrollment count >= max enrollment (you may over fill a class)06) then increment class counter07) end if08) end for09) if class counter > 1510) then issue message stating coordinator deserves a bonus11) end if12) End ProgramVariables required: CLASS_COUNT, MAX_ENROLL, ENROLL_COUNT
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
246
Designing a Program Using Conditional Processing (continued)
Step 2A: Create and Test SQL Steps
In step 2A you will:
• Validate your Selects with what is in the table.
• Validate your Count with what is in the table.
• Enroll Table (Where Course=1001 and Session Nbr = 1).
• Session Table (Where count(*) >= MAX_ENROLL).
Slide 129
Student Notes
2A. Create and Test SQL Steps
As you did in PSU_CRS_INS, you need to use your SQL tool to validate the basic SQL that does the job.
You want to do this before you modify or add the SQL into your Application Engine program.
The combined Select counts enrollments in course sessions and displays one row per course session. You can see the count next to the Max enrollment column. If the count is greater than or equal to (>=) the max enrollment, then the session increments the counter for the coordinator.
Here you would apply the structure derived from the application design and validate that the SQL and the data available will actually yield the results you want.
The following SQL is in the file:.C:\labs\0411_AppEngine\SQL\Activity18.sql.
Test your Selects in SQL Developer.
SELECT COURSE , SESSION_NBR , MAX_ENROLL FROM PS_PSU_CRS_SESSN
Test your Select COUNT(*) in SQL Developer.
SELECT COUNT(*) FROM PS_PSU_STU_ENROLL WHERE COURSE = '1001'
SELECT C.COURSE, S.SESSION_NBR, C.MAX_ENROLL, COUNT(*) FROM PS_PSU_CRS_SESSN C , PS_PSU_STU_ENROLL S WHERE C.COURSE = S.COURSE AND C.SESSION_NBR = S.SESSION_NBR GROUP BY C.COURSE, S.SESSION_NBR,MAX_ENROLL HAVING COUNT(*) >= MAX_ENROLL ORDER BY COUNT(*) DESC , C.COURSE
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
247
Designing a Program Using Conditional Processing (continued)
Step 2B. Build Related Definitions
In Step 2B, you will:
• Create new fields.
• Define state records.
• Create messages in the Message Catalog.
Slide 130
Student Notes
Create New Fields
• Determine what data items the program needs.
• If necessary, create new fields.
• Choose the appropriate data type and size.
Define State Records
• Make a copy of an existing record, if possible.
• Select File, Open PS_PSU_CRS_SESSN.
• Select File, Save as PS_WAITLIST_AET.
• Add PROCESS_INSTANCE as the first and only key field
• Remove unneeded fields.
• Add PROCESS_INSTANCE as the first field and the only key.
• Add additional fields as needed.
Add ENROLL_COUNT, CLASS_COUNT and TEMP_FLD.
Message Catalog
Once you determine what messages will be generated by the application, add them to the Message Catalog. Message Sets 20000 and above are reserved for customer messages.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
248
Page Used to Create Messages
Page Name Navigation
Message Catalog PeopleTools, Utilities, Use, Message Catalog
Use the Message Catalog page to create messages for a Log Message action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
249
Designing a Program Using Conditional Processing (continued)
Step 2C. Write the Application.
Create the WAITLIST Application Engine program.
Slide 131
Student Notes
Pseudocode
Here is the pseudocode for the WAITLIST program:
Nbr SECTION STEP ACTION TYPE
1 MAIN STEPM1 Do Select Select /Fetch
2 * * Call Section
7 * * Do Until
8 * STEPM2 Do When
9 * * Call Section
3 COMPARE STEPC1 SQL
4 * STEPC2 Do When
5 * * Call Section
6 ADDCOUNT STEPA1 SQL
10 BONUS STEPB1 Log Message
The following file contains the code for the WAITLIST program:
C:\labs\0411_AppEngine\Scripts\Activity18.txt
The following table shows the completed program.
The Script Section column gives a reference to the specific action documented in the script.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
250
Section Step Action Type StatementScript Section
MAIN STEPM1 Do Select Select /Fetch
%SELECT(COURSE, SESSION_NBR, MAX_ENROLL)
SELECT COURSE, SESSION_NBR, MAX_ENROLL
FROM PS_PSU_CRS_SESSN
1.1.1
* * Call Section COMPARE None
* * DO Until %SELECT(TEMP_FLD)
SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(CLASS_COUNT) > 15
1.1.3
* STEPM2 Do When %SELECT(TEMP_FLD)
SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(CLASS_COUNT)> 15
1.2.1
* * Call Section BONUS
COMPARE STEPC1 SQL %SELECT(ENROLL_COUNT)
SELECT COUNT(*)
FROM PS_PSU_STU_ENROLL
WHERE COURSE = %BIND(COURSE) AND SESSION_NBR = %BIND(SESSION_NBR)
2.1.1
* STEPC2 DO When %SELECT(TEMP_FLD)
SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(ENROLL_COUNT) >= %BIND(MAX_ENROLL)
2.2.1
* * Call Section ADDCOUNT None
ADDCOUNT STEPA1 SQL %SELECT(CLASS_COUNT)
SELECT %BIND(CLASS_COUNT) + 1 FROM PS_INSTALLATION
3.1.1
BONUS STEPB1 Log Message 30000,5
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
251
Designing a Program Using Conditional Processing (continued)
Step 3. Test the Application
In step 3 you will:
• Trace statement timings.
• Run from Application Designer.
• Save the trace to compare with others generated later.
• Activate and test using the Debugger.
Slide 132
Student Notes
Repeating the Cycle
Repeat the following cycle as required until WAITLIST performs as designed:
1. Debug the program.
2. Trace the execution.
3. Examine the output.
4. Modify the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
252
Activity 18: Building the WAITLIST programIn this activity, you will review the activity overview and build the WAITLIST program. Specifically, you will:
1. Create and test the SQL steps.
2. Build related definitions.
3. Write the WAITLIST application.
4. Test the application.
Slide 133
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
253
Activity OverviewPeopleSoft University employs a Wait List Coordinator who is responsible for ensuring that all PeopleSoft classes are filled. If the Wait List Coordinator has filled more than 15 classes, he or she will receive a bonus.
This nonrestartable Application Engine program reviews the Student Enrollment table and compares the maximum enrollments for a course session to the number of students enrolled for that session. A cash bonus is awarded to the Wait List Coordinator if more than 15 sessions are filled to capacity.
The SQL for this activity is in the file C:\labs\0411_AppEngine\Scripts\Activity18.txt.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
254
Activity Detailed StepsPerform the detailed steps to complete the activity.
Creating and Testing the SQL Steps
To create and test the SQL steps:
1. Open the file C:\labs\0411_AppEngine\SQL\Activity18.sql.
2. Run the SQL statements in SQL Developer, and verify that they run correctly.
-- Look at the PS_PSU_CRS_SESSN table for contentSELECT COURSE, SESSION_NBR, MAX_ENROLL FROM PS_PSU_CRS_SESSN-- Look at the PS_STUDENT_ENROLL table for content.SELECT COUNT(*) FROM PS_PSU_STU_ENROLL-- Develop the Count of all Courses and see if you have any Full classes.
SELECT C.COURSE, S.SESSION_NBR, C.MAX_ENROLL, COUNT(*) "ENROLL_COUNT" FROM PS_PSU_CRS_SESSN C, PS_PSU_STU_ENROLL S WHERE C.COURSE = S.COURSE AND C.SESSION_NBR = S.SESSION_NBR GROUP BY C.COURSE, S.SESSION_NBR, C.MAX_ENROLL HAVING COUNT(*) >= C.MAX_ENROLL ORDER BY COUNT(*) DESC , C.COURSE
Building Related Definitions
To build related definitions:
1. Create the CLASS_COUNT field in Application Designer.
2. Enter the following information:
Element Value or Status
Data type Number
Integer positions 3
Decimal positions 0
Label ID WAITLIST
Short name and Long name Class Count
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
255
3. Create a state record.
a. Open the record PSU_CRS_SESSN.
b. Select File, Save As.
c. Name the new record WAITLIST_AET.
Click NO to the warning message.
d. Delete all but the following fields:
COURSE
SESSION_NBR
MAX_ENROLL
e. Insert the following fields:
PROCESS_INSTANCE.
ENROLL_COUNT
CLASS_COUNT
TEMP_FLD
f. Make PROCESS_INSTANCE a key.
g. Remove the key attribute from all other fields.
h. Save.
4. Build the SQL table.
a. Select Build, Current Definition.
b. Select the Create Tables check box.
c. Select the Execute SQL Now option.
d. Click Build.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
256
5. Create a new message in the Message Catalog.
a. Select PeopleTools, Utilities, Administration, Message Catalog.
b. Select Message Set 30000.
c. Click the + button to add a new row.
d. Enter the following information:
Page Element Value or Status
Number 5
Severity Message
Message Text Waitlist Coordinator qualifies for a Bonus!
e. Save.
Write the WAITLIST Application
To write the WAITLIST application:
1. In Application Designer, select File, New, Definition Type: Application Engine program.
2. Save as WAITLIST.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
257
3. Insert sections, steps, and actions to match the structure shown in the following table:
Section Step Action Type StatementScript Section
MAIN STEPM1 Do Select Select/Fetch
%SELECT(COURSE, SESSION_NBR, MAX_ENROLL) SELECT COURSE, SESSION_NBR, MAX_ENROLL FROM PS_PSU_CRS_SESSN
1.1.1
* * Call Section COMPARE None
* * DO Until %SELECT(TEMP_FLD) SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(CLASS_COUNT) > 15
1.1.3
* STEPM2 Do When %SELECT(TEMP_FLD) SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(CLASS_COUNT)> 15
1.2.1
* * Call Section BONUS None
COMPARE STEPC1 SQL %SELECT(ENROLL_COUNT) SELECT COUNT(*) FROM PS_PSU_STU_ENROLL WHERE COURSE = %BIND(COURSE) AND SESSION_NBR = %BIND(SESSION_NBR)
2.1.1
* STEPC2 DO When %SELECT(TEMP_FLD) SELECT 'X' FROM PS_INSTALLATION WHERE %BIND(ENROLL_COUNT) >= %BIND(MAX_ENROLL)
2.2.1
* * Call Section ADDCOUNT None
ADDCOUNT STEPA1 SQL %SELECT(CLASS_COUNT) SELECT %BIND(CLASS_COUNT) + 1 FROM PS_INSTALLATION
3.1.1
BONUS STEPB1 Log Message 30000,5
• The code for the steps is contained in the file
C:\labs\0411_AppEngine\Scripts\Activity18.txt.
• The Script Section column gives a reference to the specific action documented in the script.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
258
4. Specify WAITLIST_AET as the default state record.
a. Select File, Definition Properties to access the program properties.
b. Select the State Records tab.
c. In the Qualify Search field, enter WAITLIST.
d. Click the Get List button. (Do not press Enter or the dialog box will close with no changes.)
e. Highlight WAITLIST_AET in the list.
f. Click the Add button.
5. Disable Restart.
a. In the program properties, select the Advanced tab.
b. Select the Disable Restart check box.
6. Click OK to dismiss the dialog.
7. Save.
Test the Application
To test the application:
1. Activate trace statement timings on Configuration Manager.
a. In Configuration Manager, make sure Debugger is deactivated.
Select the Profile tab.
Click the Edit button.
Select the Process Scheduler tab.
Clear the Debug check box.
Click OK.
b. Select the Trace tab.
c. Leave the SQL and Step Trace check boxes active and select the Statement Timings (file) check box as well.
d. Click OK.
2. Launch the program from Application Designer by selecting Edit, Run Program, or click the traffic light button..
3. If the program fails, turn off traces and test using the Debugger.
4. When the program is successful, run it using the Request AE page to see the message on the Message Log.
5. Select PeopleTools, Application Engine, Request AE.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
259
6. Enter the following information:
Page Element Value or Status
Run Control ID WAITLIST
Program Name WAITLIST
7. Click OK.
8. Navigate to Process Monitor to check the results.
Select PeopleTools, Process Scheduler, Process Monitor.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
260
Using Application Engine Libraries
Application Engine Library
An Application Engine library:
• Is a collection of shared Application Engine program sections.
• Contains sections defined as Public.
• Cannot be defined to run standalone.
• Does not require a MAIN section.
• Is not intended to store a specific SQL action within a section.
Slide 134
Student Notes
Application Engine Libraries
Most Application Engine programs are defined to be executable. An executable program has a main entry point in its definition: the section MAIN. This defines the entry point, so whatever method you choose to invoke the program, such as command line or Process Scheduler, can initiate the program.
However, in some cases, you may want a program to contain only a collection, or library, of common routines(in the form of callable sections) that you do not want to run as a standalone program. When sections are defined as Public, other programs can call the sections, or routines, that exist in the program at runtime. This is not a special feature of Application Engine Libraries because any section in an Application Engine programcan be marked as public and then called from other programs.
Because this type of program is not designed to run as a standalone program, it does not require the MAIN Section, or initial entry point.
Important! Setting the Application Library option renames the MAIN section.
Application Libraries are the appropriate place to store a collection of shared Application Engine program sections. It is not intended to store a specific SQL action within a section.
When you select the Application Library check box, you are prompted to rename the sections. (Yes, you could rename it MAIN, but don't.)
Be careful. Oracle does actually deliver some Application Engine programs that are flagged as Application Libraries, but that contain MAIN sections that get run. An example is TL_TIMEADMIN from the Time and Labor product.
Important! To share common SQL, use SQL definitions.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
261
Creating an Application Engine Library
To create an Application Engine Library:
1. Create a new Application Engine program.
2. In the Application Engine program properties, select the Application Library check box.
3. Add Sections, steps, and actions for the callable section.
4. Select the Section Access/Public check box.
5. Save the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
262
Activity 19: Creating an Application Engine LibraryIn this activity, you will review the activity overview and:
1. Create an Application Engine library.
2. Add a callable BONUS section to the library.
3. Modify the WAITLIST program to call the BONUS section.
Slide 135
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
263
Activity OverviewYou may want to call the section BONUS from several different Application Engine programs. In this activity, you will create an Application Engine library to use in this course, and you will include BONUS as the section. Then you will modify the WAITLIST program to call the BONUS section in your new Application Engine library.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
264
Activity Detailed StepsPerform the detailed steps to complete the activity.
Creating an Application Engine Library
To create an Application Engine library:
1. In Application Designer, create a new Application Engine program.
You will get the section MAIN.
2. In the Program Properties, Advanced tab, select the Application Library check box.
3. Click OK.
4. You will get a message that the section MAIN will be renamed. Click OK.
Adding a Callable BONUS Section to the Library
To add a callable BONUS section to the library:
1. In the program, change the name of Section1 to BONUS.
2. Select View, Show All Details.
3. In the BONUS section, under Access, select the Public check box.
4. Save the program as PSU_AELIB.
5. Insert an action.
6. Enter the following information:
Page Element Value or Status
Action Type Log Message
Message Set 30000
Number 5
7. Save.
Modifying the WAITLIST Program to Call the BONUS Section
To modify the WAITLIST program to call the BONUS section:
1. In the WAITLIST program, delete the section BONUS.
2. In the MAIN section, in step StepM2, change the Call Section action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
265
3. Enter the following information:
Page Element Value or Status
Section Name BONUS
Program ID PSU_AELIB
4. Save.
5. To test the program, run it from Application Designer.
6. Compare the trace file with the following results.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Incorporating Conditional Processing Lesson 7
266
Review
In this lesson, you learned that:
• The four Do actions—Do Select, Do When, Do While, and Do Until—act as SQL conditions for the execution of the other actions.
• To test for a condition, a SQL statement will return TRUE if a row is returned or FALSE if no row is returned.
• The Do actions run in a specific order: Do When, Do While, Do Select, Do Until.
Slide 136
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 7 Incorporating Conditional Processing
267
Review (continued)
In this lesson, you learned that:
• The steps of program construction are:
1. Design the application.
2A. Create and test SQL steps.
2B. Build related definitions.
2C. Write the application.
3. Test the application.
• You can store executable sections in Application Libraries and call them from other Application Engine programs.
Slide 137
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic Cross-Reference
Do Actions PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
Conditional Processing PeopleTools 8.50 PeopleBook: PeopleSoft Application Designer, "Creating Component Definitions"
Application Engine Libraries PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs" O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
269
Lesson 8
Using PeopleCode with Application Engine
Objectives
By the end of this lesson, you will be able to:
• Identify how to use PeopleCode in Application Engine programs.
• Insert PeopleCode into an Application Engine program.
• Describe dynamic calls.
Slide 139
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
270
Identifying How to use PeopleCode in Application Engine Programs
PeopleCode in Application Engine Programs
When to use PeopleCode in Application Engine:
• Testing for conditions (If-Then-Else).
• Computing (for example: calculations, string manipulation).
• Performing data preparation tasks (for example, evaluating data from run controls).
• Building dynamic portions of SQL, while still relying on SQL to complete the bulk of the actual program processing.
• Reusing online logic that is already developed (for example,: Funclibs).
• Accessing new PeopleTools functions.
Slide 140
Student Notes
PeopleCode
PeopleCode in Application Engine Programs
Keep in mind that Application Engine is a development tool that allows you to develop programs that executeSQL, in batch and online mode, against your data in a procedural and dynamic structure. The key word in the previous statement is SQL.
Despite Application Engine's richer functionality, its primary purpose is still to run SQL against your data. However there are certain tasks that PeopleCode is better suited for and can therefore perform efficiently in your Application Engine programs.
Application Engine is not intended to execute programs that include nothing but PeopleCode actions.
Inserting PeopleCode into Application Engine programs provides an opportunity for you to reuse common function libraries and improve performance. It can simplify development in some instances, as well. In many cases, a small PeopleCode program used instead of a Do When Action, for example, can replace a more complicated SQL statement.
There are few restrictions in terms of how you take advantage of PeopleCode in your Application Engine program. However, as with most software development tools, there is an intended use for a given tool. Application Engine PeopleCode is an excellent way to build dynamic SQL, perform simple IF/THEN/ELSE edits, set defaults, and perform other tasks that don't require a trip to the database.
With PeopleCode actions, your Application Engine programs can solve a wider range of business problems with added flexibility. However, when using PeopleCode in Application Engine programs, it's important not to lose sight of Application Engine's purpose.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
271
Application Engine is a development tool that allows you to develop programs to execute SQL, in batch and online mode, against your data in a procedural and dynamic structure.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
272
Inserting PeopleCode into an Application Engine Program
Inserting a PeopleCode Action
To insert a PeopleCode action:
1. Insert an action.
2. For Action Type, select PeopleCode.
3. Save.
Slide 141
Student Notes
PeopleCode Editor
There are three main parts to the PeopleCode Editor:
• The left drop down box allows you to select a step in the Editor.
• The right drop down box contains the only PeopleCode event available in Application Engine, OnExecute.
• The main window displays the code.
PeopleTool Used to Edit PeopleCode
PeopleTool Name Navigation
PeopleCode Editor 1. Double click on the gray area for the PeopleCode action.
2. Select View, PeopleCode.
3. Right-click and select View PeopleCode from the popup menu.
Use the PeopleCode Editor to write and modify PeopleCode actions in Application Engine programs.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
273
There are three main parts to the PeopleCode Editor:
• The left drop-down box allows you to change which PeopleCode program you are working with directly through the Editor.
All steps with PeopleCode actions appear in this list, and the steps appear in bold type. To change from one PeopleCode program to another just choose the step.
• The right drop down box has no effect when the PeopleCode Editor is accessed through Application Engine. It is normally used to select the PeopleCode Event that the code should be attached to, but in Application Engine, OnExecute is the only event available.
• The final portion of the PeopleCode Editor is the main editor window. This works similar to Notepad or other common text editors.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
274
Inserting PeopleCode into an Application Engine Program (continued)
PeopleCode Editor Features
PeopleCode Editor editing features:
• Standard text editing functions:
• Drag and drop.
• Validate syntax.
Slide 142
Student Notes
General Features
The PeopleCode Editor supports the standard text editing features and functions, such as Save, Cut, Copy, Paste, Find, Replace, and Undo. These can be invoked through the appropriate menu or by using the toolbar icons shown below. Also, most of them (except Save) are available from a popup menu when you right-click in the editor.
A time saving feature is drag-and-drop editing. You can drag and drop text or object names from the project workspace, or another window (including other PeopleCode Editor windows).
You can access object definitions or PeopleCode functions by right clicking on the object name or function and choosing View Definition or View Function from the popup menu.
Validate Syntax
A key feature of the PeopleCode Editor is syntax validation. This occurs automatically on Save, or if you click the Validate Syntax button. This will check all your syntax for errors, including bad object references (that is, reference to non-existent fields) and missing parameters.
Note. Validate syntax will not validate anything within quotations or after reserved words (such as RECORD).
You do not need to concern yourself with formatting your code. When you save or validate the PeopleCode program, the system will automatically format the code for you. This holds true for anything except quoted literals, which are not formatted. Also, PeopleCode is case-insensitive (again except for quoted literals).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
275
Inserting PeopleCode into an Application Engine Program (continued)
PeopleCode Variables
This table summarizes PeopleCode variables:
Variable Type Life Span Notes
Local PeopleCode program Only available for the duration of the PeopleCode program in which they are declared.
Global Application Engine Program Available while the Application Engine program is running. They are saved at checkpoints, so they can be used for restarts.
Component Application Engine Program Same as Global PeopleCode variables for Application Engine.
Slide 143
Student Notes
PeopleCode Variables
Question: Will a SQL statement recognize a value stored in a PeopleCode global variable?
For example if I declare a global variable &MyValue in a PeopleCode action and store '5' in the variable, will the following SQL statement work?
Update ps_psu_course_tbl set units = &myvalue
Answer: It depends on where you are executing the code:
In a PeopleCode action, you could pass the variable in as an argument for a SQL object or a SQL exec statement:
For instance:
&SQL = CreateSQL("update ps_psu_course_tbl set units = :1");&SQL.Execute(&myvalue);
In a SQL action you would need to have a field in your state record assigned the value you wanted to bind in.
Action = PeopleCode Staterec_aet.field1 = &myvalue; Action = SQL Update ps_psu_course_tbl set units = %bind(field1)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
276
Inserting PeopleCode into an Application Engine Program (continued)
Declaring PeopleCode Variables
To declare a PeopleCode variable:
<Scope> <datatype> <varName>;
Follow these principles:
• Scope can be Local, Component, or Global.
• The data type can be any of the conventional or object data types.
• Variables are denoted with an "&" prefix, such as
&MYROW or &Course
Slide 144
Student Notes
Declaring PeopleCode Variables
See PeopleBooks for a complete and current list conventional and object data types.
Local variables do not need to be declared, but it is always good programming practice to declare all variables. They can take on the appropriate data type when a value is assigned to the variable.
At the time you declare a local variable, you can also assign it an initial value.
Local Number &MyVariable = 3;
Global and Component variables must be declared.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
277
Inserting PeopleCode into an Application Engine Program (continued)
Referencing Fields
Follow these guidelines when referencing fields in PeopleCode within Application Engine programs:
• RECORD.FIELD references can only refer to fields that exist on a state record.
&Name = EMPLOYEE.NAME;&Name = GetRecord(RECORD.EMPLOYEE).GetField(FIELD.NAME).Value;
• Component buffers, controls, and other field objects are not accessible.
Slide 145
Student Notes
PeopleCode in online and Batch Modes
There are significant differences between executing PeopleCode in online and batch modes. Application Engine programs run in batch mode, so your PeopleCode can't access pages or controls as it can while running in online mode. In short, any PeopleCode operations that manipulate pages will not run successfully. Even if you invoke your Application Engine program online from a record or a page using the CallAppEngine PeopleCode function, the Application Engine PeopleCode still does not have direct access to the Component buffers.
Any RECORD.FIELD references that appear in a PeopleCode action can only refer to fields that exist on an Application Engine state record. Page buffers, controls, and so on are inaccessible even if you define the pagerecords as state records on the Program Properties dialog. An Application Engine program can only access state records or definitions you create in PeopleCode.
There are multiple methods used to reference fields in PeopleCode. Of the various methods, only two apply toApplication Engine.
First, you can refer to the field using the syntax <RecordName>.<FieldName>. For example, you would refer to an employee's name using EMPLOYEE.NAME.
Second, you can use object-oriented dot notation. For example, you can assign the employee's name to a variable using the following syntax:
&NAME = GetRecord(RECORD.EMPLOYEE).GetField(FIELD.NAME).Value;
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
278
Inserting PeopleCode into an Application Engine Program (continued)
Assignment Statements
The format for assignment statements is:
Field|Variable = expression;
The expression may be a constant, another variable, a field, or a calculated value.
For example:
&text1 = "String constant";&var1 = &var2;&avg = (&var3 + &var4) /2;
All statements end with a semi-colon.
Slide 146
Student Notes
Comments
All PeopleCode executable statements should end with a semi-colon.
Comments should also be included in all PeopleCode customizations.
To comment you can use Rem or Remark and end the comment with a semi-colon or you can delineate a comment by using /* to begin the comment and */ to end the comment.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
279
Inserting PeopleCode into an Application Engine Program (continued)
The If-Then Statement
The parameter in the Exit function controls the path the Application Engine program will take.
• "1" indicates that the On Return instruction will be executed.
• "0" tells the program to ignore the On Return action.
For example:
If &Test = 10 ThenExit(0); /* or can use Exit 0; */ElseExit(1); /* or can use Exit 1; */End-If;
Slide 147
Student Notes
The If-Then Statement
In the Application Engine, the If-Then statement is used to control flow of execution with the exit statement. The setting of the Exit can cause the next Application Engine step to conditionally be skipped.
Note that if unspecified, "0" is the default, non-error condition, and "1" indicates an error.
If you do not specify an exit return out of PeopleCode a return of 0 will be assumed. This 0 return will have the program to flow down to the next action in the step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
280
Inserting PeopleCode into an Application Engine Program (continued)
On Return
The On Return options are:
• Abort The program issues an error and exits immediately.
• Break The program exits and control returns to the calling step.
• Skip Step The program exits the current step, and continues with the next step.
Slide 148
Student Notes
On Return
Use the On Return dropdown to select Abort, Break, or Skip Step.
Skip Step
Skip Step: If this is the last step in the section, the calling section/step resumes control of the processing.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
281
Inserting PeopleCode into an Application Engine Program (continued)
Exit Code
The following diagram illustrates how the Exit code controls program flow.
Slide 149
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
282
Activity 20: Adding PeopleCode to the WAITLIST Program In this activity, you will review the activity overview and add PeopleCode to the WAITLIST program.
See Application Engine: Activity Guide, "Using PeopleCode with Application Engine," Activity 20: Adding PeopleCode to the WAITLIST Program.
Slide 150
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
283
Activity OverviewThe Do When and Do Until statements in WAITLIST issue SQL to test for conditions that existed in the database. The values in the state record and literals were used as arguments in the Select Where clauses. Eachtest requires a round trip to the database.
In this activity, you will use PeopleCode to perform the same tests without making trips to the database.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
284
Activity Detailed StepsPerform the detailed steps to complete the activity.
Adding PeopleCode to the WAITLIST Program
To add PeopleCode to the WAITLIST program:
1. In Application Designer, open the WAITLIST Application Engine program.
2. Save the program as WAIT_PCODE.
3. Click No when prompted to save PeopleCode.
4. In the MAIN section, StepM2, change the Do When action type to PeopleCode.
Click OK, if you receive any warning message.
5. Leave the On Return field as Skip Step.
6. Save.
7. Double-click to open the PeopleCode Editor.
8. Add the following PeopleCode:
If WAITLIST_AET.CLASS_COUNT> 15 ThenExit (0);ElseExit (1);End-If;
9. In the COMPARE section, StepC2, change the Do When action type to PeopleCode.
10. Save.
11. Open the PeopleCode Editor.
12. Add the following PeopleCode.
If WAITLIST_AET.ENROLL_COUNT >= WAITLIST_AET.MAX_ENROLL ThenWAITLIST_AET.CLASS_COUNT = WAITLIST_AET.CLASS_COUNT+ 1;End-If;
13. Delete the Call Section Action
14. Delete ADDCOUNT section
We are adding one to the counter with the PeopleCode.
15. Save.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
285
16. The following table shows the program layout as it should now look:
SECTION STEPACTION TYPE STATEMENT Notes
MAIN STEPM1 Do Select %SELECT(COURSE,SESSION_NBR,MAX_ENROLL)
SELECT COURSE, SESSION_NBR, MAX_ENROLL
FROM PS_PSU_CRS_SESSN
None
* * Call Section COMPARE None
* * Do Until %SELECT(TEMP_FLD)
SELECT 'X' FROM PS_INSTALLATION
WHERE %BIND(CLASS_COUNT)> 15
None
* STEPM2 PeopleCode On Return - Skip Step
If WAITLIST_AET.CLASS_COUNT> 15 Then
Exit (0);
Else
Exit (1);
End-If;
If TRUE then ignore On Return, so the nextaction - Call Section Bonus - will be processed.
* Call Section Call Program:
BONUS: PSU_AELIB None
COMPARE STEPC1 SQL %SELECT(ENROLL_COUNT) SELECT COUNT(*) FROM PS_PSU_STU_ENROLL WHERE COURSE = %BIND(COURSE) AND SESSION_NBR= %BIND(SESSION_NBR)
None
* STEPC2 PeopleCode If WAITLIST_AET.ENROLL_COUNT >= WAITLIST_AET.MAX_ENROLL Then
WAITLIST_AET.CLASS_COUNT= WAITLIST_AET.CLASS_COUNT+ 1;
End-If;
If TRUE then ignore On Return, so the nextaction - Call Section Addcount - will be processed.
17. Execute the program from within the Application Designer and step through the program run in the debugger to verify that the program is running successfully.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
286
Enabling Dynamic Calls
Conditional Processing
It is often necessary for a program to conditionally execute certain logic. Application Engine programs use conditional processing to:
• Control the execution of steps, or actions within a step, by using Do actions or PeopleCode.
• Control the execution of entire sections by using the Dynamic Call option.
• The section is determined through conditional tests (usually in PeopleCode).
• The Dynamic Call option is used to execute the section.
Slide 151
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
287
Enabling Dynamic Calls (continued)
Enabling a Dynamic Call
To enable a dynamic call:
1. Add a PeopleCode action.
2. In the action, based on a condition test, store a program name and a section name in the state record. The two fields used with dynamic calls are:
• AE_APPLID for the Application Engine program name.
• AE_SECTION for the Application Engine section name.
• The fields must be populated, typically using PeopleCode.
• The fields must exist in the default state record.
3. Following the PeopleCode action, add a Call Section action with the Dynamic Call checkbox selected.
Slide 152
Student Notes
Dynamic Call Section
A dynamic call section can be used in place of hard-coding a section name in the call section action. A dynamic call section action will look to a special field on the state record for the name of the section and Application Engine program that needs to be called.
Rather than calling one specific section, you can take advantage of AE_APPLID and AE_SECTION fields in the state record to execute different sections depending on the conditions a program encounters during runtime. This is called a dynamic call.
Enabling Dynamic Call
You enable a dynamic call by first having your program populate a section name in the AE_SECTION field, and a program name in AE_APPLID field.
The values you insert into these fields are based on conditions met within your program. You then create a Call Section action. By selecting the Dynamic checkbox for the action, that action calls whatever section name appears in the state record AE_SECTION field.
Dynamic Call Fields
If you will only be using the section within one Application Engine program, then only the AE_SECTION field must be on the state record. If you want to be able to call a section from other Application Engine programs, you will need to define both AE_APPLID and AE_SECTION on your state record.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
288
If AE_APPLID is not specified, the current program is used.
If you place the AE_APPPLID field on your state record, it must be populated before the dynamic call or your program will abend.
Example
This table shows an example of a program using a dynamic call.
Section Step Action Statement
MAIN STEPM01 PeopleCode If AE_STATEREC_AET.NBR = 15 Then
AE_STATEREC_AET.AE_SECTION= "MESSAGE1";
Else
AE_STATEREC_AET.AE_SECTION= "MESSAGE2";
End-If;
* * Call Section Dynamic Call
MESSAGE1 STPEMM1 Log Message Number equal 15
MESSAGE2 STEPMM2 Log Message Number not equal 15
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
289
Activity 21: Examining PSU_INACT_3In this activity, you will review the activity overview and:
1. Examine PSU_INACT_3.
2. Run PSU_INACT_3.
See Application Engine: Activity Guide, "Using PeopleCode with Application Engine," Activity 21 Examining PSU_INACT_3.
Slide 153
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
290
Activity OverviewIn this activity, we will examine the structure and processing of the program PSU_INACT_3.
This program is a variation on the PSU_INACT_2 program. In this program, we give the user the choice of either entering an APP_REL or a TOOLS_REL. Based on the input by the user, the appropriate section will be selected dynamically by the program.
You will first examine the program elements, then execute the program with the debugger active to trace its behavior.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
291
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining PSU_INACT_3
To examine PSU_INACT_3:
1. In Application Designer, open the Application Engine program PSU_INACT_3.
2. Open the state record, PSU_INACT3_AET.
3. In the MAIN section, in the STEPM01 PeopleCode action, open the PeopleCode editor.
The following PeopleCode displays:
If All(PSU_INACT3_AET.TOOLS_REL) And None(PSU_INACT3_AET.APP_REL) Then PSU_INACT3_AET.AE_APPLID = "PSU_INACT_3"; PSU_INACT3_AET.AE_SECTION = "UPDATET";Else If All(PSU_INACT3_AET.APP_REL) And None(PSU_INACT3_AET.TOOLS_REL) Then PSU_INACT3_AET.AE_APPLID = "PSU_INACT_3"; PSU_INACT3_AET.AE_SECTION = "UPDATEA" Else PSU_INACT3_AET.AE_APPLID = "PSU_INACT_3"; PSU_INACT3_AET.AE_SECTION = "ERRMSG" End-If;End-If;
• If the TOOLS_REL has a value, the AE_SECTION is set to UPDATET.
• If the APP_REL has a value, the AE_SECTION is set to UPDATEA.
• If there are neither or both values entered, the AE_SECTION is set to ERRMSG.
4. Examine the next action, Call Section, following the PeopleCode action.
The Dynamic checkbox is selected, indicating that the program will call the section based on the AE_APPLID and AE_SECTION in the state record.
Running PSU_INACT_3
To run PSU_INACT_3:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
292
1. Navigate to the Request AE page.
a. Select PeopleTools, Application Engine, Request AE.
b. Choose Run Control ID PSU_INACT_3.
c. Notice the TOOLS_REL field is populated with '700'.
2. If it is not already set, activate the debugger for Application Engine in Configuration Manager under the Profile tab.
3. Execute the program in Application Designer.
a. Select Edit, Run Program.
b. For Run Control ID, enter PSU_INACT_3 to pick-up the '700' value.
4. In the debugger:
a. Enter an L and hit ENTER twice to see the unpopulated Dynamic fields.
b. Enter I to enter StepM01.
c. S to enter the PeopleCode step.
d. Enter an L and Enter twice to display the contents of the state record.
e. Answer the following questions:
Question Answer
What is the value for AE_APPLID?
What is the value for AE_SECTION?
f. Enter S to step through the Call Section action.
g. Enter G to permit the program to complete.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
293
Activity 22: Modifying the WAIT_PCODE Program to use Dynamic Call.
In this activity you will review the activity overview and modify WAIT_PCODE, adding a second Log Message action to flag employees who will not get bonuses for a class, and setting up a Dynamic call to selectthe correct message when running the program.
See Application Engine: Activity Guide, "Using PeopleCode with Application Engine," Activity 22 Modifying the WAIT_PCODE Program to use Dynamic Call.
Slide 154
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
294
Activity OverviewIn this activity you will review the activity overview and modify WAIT_PCODE, adding a second Log Message action to flag employees who will not get bonuses for a class, and setting up a Dynamic call to selectthe correct message when running the program.
In this activity, students will use the WAIT_PCODE program they just created and make some modifications to it. Instead of simply displaying the bonus message, the program will display a second message if the count is not high enough to justify a bonus.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
295
Activity Detailed StepsPerform the detailed steps to complete the activity.
Adding Dynamic Call
To add a dynamic call:
1. Add the fields AE_SECTION and AE_APPLID to the WAITLIST_AET State Record.
Important! Remember to rebuild the record.
2. Add a Message to the Message catalog to say: "You do not get a Bonus."
a. Select PeopleTools, Utilities, Administration, Message Catalog.
b. Choose Message Set 30000.
3. Open PSU_AELIB Application Library.
4. Add a new Section, NOBONUS, to the PSU_AELIB Application Library.
Make sure you select the Public checkbox in the Section properties.
5. Add a Log Message action to reference that Message.
6. In the WAIT_PCODE program select the Dynamic checkbox in the Call Section action in StepM2.
7. Replace the PeopleCode in StepM2 with the following:
If WAITLIST_AET.CLASS_COUNT > 15 Then WAITLIST_AET.AE_SECTION = 'BONUS';Else WAITLIST_AET.AE_APPLID = 'PSU_AELIB'; WAITLIST_AET.AE_SECTION = 'NOBONUS';End-If;
Testing
To test:
1. Turn on Statement Timings in Configuration Manager.
(They should be still on from earlier.).
2. Test the program in two-tier from Application Designer.
3. Examine the trace file generated.
4. To test the NOBONUS Section call run the program again.
5. In the Application Engine debugger type an S to execute StepM1
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PeopleCode with Application Engine Lesson 8
296
6. At STEPM02 use the M debug option to change the CLASS_COUNT field on the State Record to 14.
For Field Name enter CLASS_COUNT.
For Enter New Value enter 14.
7. At STEPM02 type an I and hit ENTER.
8. At STEPM02 PeopleCode enter an I and hit ENTER.
9. At STEPM02 Call Section enter an L and hit ENTER twice.
Notice the dynamic field values.
10. Enter S to step through the Call Section action.
11. Enter a G to permit the program to complete.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 8 Using PeopleCode with Application Engine
297
Review
In this lesson you learned that:
• Application Engine has the ability to use PeopleCode to make logical decisions to control the execution of sections, steps, or actions.
• PeopleCode is one of the nine action types.
• The dynamic calls feature allows you to use PeopleCode to populate the fields AE_SECTION and AE_APPLID in a state record so that the Application Engine program will dynamically call the specified section using a Call Section action.
Slide 155
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
PeopleCode PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Using Meta-SQL and PeopleCode"
PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide, "Using the PeopleCode Editor"
PeopleCode Variables PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide,"Variables"
PeopleTools 8.50 PeopleBook: PeopleCode Developer's Guide,"PeopleCode Language"
On-Return Options PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine,"Using Meta-SQL and PeopleCode"
Dynamic Calls PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine,"Creating Application Engine Programs"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
299
Lesson 9
Using Set Processing
Objectives
By the end of this lesson, you will be able to:
• Describe set processing.
• Modify a program to use set processing.
Slide 157
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
300
Describing Set Processing
Set Processing
Set processing:
• Only selects those rows that meet the filtering criteria
• Executes business rules once against all selected rows
• Pushes processing to the RDBMS rather than in the Application Engine Program
• Uses UPDATE or INSERT/SELECT or DELETE SQL to process sets or groups of rows at one time
Slide 158
Student Notes
Set Processing
All relational database systems use Structured Query Language (SQL) to process the information they contain. SQL was designed to let you specify sets of data in which you are interested.
Set processing takes advantage of the SQL characteristic to process groups, or sets, of rows at one time rather than processing each row individually. If implemented properly, in most cases set processing is more efficientthan row-by-row processing, especially when you enter the realm of high volume processing.
Since Application Engine is designed specifically to process high volume updates to database information, setprocessing is vital to the development of efficient Application Engine programs. In this lesson you will build programs using set processing SQL and examine the effects of its use.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
301
Describing Set Processing (continued)
Set Processing Advantages
Set Processing advantages include:
• Improved performance.
• Minimized (PeopleTools) SQL overhead.
• Simplified maintenance.
• Leverages RDBMS resources.
Slide 159
Student Notes
Set Processing Advantages
In most, perhaps 95%, situations encountered with PeopleSoft applications, set processing can be implemented to improve performance. This includes those instances in which row-by-row processing seemed like the only alternative. The following list includes some of the major reasons why you are encouraged to use set processing and some of the key benefits that you can expect from a set-based program.
• Improved Performance.
Our internal testing has revealed that, in an overwhelming majority of cases, set processing performs significantly better than its row-by-row counterpart for "reasonable" batch processing volumes. Set-based programs tend to scale in a geometric manner. Row-by-row processing scales in a more linear manner. When you encounter higher volumes, row-by-row processing can sometimes become overwhelmed.
• Minimized PeopleTools SQL Overhead.
Set processing is important with Application Engine because Application Engine has built in checkpoint/restart capabilities. Since Application Engine records the status of a program run, there is an avoidable degree of overhead associated with each Application Engine SQL statement that gets executed. Ifyou use set processing, you would tend to use fewer Application Engine SQL statements, each of which processed more data than the statements executed in row-by-row processing. As a result, the Application Engine overhead becomes less of a factor in the overall program.
• Easy Maintenance.
Maintenance activities include tuning, fixing, adding enhancements, and so on. There will be less SQL actions for set based programs than for row-by-row programs.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
302
• Leveraging the RDBMS.
With set-based processing, you take advantage of the SQL processing engine on the database rather than placing the processing burden and overhead on the application executable. And, as the RDBMS systems getmore sophisticated, set-based programs will reap even more performance gains. Using a row-by-row approach and pulling data into the program for each transaction degrades performance regardless of where the program runs. Even if the batch server and database engine are on the same physical machine, the data still travels through a variety of API layers.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
303
Describing Set Processing (continued)
Row-by-Row and Set Processing Compared
Substantial performance improvements can be realized from set processing:
PSU_CRS_INS uses row-by-row processing.
For each pass through the Do Select, one row is inserted.
PSU_CRS_SET uses set processing.
Slide 160
Student Notes
PSU_CRS_INS Trace File
The following is a portion of a trace file for PSU_CRS_INS.
Notice that only one row is inserted per pass through the Do Select. In PSU_CRS_INS, this was repeated six times.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
304
PSU_CRS_SET
As an alternative, consider the program, PSU_CRS_SET:
Section Step Action Statement
MAIN STEPM1 SQL INSERT INTO PS_PSU_COURSE_TBL
SELECT A.COURSE, %bind(effdt), A.EFF_STATUS, A.DESCR, %bind(COURSE_TYPE), A.LENGTH_DAYS, A.TRAINING_UNITS, A.ONSITE, A.INSTRUCTOR, '850', '850'
FROM PS_PSU_COURSE_TBL A
WHERE A.EFFDT = (SELECT MAX(A1.EFFDT) FROM PS_PSU_COURSE_TBL A1
WHERE A1.COURSE = A.COURSE
AND A1.EFFDT <= %CurrentDateOut)
AND A.EFF_STATUS = 'A'
AND A.COURSE_TYPE = %bind(course_type)
This is the trace resulting from a run of PSU_CRS_SET.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
305
Modifying a Program to use Set Processing
Temporary Tables
Set processing can make use of temporary tables to preselect data that can then be handled via a single SQL statement.
Temporary tables are designed to:
• Hold transaction data for the current run or iteration of your program.
• Contain only those rows of data affected by the business rule.
• Present key information in a denormalized form.
• Switch the keys for rows coming from the master tables if needed.
Slide 161
Student Notes
Set Processing and Temporary Tables.
Although temporary tables are not necessarily required for set processing, you will find that well-designed temporary tables will complement your set-based program in a variety of ways. For instance, you'll enjoy performance benefits, and if your program runs against a temporary table rather than the master tables, online users and processes can still access the master tables.
Creating temporary tables allows you to achieve one of the main objectives involved with set based processing-the processing remains on the RDBMS server. By storing transient data in temporary tables, you avoid the situation where the batch program fetches the data, row-by-row, and runs the business rule, processes the data, and then passes the updated data back to the database. If the program were running on a machine other than the database server, you'd also be taking performance hits due to the network roundtrip.
Application Engine supports a record type of temporary table, which allows you to have multiple instances ofthe same temporary table, thus allowing concurrent processing. However there may be times when you only need a single instance of a table. In that case, a standard SQL table can be used and the naming convention of TMP at the end will signify that it is being used as a temporary table.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
306
Modifying a Program to use Set Processing (continued)
WAITLIST Using Set Processing
How would you re-write the WAITLIST program to use set processing, and to accept input parameters?
Write a SQL action that retrieves a list of classes with enrollments greater than or equal to the maximum enrollment.
You would also need:
• A table to temporarily hold the list of classes.
• A state record to pass the parameters: begin date, end date, number of classes to qualify for a bonus.
Slide 162
Student Notes
Set Processing
WAITLIST was created without set processing in mind.
Also, what if you want to limit the date range on the classes? And do you really want that number 15 hard-coded? What if you decide to make it 10? These input parameters have nothing to do with set-processing. They only add to the flexibility of the program.
Since Application Engine can do set processing, we will now examine how to program this more effectively.
We already have the data sources
We need to create a SQL table to store our interim results.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
307
Modifying a Program to use Set Processing (continued)
Step 1. Analyze and Design
The following is the pseudo code for a WAIT_SET program:
01) Begin Program;02) Clear temporary table ;03) Collect ALL Course Sessions where enrollment count >= max enroll, write course, session_nbr, max_enroll, enroll_count into a temporary table ;04) If count of temporary table >= Bonus_nbr then05) issue Bonus message;06) End-if;07) End Program;
Slide 163
Student Notes
1. Analyze and Design the Application
You will be using set processing, so once you have determined the pseudocode, you will need to create the SQL statements.
What will the program look like?
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
308
Modifying a Program to use Set Processing (continued)
CRS_FULL_TMP Data Model
The following diagram illustrates temporary table relations for the WAIT_SET temporary table, CRS_FULL_TMP.
Slide 164
Student Notes
CRS_FULL_TMP Temporary Table
We need to create a temporary table that stores and calculates the count from PSU_STU_ENROLL for each course.
We will select the set into the temporary table.
Sections and Steps
Translate the pseudocode into the following sections and steps:
• Step 1 Initialize the temporary table.
• Step 2 Populate the temporary table with sessions that exceed their maximum enrollment.
• Step 3 Call section BONUS, in the application library PSU_AELIB, when there are more than the specifiednumber of classes where enrollment count >= maximum enrollment.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
309
Modifying a Program to use Set Processing (continued)
2A. Build Related Definitions
Create these definitions:
• Create any new fields that will be needed.
BONUS_NBR to store the number of classes to qualify parameter
• Create the temporary table to temporarily hold the rows.
Define and build the SQL table record -CRS_FULL_TMP.
• Create and build the state record.
Slide 165
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
310
Modifying a Program to use Set Processing (continued)
2B Create and Test your SQL
You need SQL for these steps:
• STEPM1 Initialize the table.
• STEPM2 Populate the temporary table.
• STEPM3 Test for Bonus qualification.
Slide 166
Student Notes
SQL
Here is the SQL for the steps above:
STEPM1 Initialize the Table
DELETE FROM PS_CRS_FULL_TMP Or %TRUNCATE TABLE (PS_CRS_FULL_TMP)
STEPM2 Populate the Temporary Table
INSERT INTO PS_CRS_FULL_TMP(COURSE, SESSION_NBR, MAX_ENROLL, ENROLL_COUNT) SELECT C.COURSE, C.SESSION_NBR, C.MAX_ENROLL, COUNT(*)FROM PS_PSU_CRS_SESSN C, PS_PSU_STU_ENROLL SWHERE C.COURSE = S.COURSE AND C.SESSION_NBR = S.SESSION_NBR AND C.START_DATE BETWEEN %BIND(FROMDATE) AND %BIND(THRUDATE)GROUP BY C.COURSE, C.SESSION_NBR , C.MAX_ENROLLHAVING COUNT(*) >= C.MAX_ENROLL
STEPM3 Test for Bonus Qualification
SELECT 'X' FROM PS_CRS_FULL_TMP HAVING COUNT(*) > %BIND(BONUS_NBR)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
311
Modifying a Program to use Set Processing (continued)
Step 2C. Build the Application Engine Program
In this step you will:
• Add steps and actions.
• Add SQL to SQL actions and Do loops.
• Test.
Slide 167
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
312
Activity 23: Creating the WAIT_SET programIn this activity, you will review the activity overview and:
1. Run WAITLIST to capture timings trace information.
2. Create WAIT_SET.
3. Run WAIT_SET.
See Application Engine: Activity Guide, "Using Set Processing," Activity 23: "Creating the WAIT_SET Program"
Slide 168
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
313
Activity OverviewIn this activity, you will run WAITLIST with trace enabled to capture trace information for that program.
Then, create the WAIT_SET program, using the steps and actions described earlier in this lesson.
When you have completed the WAIT_SET program, run it with trace enabled to capture trace information forthat program, and compare the processing history with the trace you captured when running WAITLIST.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
314
Activity Detailed StepsPerform the detailed steps to complete the activity.
Running WAITLIST to Capture Trace Information
To run WAITLIST to capture trace information:
If you have run WAITLIST already and recorded timing data skip to #4.
1. In Application Designer, open the Application Engine program WAITLIST.
2. In Configuration Manager, on the Trace tab, select the Statement Timings (file) checkbox.
3. Select Edit, Run or click the traffic light button to run the program.
4. Open the WAITLIST trace file located in C:\Temp.
5. Answer the following question:
Question Answer
What was the total time to run this program?
Creating the WAIT_SET program
To create the WAIT_SET program:
1. Create new field, BONUS_NBR, with the following attributes:
Field Type: Number
Integer Positions: 3
Decimal Positions: 0
2. Create a new record, CRS_FULL_TMP, as a SQL table with the following fields:
COURSE (Key)
SESSION_NBR (Key)
MAX_ENROLL
ENROLL_COUNT
3. When you save, you will be prompted to choose a tablespace.
Select PTAPP.PSPTDMO.
4. Build the table.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
315
5. Create the state record, WAITSET_AET, as a SQL table with the following fields:
PROCESS_INSTANCE (Key)
FROMDATE
THRUDATE
TEMP_FLD
BONUS_NBR
6. Build the table.
7. Test your SQL actions.
There is a script in C:\labs\0411_AppEngine\Scripts\Activity23.txt that contains the SQL required to create the modified program. You may use that or write your own.
Test the SQL in SQL Developer.
8. Build the WAIT_SET program using the following program layout:
Program Name: WAIT_SET
SECTION STEPACTION TYPE ACTIONS
SCRIPT SECTION
MAIN STEPM1 SQL %TRUNCATETABLE (PS_CRS_FULL_TMP) 1.1.1
* STEPM2 SQL INSERT INTO PS_CRS_FULL_TMP
(COURSE, SESSION_NBR, MAX_ENROLL, ENROLL_COUNT)
SELECT C.COURSE, C.SESSION_NBR,
C.MAX_ENROLL, COUNT(*)
FROM PS_PSU_CRS_SESSN C,
PS_PSU_STU_ENROLL S
WHERE C.COURSE = S.COURSE AND C.SESSION_NBR = S.SESSION_NBR AND
C.START_DATE BETWEEN
%BIND(FROMDATE) AND
%BIND(THRUDATE)
GROUP BY C.COURSE, C.SESSION_NBR,
C. MAX_ENROLL
HAVING COUNT(*) >= C.MAX_ENROLL
1.2.1
* STEPM3 DO When %SELECT(TEMP_FLD)
SELECT 'X' FROM PS_CRS_FULL_TMP
HAVING COUNT(*) > %BIND(BONUS_NBR)
1.3.1
* * Call Section
Section Name:BONUS
Program ID:PSU_AELIB
None
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
316
9. In the program properties, assign the WAITSET_AET state record to your program and on the Advanced tab, select Disable Restart.
Running WAIT_SET
As with a program you ran in an earlier activity, you will need to create a Run Control on the Request AE page. You will use that run control to run the WAIT_SET program from Application Designer. Running the program from Application Designer will allow you to examine the trace log after execution.
To run WAIT_SET:
1. Select PeopleTools, Application Engine, Request AE.
2. Select the Add a New Value tab.
3. Enter the following information:
Page Element Value or Status
User ID PTTRA
Run Control ID WAIT_SET
Program Name WAIT_SET
4. On the Application Engine Request page, enter the following information:
Page Element Value or Status
Process Frequency Always
State Record WAITSET_AET
Bind Variable Name BONUS_NBR
Value 4
5. Add another row by clicking the + button.
6. Enter the following information:
Page Element Value or Status
State Record WAITSET_AET
Bind Variable Name FROMDATE
Date January 1, 2009
7. Add another row by clicking the + button.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
317
8. Enter the following information:
Page Element Value or Status
State Record WAITSET_AET
Bind Variable Name THRUDATE
Date December 01,2009
9. Compare your run control page to the results in the Results section below.
10. Save.
11. In Application Designer, with WAIT_SET open, click the traffic light button.
12. For Run Control ID, enter WAIT_SET and run to completion
13. Examine the trace file.
14. Answer the following question:
Question Answer
What was the total time to run this program?
15. Compare this time to the time recorded for WAITLIST.
Results
Here is what your run control page should like:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Set Processing Lesson 9
318
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 9 Using Set Processing
319
Review
In this lesson, you learned that:
• Programs designed to take advantage of set processing can improve the application performance.
• Set Processing can yield:
• Improved performance.
• Minimized (PeopleTools) SQL overhead.
• Simplified maintenance.
• Improved utilization of RDBMS resources.
Slide 169
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
Temporary Tables PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Developing Efficient Programs"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
321
Lesson 10
Using Temporary Tables
Objectives
By the end of this lesson, you will be able to:
• Describe parallel processing.
• Implement parallel processing.
• Use meta-SQL with parallel processing.
• Describe run time allocation.
Slide 171
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
322
Describing Parallel Processing
Parallel Processing
Parallel processing is the simultaneous execution of multiple instances of a single program.
Uses of parallel processing include:
• Concurrent execution of a program by multiple users.
• Reduction of processing time by partitioning high volumes of data into batches to be processed by separate instances of a program.
Slide 172
Student Notes
Temporary Tables
Since Application Engine programs run in batch, it is very likely that multiple instances of the same program can be running in parallel. When batch programs begin running simultaneously, they introduce a significant risk of data contention and deadlocks on common tables and/or temporary tables.
For Application Engine programs, PeopleTools provides a feature that enables you to drastically reduce the risk of table contention by dedicating specific instances of temporary tables for each program run. With this feature, you have a pool of temporary table instances, and within that pool some tables are dedicated to particular programs, and some instances are undedicated, meaning they are "shared."
In this lesson, we will examine how temporary tables are created, how to incorporate them into your Application Engine program and how the execution is handled.
Whether your Application Engine program will be run for several users running the same program simultaneously, or if you have designed a high volume batch job to be split into several runs for performance,it is critical to know how to implement, manage and maintain your temporary table pools. Application Engineallows you to employ a temporary table management scheme to maintain a pool of temporary tables for parallel processing. Many delivered PeopleSoft Application Engine processes employ these techniques
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
323
Describing Parallel Processing (continued)
Concurrent Table Access Model
This diagram illustrates concurrent temporary table access by multiple programs and a single temporary table:
Slide 173
Student Notes
Concurrent Table Access Model
What if we wanted to add criteria to the WAIT_SET application so it would process only counted rows of data for a specific waitlist coordinator. That way different offices could see whether their waitlist coordinator earned a bonus. Each concurrent run of the program using the same temporary table would hinder the performance of all processes. In addition, it might introduce a significant risk of data contention and deadlocks on the one temporary table used for all processes.
This could create unpredictable results, such as:
• Data corruption, as different instances of the code would be issuing Deletes, Inserts, and/or Updates that areunsynchronized with the others.
• Performance loss due to RDBMS table management.
• Performance loss due to program complexity.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
324
Describing Parallel Processing (continued)
PeopleSoft Parallel Processing Model
This diagram illustrates concurrent execution of a program by multiple users and multiple temporary tables:
Slide 174
Student Notes
PeopleSoft Parallel Processing Model
All processes will run more efficiently and without the risk of data contention if each has its own dedicated temporary table to hold the sets of rows to be processed for each separate run.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
325
Describing Parallel Processing (continued)
Single Program and Single Table Model
This diagram illustrates the batch, high volume, single instance processing model:
Slide 175
Student Notes
Internal Program Performance
Internal program performance can be improved only by:
• Tuning SQL.
• Reviewing program processing methods.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
326
Describing Parallel Processing (continued)
Multi-Program and Table Model
This diagram illustrates executing an Application Engine program three times using different input variables each time to divide up the rows processed by each run:
Slide 176
Student Notes
Multi-Program and Table Model
Using criteria in our Application Engine program, we could execute the Application Engine program three times using different input variables each time to divide up the rows processed by each run.
Using temporary tables, each run would get a dedicated temporary table for added performance improvement.
Multiple Program Instances Running against Multiple Temporary Table Instances
Parallel processing can enable you to reduce the time required to update the data that currently gets processed while residing in one instance of PS_MYAPPLTMP.
To parallel process, you partition the data between multiple concurrent runs of MYAPPL, each with its own dedicated version of PS_MYAPPLTMP. If you have a payroll batch process, you could divide the employee data by last name. For example, employees with last names beginning with A through M get inserted into PS_MYAPPLTMP1; employees with last names beginning with N-Z get inserted into PS_MYAPPLTMP2.
To use two instances of the temporary table, you would define MYAPPL to access one of two temporary tables. One execution would use A-M and the other N-Z.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
327
Note. This particular solution utilizes two unique programs against two unique tables
Typically, an organization implements parallel processing when considerable amounts of data need to be updated or processed within a limited amount of time, or "batch window." In most cases, parallel processing is more efficient in environments containing multiple CPUs and partitioned data.
When batch programs begin running simultaneously, they introduce a significant risk of data contention and deadlocks on common tables or temporary tables. Keep in mind that many delivered PeopleSoft batch applications employ the technique of set processing, and set processing (in most cases) involves extensive useof temporary tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
328
Describing Parallel Processing (continued)
Online and Batch Methods
When Application Engine programs are run in parallel, they are run in one of two methods:
• Online (synchronously) - implemented through a code callappengine() function.
• Batch (asynchronously) - implemented through a process definition initiated via the Process Scheduler.
Due to the differences in execution of these two methods the temporary tables used must be segregated.
Slide 177
Student Notes
Reducing the Risk of Table Contention
For Application Engine programs, PeopleTools provides a feature that enables you to dedicate specific instances of temporary tables for each program run.
With this feature, you have a pool of temporary table instances, and within that pool are:
• A base table that can be shared.
• Numbered tables for online, dedicated executions of your Application Engine program.
Some numbered tables are for explicit Application Managed allocation and control. This scheme is used only by Enterprise Performance Management (EPM). This course will not discuss this option extensively as it is built into the EPM application.
Some tables are for batch background execution programs (the documentation refers to this type of temporarytable as dedicated. In fact once an online application has a temporary table allocated to it, the table is dedicated to that program. These processes will be referred to as batch in future development to clarify this concept. You will see the word dedicated progressively eliminated.).
The PeopleSoft 8 release introduced a temporary table record type definition for use by EPM. You were able to define a record and set its type to Temporary Table. Doing this, causes the PeopleSoft table build process to build multiple, uniquely named copies of your temporary table. Your application program had to get a unique table, use it, and release it back to the pool of temporary tables. The PeopleSoft EPM product used thisapproach.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
329
Describing Parallel Processing (continued)
PeopleSoft Temporary Tables Solutions
This table summarizes PeopleSoft temporary table solutions:
Online Batch
Invoked by CallAppEngine from PeopleCode. Invoked through the process scheduler.
Run quickly, synchronously, and at random times. Run for longer amounts of time, asynchronously, and at scheduled times.
Potential for simultaneous execution. Potential for simultaneous execution and can be designed for parallel execution for performance.
Uses the online temporary table pool. Uses the batch/dedicated temporary table pool.
Not restartable Restartable
Slide 178
Student Notes
Temporary Table Record Type
PeopleSoft 8 introduces a Temporary Table record type definition. You are able to define a record and set its Type to Temporary Table. By doing this the PeopleSoft Build process will build multiple uniquely named copies of your temporary table as a pool to assign data sets when processes are initiated in parallel.
Additionally, temporary table management is built in for your Application Engine programs. You can code your program with supplied meta-SQL, so each execution of your Application Engine program will be given access to its own copy of the temporary table for its exclusive use. When the program ends the table will be returned to the pool of temporary tables. O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
330
Implementing Parallel Processing
Steps to Implement Parallel Processing
The steps to implement parallel processing are:
1. Define your temporary tables.
2. Set or check the temporary table online pool. This is a global setting and is usually established at installation time.
3. Assign temporary tables to be dedicated to each Application Engine program.
4. Set the number of dedicated temporary tables to form the number of temporary tables to be created for theprocess to be run in parallel.
5. Build or rebuild your temporary table record to create the appropriate number of temporary table instances assigned to the Application Engine parallel process.
6. Adjust your program meta-SQL (i.e. %TABLE) to resolve the data set to the appropriate application engine process being run in parallel..
Slide 179
Student Notes
Steps to Implement Parallel Processing
There is no simple switch or checkbox that enables you to turn parallel processing on and off. To implement parallel processing, you need to complete a set of tasks in the order that they appear in the following list.
1. Define your temporary tables with a Type of Temporary Table.
2. Set or check the temporary table online pool. This will set the basic temporary table online pool based on the PeopleTools Options specifications. This setting is a global number, in that it affects every temporary table in your database being initiated through the function callappengine(). If this global online number is changed then every temporary table must be rebuilt.
3. Assign temporary tables to your Application Engine program in its Program Properties, setting the appropriate number of Instance Counts and Runtime option. The runtime option dictates whether to allow another process to be initiated if all application engine dedicated temporary tables are in use (continue option) or whether to inhibit the process from being initiated again until an available temporary table has been released (abort option).
4. Set the Temporary Table Batch Pool by setting the instance count in the program properties specific to each application engine program to be run in parallel..
5. Build or rebuild your temporary table record. This will build the necessary batch temporary tables into that record's temporary table pool for use at execution time for that unique application engine program.
6. Code %Table meta-SQL as references to temporary tables in your Application Engine program, so that Application Engine can resolve table references to the assigned temporary table instance dynamically at runtime.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
331
Implementing Parallel Processing (continued)
Defining your Temporary Tables
Define your temporary tables
1. Create a new record.
2. PeopleSoft recommends that you make Process Instance a key field. The process instance is used to restart the process should it abnormally end.
3. Set the Record Type to Temporary Table.
4. Save the record.
Slide 180
Student Notes
Temporary Table
Important! Do not build the record at this time.
Define Temporary Tables
Warning! If you choose not to include PROCESS_INSTANCE as a key field in a Temporary Table, you should change the Temp Table runtime options to Abort in the appropriate Application Engine programs. Thisis to ensure your program does not use the shared base table.
You use the Application Designer initially to define your Temporary Tables. You build the tables after you have assigned the global setting in PeopleTools Options for the online instances (a setting usually done at installation once) and the number of dedicated tables has been assigned to the application engine program to indicate the number of times the program is to run in parallel.
PeopleSoft recommends that you insert the PROCESS_INSTANCE field as a key into the temporary tables you intend to use with Application Engine. You must also designate other fields as keys to write the multiple data rows uniquely to the temporary table., Otherwise you will get duplicate key errors at runtime and the program will abnormally end.
Important! In order to take advantage of multiple instances of a Temporary Table, you must specify that the record definition's Record Type be set to Temporary Table.
When all instances of a temporary table are in use and the Temp Table runtime options are set to Continue, PeopleTools will use the base table for its execution. If there is a possibility that the base table will be used you must also be sure to code in the SQL where clause in your Application Engine a reference to only the rows of data for the PROCESS_INSTANCE number that has been assigned to your program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
332
Implementing Parallel Processing (continued)
Temporary Table Online Pool
Set or check the temporary table online pool.
• On the PeopleTools Options page, specify:
• Temp Table Instances (Total)
• Temp Table Instances (Online) - used by callappengine() function
• Total temporary table instances that will be SQL created is:
• The value in Temporary Table Instance (Total).
• The sum ofinstance count values specified in all of the Application Engine Programs that use that temporary table.
• A maximum of 99 temporary table instances can be created.
Slide 181
Student Notes
Page Used to Set Temporary Tables
Page Name Navigation
PeopleTools Options PeopleTools, Utilities, Administration, PeopleTools Options
Use this page to set up temporary tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
333
Setting the appropriate number is important for establishing a pool of instances to be used by Application Engine processes invoked online from PeopleCode with the CallAppEngine function. In general, the number you choose should be relatively small, as in less than 10. The disadvantage of a larger value is that the extra instances consume space in the database, and can therefore hamper overall performance.
Important! Temp Table Instances (Total) and Temp Table Instances (Online) should always be the same value except in a PeopleSoft Enterprise Performance Management (EPM) database.
Important! If you change the values for Temp Table Instances in PeopleTools Options, you need to log off your connection and log back on again for the new value to be utilized properly. You will also need to rebuildall of your temporary tables. If you lower the number, you will need to manually drop the additional, now unused, tables.
Temp Table Instances (Online)
There are two reasons to set Temp Table Instances (Online) to a particular value:
• Application Engine uses this value to identify a range of temporary tables devoted to programs called by the PeopleCode function CallAppEngine. A randomizing algorithm balances the load for the online processthat gets assigned to a temporary table devoted to online program execution.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
334
• This value provides backward compatibility for developers using the 8.0 toolset (EPM) who took advantageof the %Table(record_name, instance_number) approach to manually managing temporary table locking.
Temp Table Instances (Total)
The difference between the Total and Online will be your EPM managed tables. If you are not on an EPM database the total and online should be the same.
Total Instances
Application Designer builds the temporary table instances at the same time it builds the base table for the record definition. When Application Designer builds a table (as in, Build, Current Object) and the Record Type is Temporary Table, it determines the total number of instances of the temporary table to build.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
335
Implementing Parallel Processing (continued)
EPM Temporary Tables
This diagram illustrates which temporary tables are reserved.
Slide 182
Student Notes
Temporary Table
Note. Enterprise Performance Management (EPM) was introduced using PeopleTools 8. This Tools release had a TEMP BATCH setting in PeopleTools Options. This value is not used in other PeopleSoft Applications.Other PeopleSoft Applications use the number of tables from the Program Properties of the Application Engine programs using a given temporary table.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
336
Implementing Parallel Processing (continued)
Assigning Temporary Tables
Assign Temporary Tables to the Application Engine program.
• Use the Temp Tables tab on the Program Properties dialog box to assign temporary tables.
• Also on this tab assign Instance Count and specify Continue or Abort if non-shared tables cannot be assigned.
Slide 183
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
337
Student Notes
Definition Used to Assign Temporary Tables
Definition Name Navigation
PSU_CUST_CHG File, Open, Definition: App Engine Program, Name: PSU_CUST_CHG, File, Definition Properties, Temp Tables
Important! Anytime you change the instance counts, you need to rebuild the temporary tables to ensure that the right number of instances get created and are available for your programs.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
338
Implementing Parallel Processing (continued)
Setting the Temporary Table Batch Pool
Set the Temporary Table Batch pool
• If the program will be run in batch, you will need to establish the number of temporary table instance that will be used for your program.
• Use the Instance Count field on the Temp Tables tab of the Program Properties dialog box.
• If the program will only be run in batch mode, select the Batch Only checkbox on the Program Properties: Advanced tab.
Slide 184
Student Notes
Temporary Table
Important! You need to set the Instance Count value on the Temp Tables tab prior to building the record definition in Application Designer.
Instance Count
The number entered here will dedicate the number of instances requested for this program. In this case, four instances of the table will be created in addition to the base table for use by this program.
The Runtime group box has two options for "If non-shared Tables cannot be assigned." This is the action the Application Engine will take if batch/dedicated tables cannot be allocated at runtime.
• Continue The base table will be used instead.
• Abort Inhibits the program from initiating when temp tables exhausted
Batch Only
The Advanced tab has a Batch Only checkbox. If the program will only be run in batch mode and not executed from the CallAppEngine PeopleCode function, you should use this checkbox.
Any dedicated temporary table used for Batch Only programs do not have online instances created.
Batch Only is new in PeopleTools 8.4x.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
339
Implementing Parallel Processing (continued)
Building Temporary Table Records
Build or rebuild your temporary table record.
This diagram shows how temporary tables are allocated based on Instance Count in the program properties:
Slide 185
Student Notes
Temporary Table Instances
The actual number of temporary table instances built for a particular temporary table record during the SQL Build process equals the Temp Table Instances (Total) in PeopleTools options value plus the sum of all the Instance Count values specified in all the Application Engine programs that use that Temporary Table (assigned in the program's Program Properties dialog.)
For example: Assume that you have assigned APPLTMPA a record type of Temporary in Application Designer.
Say that:
• Temp Table Instances (Total) is set to 10
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
340
• APPLTMPA appears in the Temp Tables tab in the Program Properties for two Application Engine programs.
• In one program the Instance Count is set to 3
• In the other the Instance Count is set to 2.
When you run SQL Build, PeopleTools builds a total of 16 temporary table instances for APPLTMPA (10 + 3+ 2 + 1). The extra one is for the base table.
Anytime you change the instance counts, you need to rebuild the Temporary Tables to ensure that the right number of instances get created and are available for your programs. If you don't, the allocation program will think there are more online and less batch tables than are available.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
341
Implementing Parallel Processing (continued)
Application Engine Temporary Table Use, Running in Parallel
This diagram shows an example with three Application Engine programs using a variety of temporary tables with different instance counts.
Slide 186
Student Notes
How Many Tables?
The question is: How many tables do your processing programs need concurrently?
If you intend to run AE1, AE2, and AE3 independently in parallel, you will need all seven instances of the temporary table.
The actual number of batch temporary tables built is the sum of the instance counts in all the programs that have assigned that table as a temp table. The instance count value is not how many SQL table instances that program can use, it is how many instances that program is going to send to the batch temp table pool. Once the batch pool is created it is a community pool and all programs can use all and any instances in the pool for the temporary tables assigned to it.
How many instances do I need? You need to assess how many instances of the Application Engine program many be running at the same time.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
342
Implementing Parallel Processing (continued)
Application Engine Temporary Table Use, Running Serially
This diagram shows an example with three Application Engine programs using a variety of temporary tables with different instance counts:
Slide 187
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
343
Activity 24: Adding a Temporary Table to PSU_CUST_CHGIn this activity, you will review the activity overview and add a temporary table to PSU_CUST_CHG.
See Application Engine: Activity Guide, "Using Temporary Tables," Activity 24: Adding a Temporary Table to PSU_CUST_CHG.
Slide 188
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
344
Activity OverviewIn this activity, you execute the first five steps to implement parallel processing.
You will create a temporary record (TEST_TAO), and assign that record to the PSU_CUST_CHG program. You will set the temporary batch pool and build the record.
Do not make any changes to the Temporary Table Online Pool in PeopleTools Options.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
345
Activity Detailed StepsTo add a temporary table to PSU_CUST_CHG:
1. Define the temporary table.
2. Check the temporary table online pool. (Optional)
3. Assign temporary tables to Application Engine program.
4. Set the temporary table batch pool.
5. Build or rebuild your temporary table record.
Defining the Temporary Tables
To define the temporary table:
1. In Application Designer, create a new record, TEST_TAO.
2. Add the following fields. For this Activity we do not want to make the fields keys:
• PROCESS_INSTANCE
• TEMP_FLD
3. On the Record Type tab, set the Record Type to Temporary Table.
4. Save.
Note. Do not build the record at this time. Not all of the instances required will be built if you do so.
Setting the Temporary Table Online Pool
This has already been done.
If you want to verify, select PeopleTools, Utilities, Administration, PeopleTools Options.
Note the Temp Table Instances (Total) and the Temp Table Instances (Online) values.
Assigning the Temporary Table to the Program
To assign the temporary table to the program:
1. Open the Application Engine program PSU_CUST_CHG
2. Open the Program Properties.
3. Select the Temp Tables tab.
4. Add TEST_TAO to the selected Temporary Tables for this program.
5. Save.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
346
6. If you are prompted with message that asks, "Insert updated Temp Table list into Project?" click Yes.
Setting the Temporary Table Batch Pool
To set the temporary table batch pool:
1. For the Application Engine program PSU_CUST_CHG, open the Program Properties, click the Temp table tab and set Instance Countto 4.
2. Click OK.
3. Save.
Building the Temporary Table
To build the temporary table:
1. In Application Designer, access TEST_TAO.
2. From the Menu, select Build, Current Definition.
3. In the Build Dialog, select the Create Tables checkbox and select the Build Script File radio button.
(We do not actually want to create the physical tables at this time in the classroom. Normally, you would want to build the physical tables at this step in the process)
4. Click the Settings button.
5. Click the Logging tab.
6. Select the Fatal errors, warnings, and informational messages radio button.
7. Click ok.
8. Click Build to create the script file.
9. Compare your Output Window to the results below.
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
347
Using Meta-SQL with Parallel Processing
Adjusting Meta-SQL
Adjust your program Meta-SQL to resolve the application engine program to the temporary table assigned to it's process at run time.
• Table references must be set up using %Table.
• To add rows to temporary tables, you must provide the process instance number using either:
• %ProcessInstance
• %Bind(PROCESS_INSTANCE)
• While assigned Temporary Tables are cleared at the start of processing, no automatic deletes happen duringor at the end of the program. You may want to consider using an action containing SQL with %TruncateTable for additional deletes during or at the end of the run.
Slide 189
Student Notes
Meta-SQL
A critical step in implementing parallel processing is to make sure that you've included all of the appropriate meta-SQL within the code that your Application Engine program executes.
Referencing Temporary Tables (%Table)
When you are developing programs that take advantage of %Table, keep the following items in mind:
• As a general rule, all Temporary Tables should be keyed by Process Instance and other fields to allow for multiple rows to be inserted on it.
Also, if the Continue option will be used when batch/dedicated tables can't be assigned, Process Instance must be present and a key on your temporary table.
• Your choice of indexes on temporary tables is an important consideration.
Depending on the use of the temporary table in your program as well as your data profile, the system indexes based on your key structure may be sufficient. On the other hand, a custom index may be needed instead, or perhaps no indexes are necessary at all. It is worth considering these issues when designing your application. You want to define indexes and SQL that will perform well in most situations, but individual programs or environments may require additional performance tuning during implementation.
• You should always use %Table(recname) when coding.
Note. The default table name refers to PS_recname, where PS_recname1,2,? refer to the batch/dedicated temporary tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
348
For batch/dedicated temporary tables, when Application Engine resolves any %Table, it checks an internal array to see if a temporary table instance has already been chosen for the current record. If so, then Application Engine substitutes the chosen table name. If there are no more batch/dedicated instances available, then Application Engine uses the base table instance (PS_recname) by default (Continue option in the programs properties is selected). Regardless of whether %Table is in PeopleCode SQL or in an Application Engine SQL action the program uses the same physical SQL table.
For synchronous calls to Application Engine, an available instance number will be selected at random according to internal rules. Synchronous refers to using the CallAppEngine PeopleCode function; all other methods that you use to invoke Application Engine programs are asynchronous, which means the page is not "frozen" while the program runs to completion.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
349
Using Meta-SQL with Parallel Processing (continued)
Single Temporary Table Assignment with %Table
With no batch or dedicated tables assigned, this statement:
Select PROCESS_INSTANCE,TEMP_COL1,TEMP_COL2 from %Table(MYAPPLTMP)
is resolved as shown in this diagram.
Slide 190
Student Notes
%Table
If you defined your Application Engine program to have no batch/dedicated tables the %Table in the Select will be resolved to the base temporary table:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
350
Using Meta-SQL with Parallel Processing (continued)
Multiple Temporary Table Assignment with %Table
Where multiple batch or dedicated tables are assigned, this statement:
Select PROCESS_INSTANCE,TEMP_COL1,TEMP_COL2 from %Table(MYAPPLTMP)
is resolved to an available instance of the temporary table, as shown in this diagram.
Slide 191
Student Notes
%Table Meta-SQL
The Application Engine runtime program invokes logic to pick one of the available instances.
Once each program instance gets matched with an available temporary table instance, the %Table meta-SQL construct resolves to use the corresponding temporary table instance.
Run control parameters passed to each instance of the MYAPPL program enable it to identify which input rows belong to it, and each program instance inserts the rows from the source table into its assigned temporary table instance using %Table.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
351
Activity 25: Examining Parallel Processing with AETESTPROG
In this activity you will review the activity overview and examine how AETESTPROG implements parallel processing.
See Application Engine: Activity Guide, "Using Temporary Tables," Activity 25: Examining Parallel Processing with AETESTPROG.
Slide 192
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
352
Activity OverviewIn this activity, you will look at the AETESTPROG program settings related to parallel processing, then execute the program through the Process Scheduler.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
353
Activity Detailed StepsIn this task, you will:
1. Examine AETESTPROG.
2. Execute the program using Process Scheduler.
3. Launch the program from Application Designer.
Examining AETESTPROG
To examine AETESTPROG:
1. In Application Designer, open the Application Engine program AETESTPROG.
2. Look at the temporary tables used by the program.
a. Select File, Program Properties.
b. Select the Temp Tables tab.
c. Answer the following question:
Question Answer
What is the temporary table?
Question Answer
How many test tables are available for AETESTPROG's execution?
3. Click OK to close.
4. Expand the META section.
This section of AETESTPROG is used to test variables in an Application Engine program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
354
5. Double-click on the SQL action for the step VARIABLE.
The following SQL displays:
INSERT INTO %Table(AETEST_TAO) (PROCESS_INSTANCE , AE_INT_1 , AE_APPLID , AE_SECTION , AE_STEP , PROCESSINSTANCE , RETURNCODE , RUN_CNTL_ID , AS_OF_DATE , AE_SQLROWS , CURRENCY_CD , ANNUAL_RT ) SELECT %ProcessInstance , %Bind (AE_INT_1) , %AEProgram , %AESection , %AeStep , %ProcessInstance , %ReturnCode , %RunControl , %DateIn(%AsOfDate) , %SqlRows , 'USD' , 0.0 FROM PS_INSTALLATION
This statement uses %Table(AETEST_TAO) to select the temporary table to use for the program.
Notice that the SQL inserts a row into the temporary table that contains all of the program information using the variables.
Also notice that the SQL uses variables for %AEProgram, %AESection, and so on.
6. Close the SQL window.
Executing the Program using Process Scheduler
To execute the program using Process Scheduler:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
355
1. Append to the Parameter List parameter on the process definition.
a. Select PeopleTools, Process Scheduler, Processes.
b. Choose the AETESTPROG process definition.
c. Click the Override Options tab.
d. In the Parameter List field, select Append.
e. In the Parameter field, enter -TRACE 7
f. Click Save.
2. Navigate to the Application Engine Run Control page.
a. Select PeopleTools, Process Scheduler, System Process Requests.
b. For Run Control ID, select Training.
3. On the Application Engine Request page, click the Run button.
4. On the Process Scheduler Request page, select the AETESTPROG checkbox.
5. Click OK.
6. Navigate to Process Monitor to check the results.
Select PeopleTools, Process Scheduler, Process Monitor.
7. When the program is successful, click on the Details link.
Select the View Log/Trace link.
8. Click on the Application Engine Trace File (.AET) link to display the trace.
9. Answer the following question:
Question Answer
What test tables are being allocated for AETESTPROG?
Test table information is listed in the trace file because you enabled tracing of temporary tables.
Launching the Program from Application Designer
You can see the allocation of multiple temporary tables for a process by launching the program from Application Designer with the debugger active. While the program is paused waiting for input, you can examine the temporary tables assigned to the specific process, matching it to the process Run Control ID.
Important! Before continuing, verify that the Application Engine Debugger is activated.
To launch the program from Application Designer:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
356
1. Execute AETESTPROG five times using the Run Program button
Use these five run control IDs: RUN01, RUN02, RUN03, RUN04, RUN05.
When the debugger kicks in do not press G.
2. Navigate to the Review Temp Table Usage page.
Select PeopleTools, Application Engine, Review Temp Table Usage.
3. Click the View Locks link for AETEST_TAO.
The View Locks page identifies the process instances that have the temporary tables locked.
4. Click Return.
5. Access the Temp Table Settings by Program tab.
The Temp Table Settings by Program tab shows which programs have temporary tables assigned to them and the number of instances.
6. In the command window of two of your running programs type a G to run them to completion.
7. On the Temp Table Usage page click on the View Locks hyperlink again.
8. Two of the tables should be gone from the listing.
In the command window of the rest of your running programs type a G to run them to completion.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
357
Describing Run-Time Allocation
On Line Processes
Online processes have dedicated temporary tables, defined globally.
PeopleTools randomly allocates a single temporary table instance number to the online program for all dedicated temporary table needs.
No other program can use an assigned instance number until the online program runs to completion.
Any other online process that gets an in-use instance value will wait until the instance number is unlocked.
Slide 193
Student Notes
Page Used to View Online Assignments of Temporary Table Instances
Page Name Navigation
Online Instance Usage PeopleTools, Application Engine, Review Online Instance Usage
Use the Online Instance Usage page to view online assignments of temporary table instances:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
358
The manner in which a program allocates a temporary table differs depending on how you invoke a program. The distinction between invocation methods falls into two categories: online and batch.
For instance, an online program might be invoked from a page using PeopleCode, and you typically invoke batch programs by scheduling them to run through the Process Scheduler.
Online Processes
Online processes have dedicated Temporary Tables, defined globally on PeopleTools Options.
PeopleTools randomly allocates a single Temporary Table instance number to the online program for all dedicated temp table needs. Any other online process that happens to get the same instance value as programX will wait for the lock to be released when programX completes and the instance number is unlocked. The AELOCKMGR table is used as the "gatekeeper" for the online instances used.
Online Instances Usage Page
Technically, online Application Engine processes employ a simple load-balancing algorithm to divide up many concurrent processes across all the available online instance values. Processes that happen to get the same random value will run in series on a first come, first served basis. The higher the number of online instances defined on PeopleTools Options, the less likely it will be for two online processes to get the same value.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
359
Describing Run-Time Allocation (continued)
Batch Processes
Batch/dedicated table instance numbers are allocated on a record-by-record basis.
Numbers start with the lowest instance number until all numbers are in use.
If all instances are used and you indicated Continue for the If non-shared Tables cannot be assigned, additional programs use the base table with Process Instance as a key.
When a program ends normally or is cancelled in Process Monitor, assigned instances are automatically released.
Slide 194
Student Notes
Temporary Table
Important! For EPM it is still necessary to truncate the Temp tables. For all other applications it's handled bythe system.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
360
Describing Run-Time Allocation (continued)
Restartable Programs
If restart is disabled the temporary tables are unassigned automatically in the event of a controlled abend.
In the event of a "kill" or a "crash," tables remain locked, and must be freed using Process Monitor or the Manage Abends page.
Tables in use by processes canceled using Process Monitor are freed automatically.
For restartable programs, the temporary tables remain locked across restarts until:
• The program has completed successfully
Or
• The table is manually released using Process Monitor or the Manage Abends page.
Slide 195
Student Notes
Page Used to Release Temporary Tables
Page Name Navigation
Manage Abends PeopleTools, Application Engine, Manage Abends
Use the Manage Abends page to release temporary tables locked when programs fail, if they are run outside of Process Scheduler; otherwise use Process Monitor to cancel your request, which releases the locks.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
361
This table summarizes table allocation for online and batch processes.
Summary Online Batch
Allocation Meta-SQL %Table(temp-tbl) %Table(temp-tbl)
Runtime Table Allocationby psae.exe
Randomly assigns Instance Number from the number range on your Online Temp Tables. This Instance Number is used for all Temp Tables for that program run.
Individually allocated based on availability on a record-by-record basis. Begins with lowest instance number available for each Temporary Table until all instances in use.
No Temp Tables Free For a particular record, if the instance is currently in use then the psae.exe queues the program until the assigned Instance number becomes free.
If no free Temporary Tables and Continue set - use Base table .If assignment cannot be made and the program is set to Abort, execution terminates. Never queues for a table.
Initially Clear Temp Table
When program Instance comes available. When assigned.
Locked When Application Engine program loads into memory.
When Application Engine program loads into memory.
Un-Lock Unlock on completion of program. On crash, free from Manage Abends.
If Restartable stays locked across Restarts until completes successfully. If not Restartable on program completion. 'Kill' program requires manually freeing tables. Cancel from Process Monitor frees tables.
Note. Use Process Monitor rather than the Manage Abends page for clearing program locks as much as possible.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
362
Activity 26: Modifying WAIT_SET to Use Temporary TablesIn this exercise you will review the activity overview and modify WAIT_SET to use temporary tables.
See Application Engine: Activity Guide, "Using Temporary Tables," Activity 26: Modifying WAIT_SET to Use Temporary Tables
Slide 196
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
363
Activity OverviewFor this activity you will modify the WAIT_SET program to utilize a PeopleSoft batch (dedicated) temporarytable.
Follow these steps:
1. Create the temporary table.
Create CRS_FULL_TAO as a clone of CRS_FULL_TMP.
2. Modify WAIT_SET.
a. Assign CRS_FULL_TAO as a temporary table.
b. Set instance count to 3.
c. Select Continue for If non-shared Tables cannot be assigned.
d. Delete StepM01.
e. Adjust your SQL:
Replace PS_ CRS_FULL_TMP with %Table(CRS_FULL_TAO).
Account for the field PROCESS_INSTANCE in your INSERT.
3. Build the temporary record.
Use Execute and Build Script.
4. Test.
Examine the trace to see how your SQL is resolved.
Answer the following question:
Question Answer
Which Temporary Table was allocated?
Note. Disconnect from the database in SQL Developer before running an Application Engine Program. Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
364
Activity Detailed StepsFollow these steps:
1. Create the temporary record CRS_FULL_TMP.
2. Modify the WAIT_SET application engine program .
3. Build the temporary record.
4. Test.
Creating the Temporary Record
To create the temporary record:
1. Open the CRS_FULL_TMP record definition.
2. Save it as CRS_FULL_TAO.
3. Add the field PROCESS_INSTANCE.
Make it a key.
4. Set Record Type to Temporary Table.
5. Save the record.
6. Do not build the record yet.
Modify WAIT_SET
To modify WAIT_SET:
1. Open the Program Properties:
a. Select the Temp Tables tab.
b. Add the record CRS_FULL_TAO.
c. In the Instance Count field, enter 3.
d. For If non-shared Tables cannot be assigned, select the Continue option.
2. Delete STEPM01. The truncate is automatic with the Temporary tables.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
365
3. Adjust the SQL in the SQL action in STEPM2. (You can copy from the provided script file. )
Use the following SQL:
INSERT INTO %Table(CRS_FULL_TAO)(PROCESS_INSTANCE , COURSE , SESSION_NBR , MAX_ENROLL , ENROLL_COUNT) SELECT %ProcessInstance , C.COURSE ,C.SESSION_NBR ,C.MAX_ENROLL ,COUNT(*) FROM PS_PSU_CRS_SESSN C , PS_PSU_STU_ENROLL S WHERE C.COURSE = S.COURSE AND C.SESSION_NBR = S.SESSION_NBR AND C.START_DATE BETWEEN %Bind(FROMDATE) AND %Bind(THRUDATE) GROUP BY C.COURSE, C.SESSION_NBR , C.MAX_ENROLL HAVING COUNT(*) >= C.MAX_ENROLL
Adjust the SQL in the Do When action in STEPM3. (You can copy from the provided script file.)
Use the following SQL:
%Select(TEMP_FLD) SELECT 'X' FROM %Table(CRS_FULL_TAO) WHERE PROCESS_INSTANCE = %ProcessInstance HAVING COUNT(*) > %Bind(BONUS_NBR)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
366
4. Compare your Application Engine program to this template:
SECTION STEPACTION TYPE ACTIONS
SCRIPT SECTION#
MAIN STEPM1 * Remove this Step 1.1
* STEPM2 SQL INSERT INTO %Table(CRS_FULL_TAO)(PROCESS_INSTANCE
, COURSE
, SESSION_NBR
, MAX_ENROLL
, ENROLL_COUNT)
SELECT %ProcessInstance
, C.COURSE
,C.SESSION_NBR
,C.MAX_ENROLL
,COUNT(*)
FROM PS_PSU_CRS_SESSN C
, PS_PSU_STU_ENROLL S
WHERE C.COURSE = S.COURSE
AND C.SESSION_NBR = S.SESSION_NBR
AND C.START_DATE BETWEEN
%Bind(FROMDATE) AND %Bind(THRUDATE)
GROUP BY C.COURSE, C.SESSION_NBR , C.MAX_ENROLL
HAVING COUNT(*) >= C.MAX_ENROLL
1.2
* STEPM3 DO When %Select(TEMP_FLD)
SELECT 'X'
FROM %Table(CRS_FULL_TAO)
WHERE PROCESS_INSTANCE = %ProcessInstance
HAVING COUNT(*) > %Bind(BONUS_NBR)
1.3
* * Call Section Call Program:
BONUS
PSU_AELIB
5. Save the Application Engine program.
Building the Temporary Table Record
To build the temporary table record:
1. Open the record definition CRS_FULL_TAO
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 10 Using Temporary Tables
367
2. Select Build, Current Definition.
a. Select the Create Tables checkbox.
b. Select the Execute and Build Script option.
c. Click the Settings button.
d. Select the Recreate table if already exists option.
e. Click OK.
f. Click the Build button. You will get a message "Potentially data destructive settings are active. Continue the build process?
g. Click Yes to build the table.
3. Look in the Build pane of the output window to locate and open the SQL Build script.
Answer the following question:
Question Answer
How many tables were built?
Testing Your Program
Run the program from Application Designer.
1. Execute the program using the Run Program button.
a. Enter the Run Control ID WAIT_SET so your program picks up the runtime parameters entered in the AEREQUEST page.
b. Click OK.
c. Type G in the debugger to run to completion.
2. Examine the trace to see how your SQL is resolved
3. Answer the following question:
Question Answer
Which Temporary Table was allocated?
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using Temporary Tables Lesson 10
368
Review
In this lesson you learned that:
• Parallel processing is implemented in Application Engine programs by using temporary tables.
• When a temporary table record is built, the number of temporary tables created is determined by
• PeopleTools options for Temp table instances (Total) and
• Any application programs utilizing the temporary table.
• In the Application Engine program temp tables must be referenced using the meta-SQL %Table(table_name).
• The number of temporary table instances available to online programs is determined by the Temp Table Instances (Online) in PeopleTools Options.
Slide 197
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
Parallel Processing PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Creating Application Engine Programs"
Temporary Tables PeopleTools 8.50 PeopleBook: Data Administration Tools,"PeopleTools Utilities"
PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine,"Using Temporary Tables"
Meta-SQL PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine,"Using META-SQL and PeopleCode"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
369
Lesson 11
Executing Application Engine Programs
Objectives
By the end of this lesson, you will be able to:
• List ways to execute Application Engine programs.
• Execute an Application Engine program using a push button.
• Execute an Application Program with the Process Scheduler.
• Execute an Application Engine program with a command script.
Slide 199
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
370
Listing Ways to Execute Application Engine Programs
Batch and Online Execution
This table gives a summary of differences between batch and online execution:
Online Execution Batch/Manual Execution
Started by CallAppEngine, executed as from PeopleCode.
Executes PSAE through Process Scheduler or the command line
Intended for programs that run quickly, synchronously, and at random times.
Intended for programs that run for longer periods of time, asynchronously, and at scheduled times.
Potential for simultaneous execution. Can be designed for parallel execution for performance.
Uses the online temporary table pool. Uses the Batch/Dedicated temporary table pool.
Slide 200
Student Notes
Batch Execution
This is the most typical mode of execution. You invoke programs that run in this mode using Process Scheduler or the Application Engine Process Request page. Batch mode is also referred to as asynchronous execution, meaning that it runs independently in the background.
Online Execution
Application Engine programs that execute online typically get executed from a page with the CallAppEngine PeopleCode function. Such online processes are synchronous, meaning that subsequent processes wait on the results. For instance, a page may be "frozen" until the online process returns the necessary results. When the program is called synchronously, no Commits are issued until the program completes.
CallAppEngine PeopleCode does not issue Commits. All commits are issued from within the Component Processor, which would include PeopleCode commands like SavePost Change. Be aware, in 8.50 PeopleCodenow issues a commit after FieldChange. So, if you use CallAppEngine from FieldChange, there will be a Commit issued, even before you hit the save button.
Manual Execution
To execute an Application Engine program in manual mode, you would use the command line. Usually, you only use this technique during development or if you need to manually restart the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
371
Listing Ways to Execute Application Engine Programs (continued)
PSU_PROC_ORD Data Relationships
This chart shows the underlying data relations behind the PSU_PROC_ORD program used in the examples.
Slide 201
Student Notes
PSU_PROC_ORD
The PSU_PROC_ORD program will process customer orders against the available stock on hand to allow theorder to be shipped or backordered.
The program will look at all of the open orders and check the stock level to see if there is enough inventory tofill the order. The PS_PSU_ORDER_DTL table is updated for the FILL_STATUS and a temporary table PS_PSU_OR_STAT_TMP is updated with the order status information.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
372
Listing Ways to Execute Application Engine Programs (continued)
Synchronous Execution
Use synchronous execution when:
• Processing should be of short duration.
• Processing requires some task to complete before further processing can occur.
• Application Engine performs a SQL task more efficiently than some other methods.
• A developer will be able to take advantage of existing Application Engine resources.
Slide 202
Student Notes
Example: On-line Execution of Application Engine Programs
The Process Orders page is an example of implementing Application Engine on-line execution.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
373
Definition Used to Define Pushbuttons
Definition Name Navigation
PSU_PROCESS_ORDERS File, Open, Definition: Page, Name: PSU_PROCESS_ORDERS
The page definition carries the pushbutton page control.
Double click on the Process Orders Command push button to bring up the push button/hyperlink properties:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
374
Click ok to exit the Push Button/Hyperlink page field properties.
Now, Right-click on the push button and select View Record People Code to open the PeopleCode associated with the push button. The PeopleCode calls the Application Engine program.
Here is the PeopleCode:
/* PSU CDF 06/29/01 - AE 8 Course: Execute the AppEngine program PSU_PROC_ORD, Notify the user that the process has completed. AXL 10/08/03 - Refresh the rowset to display the newly gather temporary table data in the secondary page. */
Local Rowset &RS;&RS = GetLevel0();CallAppEngine(PSU_PROC_ORD);&RS.Refresh();MessageBox(0, , 30000, 1, message not found.);UnHide(DERIVED_PSU_AE.REVIEW_STATUS);
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
375
When to Use CallAppEngine PeopleCode
Use CallAppEngine PeopleCode to call an Application Engine program to execute a process as opposed to others methods (Others methods of accomplishing the task might include: COBOL, SQL objects, Component Interfaces).
• Tasks require complex SQL for processes that are difficult to implement in PeopleCode.
• A task requires dedicated resources, such as temporary tables.
Application Engine objects that can be taken advantage of include: callable sections, program logic and SQL processing.
Process Orders page
In the Order Management folder, there is a link to the Process Order page. This page is used to demonstrate the various ways to invoke an application engine program.
Among other features, the application was written to allow you to initiate the process, wait for it to complete and when it completes allow you to view the results of the process.
Push buttons allow programmable actions to take place when selected by your user. The program that executes is PeopleCode placed on a Record Field or on the Component structure.
Process Orders Push Button
This push button is defined to execute PeopleCode associated with the DERIVED_PSU_AE record, in the PROCESS_ORDERS field of that record. By default, it will be the FieldChange PeopleCode that will be triggered when the button is pushed.
PeopleCode
The PeopleCode here invokes the process, with the CallAppEngine function, and on return from that function,puts up the message box indicating the process completion.
CallAppEngine starts the Application Engine program named applid. This is a way of starting your Application Engine programs synchronously from a page. The syntax is:
CallAppEngine(applid [, statereclist ]);Where statereclist is list of record objects in the form:&staterecord1 [, &staterecord2] . . .
There can only be as many record objects in statereclist as there are state records for the Application Engine program. Additional record objects will be ignored.
Below is sample code to pass a record object from the Component buffer to the CallAppEngine function in order to populate the Application Engine program's state record(s).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
376
/* Instantiate the record */&st_pshup_aet = createrecord(record.st_pshup_aet);/* Populate the values */&ST_PSHUP_AET.EMPLID.Value = ST_GRANT_EXER.EMPLID;/* Call the AE program */CallAppEngine("ST_DEL_ETAX", &ST_PSHUP_AET);
Note. Your Record Object must have the same data structure as your state record or your Application Engine program and PeopleCode will fail.
MessageBox is a PeopleCode function used to display a message box. The syntax is:
MessageBox(style, title, message_set, message_num, default_txt [, paramlist])
where paramlist is an arbitrary-length list of parameters of undetermined (Any) data type to be substituted in the resulting text string, in the form:
param1 [, param2]...
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
377
Listing Ways to Execute Application Engine Programs (continued)
Setting up a Synchronous Call to Application Engine
To set up a synchronous call to Application Engine:
1. Create a record and field for the push button.
2. Add FieldChange PeopleCode containing CallAppEngine to call the program.
3. Add a push button to the page you wish to use to launch the process.
4. In the push button properties, select PeopleCode Command for the Destination.
5. Enter the record and field containing the PeopleCode into the push button properties.
Slide 203
Student Notes
Derived Records
The record does not need to be a table, as most push button functionality in PeopleSoft is driven from Derivedrecords.
Note. Be aware that CallAppEngine can be used in other types of PeopleCode, not just executed from a pushbutton. See PeopleBooks for more details.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
378
Activity 27: Launching a Process with a Push ButtonIn this activity you will review the activity overview and test the online program execution using a push button.
See Application Engine: Activity Guide, "Executing Application Engine Programs," Activity 27: Launching a Process with a Push Button.
Slide 204
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
379
Activity OverviewIn this activity, you will navigate to the Process Orders page and execute the on line process. After execution, you will use a link on the page to review the order fill status.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
380
Activity Detailed StepsPerform the detailed steps to complete the activity.
Launching a Process with a Push Button
Paragraph automatically inserted
1. Navigate to the Process Orders page.
Select Order Management, Process Customer Orders and select any run control ID.
2. Click the Process Orders- Command push button.
This will launch the process.
3. When the process is complete, a message box displays with the message "Process Completed."
Click OK to return to the page.
4. When the process has completed, a Review Status button appears on the page.
a. Click the Review Status button. The fill status should then be displayed.
b. Compare your Customer Order Fill Status page to the results below.
5. Click OK to close the page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
381
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
382
Executing an Application Program with the Process Scheduler
Application Engine Process Flow for Batch and Online
This diagram illustrates how Process Scheduler manages process execution in the batch environment.
Slide 205
Student Notes
Process Scheduler
PeopleSoft's Process Scheduler will maintain status of your executing program and execute your application asynchronously from the initiation process.
PeopleTools Process Scheduler Manager is a centralized tool that enables application developers, system administrators, and application users to manage PeopleSoft batch processes. Using the PeopleSoft Internet Architecture (PIA), you can access a list of processes through a web browser and schedule a process request.
You can schedule processes to run without having to exit the PeopleSoft system. Once a scheduled process begins, Process Monitor enables you to monitor the important details of PeopleSoft batch processes, such as where certain programs ran, where and when reports were printed, and what command-line parameters were passed to third-party programs with which Process Scheduler Manager interacts.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
383
Executing an Application Program with the Process Scheduler (continued)
Asynchronous Mode
Application Engine programs can be executed through Process Scheduler in asynchronous mode.
Executing through Process Scheduler allows the user to view process status from Process Monitor.
In this section we will discuss:
• Execution with the Run button.
• Direct Process call through PeopleCode.
Slide 206
Page Used to Execute Application Engine Programs
Page Name Navigation
Process Customer Orders Order Management, Process Customer Orders
A Process Scheduler request can be launched from the Process Orders page.
Clicking the Run button brings up the Process Scheduler Request page.
At the bottom of the Process Orders page there is also a push button for asynchronous execution.
You can use the Process Monitor link to view the status of the process.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
384
Direct Process Call with PeopleCode
The push button at the bottom of the page is not synchronous, so the user can navigate to another part of the application while the process is running.
The Push Button Properties are much the same as for Synchronous Execution of an Application Engine Program, and uses the same steps for setting up the page.
The difference lies in the PeopleCode used to initiate the request.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
385
For LVC Presentation:
Polling Question: Executing an Application Program with the Process Scheduler
Question Answer
Which best describes a synchronous and asynchronous executed Application Engine program?
1. Synchronous execution suspends activity while asynchronous runs in the background.
2. Synchronous and asynchronous can be monitor in Process Monitor.
3. Asynchronous execution suspends activity while synchronous runs in the background.
4. Synchronous and asynchronous execution suspends activity while running in the background
1 (Synchronous execution suspends activity while asynchronous runs in the background).
Process Orders Page
You have seen this in another form earlier. This is the typical display you would see on a page set up to initiate a Process Scheduler request.
There is only one checkbox on this page, as this is the only process associated with the component definition used to launch the process. This page will display whatever Process Definitions are associated through security with a specific component.
Once the program has been submitted, you are returned to the run control page. You can use the Process Monitor Hyperlink to check on the status of your program.
If you either have only one server, or you don't care which one runs the process, the server name can be left blank.
PeopleSoft supplies standard run controls and subpages that you can use when you create your own run control pages. In this example, we are using the PRCSRUNCNTL_SBP.
The standard page contains hyperlinks to the Process Monitor and the Report Manager.
We will go into more detail on using the process scheduler in the next lesson.
Asynchronous Execution
Some users might have responsibility to initiate tasks, but the duration of the task, such as posting, or preparing for a payroll run, might be so long that the user would want to check status later.
PeopleCode
This push button also starts a process scheduler job, without prompting the user for any additional information, as the Process Scheduler Request Page does. The status of this request can be reviewed, as it is not synchronous.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
386
This is pretty obscure to those not familiar with object-based programming. In this particular case, the object &RQST is a miscellaneous object defined in PeopleCode, of type ProcessRequest.
ProcessRequest objects contain fields that need to be populated prior to the request being submitted. That is where the values are supplied that otherwise would be entered by the user in the process request dialog:
&RQST.RunControlID&RQST.ProcessType&RQST.ProcessName
The request is submitted by using a Method defined as part of the ProcessRequest Object. Invoking this method in PeopleCode, with the fields populated, submits the process request to the batch environment.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
387
Executing an Application Engine Program with a Command Script
Command Line Execution
Use Command Line execution of an Application Engine Program (PSAE.EXE) for:
• Restarting a program.
• Development/Testing.
• Debugging.
Slide 207
Student Notes
Restarting.
When a program abends, a system administrator might want to restart the program using the command line. Ifneeded, you can locate all of the specific program/process information from the Process Monitor on the Process Request Detail dialog. Normally, end users (or system administrators) will perform a Restart from theProcess Monitor.
Development/Testing.
Many developers include the command line in a batch file to launch a program they are developing or testing.This way, they can quickly execute the batch file as needed. This also allows separation of development of the Application Engine program from its associated pages.
Debugging.
You can set up the command line to debug, which offers an alternate method of invoking the Application Engine debugger without turning it on for all programs executed through the client. To debug a program with a Run Location of Server, you can log into the server (using Telnet, for example) and invoke the program from the command line. O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
388
Executing an Application Engine Program with a Command Script (continued)
Parameters
This table lists the minimum parameters that are required in addition to the path where PSAE.exe resides:
Description Parameter
Database platform (e.g. Microsoft, Oracle, DB2, etc.) -CT <dbtype>
Database name -CD <database name>
Logon ID -CO <oprid>
Password -CP <oprpswd>
Run Control -R <run control id>
Application Engine program -AI <application id>
Slide 208
Student Notes
Notes
Important! Logon id, password, and run control are case sensitive.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
389
Activity 28: Executing PSU_PROC_ORD with a Command Script
In this activity, you will review the activity overview and execute the Process Orders Application Engine program (PSU_PROC_ORD) from the DOS command line.
See Application Engine: Activity Guide, "Executing Application Engine Programs," Activity 28: Executing PSU_PROC_ORD with a Command Script.
Slide 209
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
390
Activity OverviewRun PSU_PROC_ORD using the command line.
You can also process the orders that were executed with the push button from a command line and see the parameters associated with the execution of the application.
In class we already have a command line set up to run the PSU_PROC_ORD program. Edit the file C:\labs\0411_AppEngine\Bat\ PSU_PROC_ORD.bat using Notepad.
You will need to verify the parameters so they are correct or modify them on the command line using these general guidelines:
Parameter Value: Case Sensitive?
Database platform (e.g. Microsoft, Oracle, DB2,?) MICROSFT N
Database name <your database> N
Logon id PTTRA Y
Password PTTRA Y
Run Control (This is needed to run.) PSU_PROC_ORD Y
App Engine program name PSU_PROC_ORD N
AE Debugger on, Trace options, Restart or DB flags set. As required NA
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 11 Executing Application Engine Programs
391
Activity Detailed StepsPerform the detailed steps to complete the activity.
Executing PSU_PROC_ORD with a Command Script
Perform these steps:
1. Right-click the file C:\labs\0411_AppEngine\Bat\ PSU_PROC_ORD.bat.
2. Select Edit to open the file for editing in Notepad.
3. Replace <PSHOME> with the path for your environment.
4. Replace <database> with your database name.
5. Verify the other parameters are set as shown in the table above.
6. Save the file.
7. Double-click on the file to execute the batch.
Warning! There are must be no carriage returns in the command line.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Executing Application Engine Programs Lesson 11
392
Review
In this lesson you learned that:
• You can execute Application Engine programs in a number of different ways appropriate to the type of userthat is initiating the program.
• You can initiate Application Engine programs from pages with push buttons set for synchronous or asynchronous execution.
• You can run Application Engine programs using Process Scheduler.
• You can execute an Application Engine program from a command script.
Slide 210
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
Synchronous Execution PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine, "Managing Application Engine Programs"
Pushbuttons PeopleTools 8.50 PeopleBook: PeopleSoft Application Designer,"Creating Page Definitions"
Meta-SQL PeopleTools 8.50 PeopleBook: PeopleSoft Application Engine,"Using META-SQL and PeopleCode"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
393
Lesson 12
Creating Process Definitions for Application Engine
Objectives
By the end of this lesson, you will be able to:
• Identify the process types used with Application Engine.
• Create Application Engine process definitions.
• Implementing an Application Engine program with no user input.
• Implementing an Application Engine program with user input.
Slide 212
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
394
Identify the Process Types used with Application Engine
Process Type
Process Type definitions define parameters common for an entire family of processes.
Process Type definitions are used to globally define:
• The parameter list.
• The command line.
• The working directory.
Each new Application Engine program needs to be added to the list of processes for the same type.
Parameters are in the form of meta-strings.
Slide 213
Student Notes
Page Used to Define Process Types
Page Name Navigation
Process Type Definitions PeopleTools, Process Scheduler, Process Types
Use the Process Type Definitions page to define process types.
Select a row on the Process Type definitions list to bring up the Type Definition component:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
395
This table shows examples of entries in the Application Engine parameter list.
Parameter Variables (meta-strings) Description
-CT %%DBTYPE%% Database Type
-CD %%DBNAME%% Database Name
-CO %%OPRID%% User ID
-CP %%OPRPSWD%% User Password
-R %%RUNCNTLID%% Run Control ID
-I %%INSTANCE%% Process Instance
-AI %%PRCSNAME%% Process Definition
Here is the parameter list for AppEngineGenericTestType, which you used earlier in the Application Engine Request page.
-CT %%DBTYPE%% -CD %%DBNAME%% -CO %%OPRID%% -CP %%OPRPSWD%% -R %%RUNCNTLID%% -I %%INSTANCE%% -AI %%RUNCNTLID%% -OT %%OUTDESTTYPE%% -FP %%OUTDEST%% -OF %%OUTDESTFORMAT%%
Notice that for AppEngGenericTestType, -AI parameter is %%RUNCNTLID%%.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
396
Creating Application Engine Process Definitions
Purposes of Process Definitions
A process definition serves four primary purposes:
• Identify the type of process to be run.
• Identify the program name to be run.
• Identify from where the program is to be run.
• Identify who has security access to run the program.
Slide 214
Student Notes
Pages Used to Define Processes
Page Name Navigation
Process Definition PeopleTools, Process Scheduler, Processes
Process Definition Options Access the Process Definition Options tab.
• Use the Process Definition page to define a process in the Process Scheduler.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
397
• Use the Options tab to control how, when and where a program will run and who can run it.
Process Definitions
For every Application Engine program that you want to run, you will need to define a process definition. The process definition must have the same name as the Application Engine program. When you looked at the parameter list, you noticed that -AI uses the meta-string PRCSNAME that is resolved at runtime to the process definition name.
Process definitions store specific parameters used to run a particular process. They store things that are only pertaining to one particular process, like PSU_INACT_1, which will have no effect on WAITLIST or IMP_DAL_SESS.
The Process Definition page
Examine the definition for PSU_INACT_1.
When we have been testing our Application Engine programs, we did not create process definitions for the new programs, but instead used a run control ID with the same name as the program. We used FASTTEST as the generic process definition to run our Application Engine programs.
This worked because FASTTEST uses the AppEngGenericTestType process type, which uses the run control ID to identify which program is to be executed.
Important! Take students to PeopleBooks for a complete description of the fields on the Process Definition page.
This table gives a summary of the fields on the Process Definition page.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
398
Process Type Defines the directory on PSPRCS.CFG for the type of program
Process Name This name must match the program name of the process you are defining. For example, if you are defining an Application Engine program named MYTEST, you must define the process name as MYTEST.
Description Displays in Process Scheduler Request page and is aimed at the user.
Priority This defines the relative priority used by the Process Server Agent to determine which process to initiate first, if multiple processes are queued to run on a given server. Low, Medium, High priorities.
API Aware An API aware task is a process that properly updates its process status which displays in the Process Monitor through the type specific API provided. Application Engine includes API aware code so always leave the box checked.
Process Definition Options page.
Important! Look at PeopleBooks for a complete description of the fields on the Process Definition Options page.
This table gives a summary of the fields on the Process Definition Options page.
Server Name The server name should only be specified if you want to restrict a particular process to the specified server definition. Leaving this blank allows the process to be run on the first server available or the default server. Also this field needs to beleft blank if the customer is implementing the Master Scheduler system, as this process will decide which server to send the process to based on load balancing.
Recurrence Name Previously defined time intervals set up for processes to run. If you add a recurrence name here, this process will use this recurrence every time you run thisprocess. If the user is able to change the recurrence on the process request page then that will override the value in this field.
Component The component in the online system where the Process Definition will be accessible in the Process Request page.
Process Group The "family" of processes to which this process belongs is a logical collection needed for a particular job function. If you choose an existing group, users that have access to that group will immediately have access to this process. You can create a new Process Group, by inserting a new row here. You will have to give access to users via the Permission List in Security. This field is case sensitive.
The Override Options Page
The Override Options page enables you to modify the Parameter List, Command Line, or Working Directory values passed to the process.
If you have any custom values that you need to send, you have the following options in your Parameter List:
• Override. Sends your custom parameters in place of the PeopleSoft defaults.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
399
• Append. Adds your custom parameters to the end of the PeopleSoft string.
• Prepend. Adds your custom parameters to the beginning of the PeopleSoft string.
• We will see an example of overrides in the Process Monitoring Lesson.
Note. When using the ProcessRequest PeopleCode Class if you do not specify values in the code the systemwill use the values specified on the process definition.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
400
Implementing an Application Engine Program with No User Inputs
Adding an Application Engine Process
To add an Application Engine process:
1. Design the Program.
2. Identify fields for user input.
3. Determine a Run Control record.
You may have to create one if input parameters are required.
4. Build the record.
5. Determine Run Control page.
Slide 215
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
401
Implementing an Application Engine Program with No User Inputs (continued)
Adding an Application Engine Process
The steps to add an Application Engine process are (continued):
1. Place page on a component.
2. Register the component, place on menu and apply security for the permission list.
3. Add a Process Definition.
4. Make Application Engine Program Modifications (if required) to read the input parameters.
5. Test
Slide 216
Student Notes
Adding an Application Engine Process for PSU_INACT_1
This table details the steps as applied to PSU_INACT_1.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
402
Step Description Details
1 Design Reviewed earlier
2 Identify fields for user input PSU_INACT_1 has none
3 Determine Run Control record (You may have to create one)
We can use a standard PS run control record. PRCSRUNCNTL
4 Build the record Already exists
5 Determine Run Control page (You may have to create one)
We can use the standard PeopleSoft run control page - PRCSRUNCNTL
6 Place page on a component PSU_RUN_INACT1
Search Record = PRCSRUNCNTL
7 Register the component, place on menu and apply security
Menu = PSU_TRAINING Portal = Employee Folder = PSU_COURSE_PROCESS Node =<use default local node checkbox> Permission List = PSU5000 Actions =Update/Display
8 Add a Process Definition (The Application Engine Program Name)
PSU_INACT_1
9 Modify the Program None required
10 Test !!!!!
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
403
Activity 29: Implementing the WAITLIST ProgramIn this activity, review the activity overview and implement the WAITLIST program.
See Application Engine: Activity Guide, "Creating Process Definitions for Application Engine," Activity 29: Implementing the WAITLIST Program.
Slide 217
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
404
Activity OverviewIn this activity, you will make the necessary changes to permit the WAITLIST program to be run from the Process Course Information page in your application. After making the settings, you will then test the execution of the program from the page. To test, run WAITLIST from the new location.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Steps to Implement
Step Description Details
1 Design We want to run this from the Process Course Information folder
2 Identify fields for user input. WAITLIST does not have any.
3 Determine Run Control record PRCSRUNCNTL
4 Build the record Already exists
5 Determine Run Control page PRCSRUNCNTL
6 Place page on a component RUN_WAITLIST
7 Use registration wizard to add component to a menu, register component in portal and set security.
Menu: PSU_TRAINING Bar: USE Portal: Employee Folder: PSU_COURSE_PROCESS Content Reference Label: Waitlist Sequence Number: 300 Node: <use default local node checkbox> Permission List: PSU5000 Actions: Add, Update/Display
8 Add a Process Definition WAITLIST
9 Modify the Program Not required
10 Test
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
405
Activity Detailed StepsPerform the detailed steps to complete the activity.
Setting up a Process Definition for WAITLIST
Perform the following steps:
1. Create a new run control component.
a. In Application Designer, select File, New, Component.
b. Add the page PRCSRUNCNTL to the component.
c. Access the component properties. On the Use tab, set the search record to PRCSRUNCNTL.
d. Save the component as RUN_WAITLIST.
2. Select Tools, Register Component
a. Accept the defaults for Add this component to a menu, Add this component to a portal registry, and Add this component to a permission list.
Click Next.
b. Add the component to the PSU_TRAINING menu, USE bar.
Click Next.
c. Enter the following information:
Page Element Value or Status
Folder Name PSU_COURSE_PROCESS
Content Reference Label Waitlist
Sequence Number 300
Always use default local node? Selected
d. Click Next.
e. Next to Permission List, Click Select.
f. For Name, enter PSU5000.
g. For Add all pages of this component with the following actions, select Add and Update Display.
Clear Update/Display All and Correction.
h. Click Next.
i. Click Finish.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
406
3. Add a Process Definition.
a. Select PeopleTools, Process Scheduler, Processes.
b. Click the Add a New Value tab.
c. Enter the following information:
Page Element Value or Status
Process Type Application Engine
Process Name WAITLIST
d. Click Add.
e. Enter the following information.
Page Element Value or Status
Description Waitlist Coordinator Bonus
Long Description This process will calculate whether the waitlist coordinator gets a bonus. It will issue a message if this is true.
Priority Medium
Process Category Default
API Aware Selected
f. Click the Process Definition Options tab.
g. Enter the following information:
Page Element Value or Status
Component RUN_WAITLIST
Process Group TLSALL
h. Click Save.
4. To test, navigate to Courses, Process Course Information, Waitlist.
a. Select a run control ID.
b. Click Run.
c. Compare your Process Scheduler Request page with the Process Scheduler Request Page below.
d. Click OK.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
407
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
408
Implementing an Application Engine Program With User Inputs
Input Parameters
Many Application Engine programs require the user to input parameters.
Developing to include user input parameters requires:
• A run control page with fields to enter the input parameters.
• A run control record with fields to store the input parameters.
• A state record with fields to store input parameters.
• Modifications to the Application Engine program to retrieve the input parameters.
Slide 218
Student Notes
Example: Input Parameters
The run control page provides edit boxes for the user to enter either the PeopleTools Release or the Application Release.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
409
Definitions Used to Add Input Parameters
Definition Name Navigation
PSU_RUN_INACT File, Open, Definition: Page, Name: PSU_RUN_INACT
PSU_RUN_INACT File, Open, Definition: Record, Name: PSU_RUN_INACT
PSU_INACT4_AET File, Open, Definition: Record, Name: PSU_INACT4_AET
PSU_INACT_4 SQL File, Open, Definition: App Engine Programs, Name: PSU_INACT_4
In Section: MAIN, Step: RUNCTL, double click on Action: SQL
Use the run control page definition to add page controls for input parameters.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
410
• Use the PSU_RUN_INACT record is used to store the values for PSU_INACT_4.
• Here is the state record for PSU_INACT_4 Application Engine program:
Note. Instead of using the system variables for the OPRID and Run Control ID you could have the fields onthe state record. Application Engine would then populate the fields when it populates the process instance.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
411
• The Application Engine Program contains SQL to retrieve run control parameters:
Run Control with Parameters
Many of the Application Engine programs that are delivered require input parameters. We will look at an existing run control page that uses parameters.
The program PSU_INACT_4 gives the user the choice of inactivating courses based on either a PeopleTools Release or an Application Release. The run control page provides dropdown list boxes for the user to enter either the Tools or Application Release.
PSU_RUN_INACT page
On this page, we are using the PRCSRUNCNTL_SBP and adding the additional fields for PeopleTools Release and Application Release. Take a look at the order tab, notice that the tools_rel and app_rel fields come from different records to the sub-page.
Run Control Record
The run control record contains OPRID and RUN_CNTL_ID as keys, plus any additional fields required to store run control parameters. In our case it contains the fields APP_REL and TOOLS_REL.
If this new record is created with a little foresight, it can be used again and again for many pages. Many of thedelivered applications develop in this way. Often the run control record is named RUN_CNTL_HR, for example, and will be the basis of the HR module run control pages.
Component Search Record
In the delivered system we often use the PRCSRUNCNTL record as the search record regardless of the run control record being used. This is so that the run controls per user tied to security are exposed by each user profile.
State Record
When you start an Application Engine program, the command line contains the information to run the program including the Run Control ID (RUN_CNTL_ID) and the User (OPRID), as well as the process instance. Because of this Application Engine has several meta-variables that can be used in the programs, in this case %%OperatorID and %%RunControl.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
412
Modifications to the Application Engine program.
The program will need to be modified to retrieve the user input parameters from the run control record and inserted into the state record. This is usually done in an initial step called RUNCNTL.
Other Delivered Pages
PeopleSoft delivers several standard pages and run control records for common user inputs. For example the As of Date, From Thru Date or Language options.
Asofdate
PeopleSoft provides a standard page for processes that require an Asofdate as input called RUNCNTL_ASOFDATE.
Fromthru
PeopleSoft also provides a standard page for processes that require a Fromdate and Thrudate called RUNCNTL_FROMTHRU.
Language Control
Instead of using the PRCSRUNCNTL_SBP page if you want to control the language that a program issues it'smessage in, you can use the PRCSRUNCNTL_LC_SBP, which is linked to the PRCSRUNCNTL.
Most delivered Run Control records support numerous Run Control pages.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
413
Activity 30: Implementing WAIT_SETIn this activity, you will review the activity overview and create a process definition to accept parameters for the WAIT_SET program.
See Application Engine: Activity Guide, "Creating Process Definitions for Application Engine," Activity 30: Implementing WAIT_SET.
Slide 219
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
414
Activity OverviewIn this activity, you will create a run control for WAIT_SET.
You will follow essentially the same steps as you did when setting up WAITLIST, but since WAIT_SET takes user input, you will need to do a little more work.
You will need to create a new run control record and a new run control page and modify the WAIT_SET program to retrieve user input from the Run Control record behind the page you are creating to launch the program.
This table gives you the details you need to implement the WAIT_SET program.
Step Description Details
1 Design We want to run this from Process Course Information
2 Identify initial bind variables - these will need to be included on the Run Control Record.
BONUS_NBR FROMDATE THRUDATE
3 Determine Run Control record. Create RUN_WAIT_SET
4 Build the record.
5 Determine Run Control page. Create RUN_WAIT_SET
6 Place page on a component. Create RUN_WAIT_SET
7 Use registration wizard to add component to a menu, register component in portal and set security.
Menu: PSU_TRAINING Bar: USE Portal: Employee Folder: PSU_COURSE_PROCESS Content Reference Label: Waitlist-Set Processing Sequence Number: 400 Node: :<use default local node checkbox> Permission List: PSU5000 Actions: Add, Update/Display
8 Add a Process Definition Must be the same name as the Application Engine program
WAIT_SET
9 Modify the program. Add a step to populate the state record with values from the run control record.
10 Test - Use the following Parameters: BONUS_NBR = 4 FROMDATE = 1st Jan 2002 THRUDATE = 1st Jun 2002
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
415
Activity Detailed StepsPerform the detailed steps to complete the activity.
Setting up a Process Definition for WAIT_SET
Perform the following steps:
1. Create a new run control record by opening the PRCSRUNCNTL record and selecting File, Save As.
a. Save as RUN_WAIT_SET.
b. Say Yes to save PeopleCode with the record.
c. Remove the fields LANGUAGE_CD and LANGUAGE_OPTION. (They are only necessary if you want to conditionally execute Sections based on a language code.)
d. Insert the following fields into the record by selecting Insert, Field:
BONUS_NBR
FROMDATE
THRUDATE
e. Build the record by selecting Build, Current definition and selecting create table.
2. Create a new run control page.
a. Open the page PRCSRUNCNTL.
b. Save as RUN_WAIT_SET. Click no to copying PeopleCode.
c. From the record RUN_WAIT_SET, drag and drop the following fields to the page:
BONUS_NBR
FROMDATE
THRUDATE
d. Save.
3. Create a new run control component.
a. In Application Designer, select File, New, Component.
b. Add the page RUN_WAIT_SET to the component by dragging the page from the project onto the component.
c. Access the component properties by selecting File, Definition Properties. On the Use tab, set the search record to PRCSRUNCNTL.
d. Leave all other defaults properties as they are.
e. Save the component as RUN_WAIT_SET.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
416
4. Select Tools, Register Component?
a. Accept the defaults for Add this component to a menu, Add this component to a portal registry, and Add this component to a permission list. Click Next.
b. Accept the defaults to add the component to the PSU_TRAINING menu. If it is blank select the PSU_TRAINING menu by selecting it from the push button. Select the USE bar from the drop down list. Click Next.
c. Enter the following information:
Page Element Value or Status
Content Reference Label Wait Set Processing
Sequence Number 400
Always use default local node? Selected
d. Click Next.
e. Verify that the permission list is PSU5000.
f. For Add all pages of this component with the following actions, select Add and Update Display. ClearUpdate/Display All and Correction.
g. Click Next.
h. Click Finish.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
417
5. Add a Process Definition.
a. Select PeopleTools, Process Scheduler, Processes.
b. Click the Add a New Value tab.
c. Enter the following information:
Page Element Value or Status
Process Type Application Engine
Process Name WAIT_SET
Page Element Value or Status
Description WaitSet Coordinator Bonus
Long Description This process will calculate whether the waitlist coordinator gets a bonus. It will issue a message if this is true.
Priority Medium
Process Category Default
API Aware Selected
d. Click the Process Definition Options tab.
e. Enter the following information:
Page Element Value or Status
Component RUN_WAIT_SET
Process Group TLSALL
f. Click Save. Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
418
6. Modify WAIT_SET Application Engine program to access the run control values.
a. Open the Application Engine program WAIT_SET.
b. Highlight the MAIN section.
c. Right-click, select Insert Step/Action.
d. Name the new step RUNCNTL.
e. Add the following SQL to the SQL action:
%Select(BONUS_NBR, FROMDATE, THRUDATE) SELECT BONUS_NBR, FROMDATE, THRUDATE FROM PS_RUN_WAIT_SET WHERE OPRID = %OperatorId AND RUN_CNTL_ID = %RunControl
f. Close the SQL Action and Save.
7. To test, navigate to Courses, Process Course Information, Wait Set Processing.
a. Select a run control ID.
b. Enter the following information:
Page Element Value or Status
Bonus Number 4
From Date 01 Jan 2002
Thru Date 01 Jun 2002
c. Click Run.
d. Click OK.
8. Select the Process Monitor link to monitor the progress of the process.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
419
Review
In this lesson you learned that:
• A process type definition defines command line, parameter list, working directory, and other general parameters for a Process Scheduler process.
• Application Engine Generic Test Type can be used to run an Application Engine program without creating the process definition (for testing).
• A process definition identifies the Application Engine program to the Process Scheduler.
• PeopleSoft supplies standard definitions as run control development starting points.
Slide 220
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Creating Process Definitions for Application Engine Lesson 12
420
Review (continued)
In this lesson you learned that:
The steps to add a new Application Engine program to the process scheduler are:
1 Design
2 Identify fields for user input to be included on the run control record.
3 Determine Run Control record
4 Build the record
5 Determine Run Control page
Slide 221
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 12 Creating Process Definitions for Application Engine
421
Review (continued)
6 Place page on a component
7 Register the component and set security with the registration wizard
8 Add a Process Definition
9 Add the necessary actions to your application engine program
10 Test
Slide 222
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
Process Types PeopleTools 8.50PeopleBook: PeopleSoft Process Scheduler, "Defining PeopleSoft Process Scheduler Support Information"
Process Definitions PeopleTools 8.50PeopleBook: PeopleSoft Process Scheduler, "Defining PeopleSoft Process Scheduler Support Information"
Input Parameters PeopleTools 8.50 PeopleBook: PeopleSoft Process Schedule,"Submitting and Scheduling a Process Request"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
423
Lesson 13
Using PSDAEMON
Objectives
By the end of this lesson, you will be able to:
• Describe PSDAEMON.
• Describe a daemon-only Application Engine program.
• List the steps to set up PSDAEMON.
• Create daemon groups.
• Monitor a daemon process.
Slide 224
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
424
Describing PSDAEMON
Daemon Programs
A daemon program is an Application Engine program of daemon type that checks for an event.
• When an event occurs, the daemon will trigger the process to handle the event.
• Daemons allow processes to be driven based on events rather than a schedule.
• Events can be internal or external to the PeopleSoft application database.
Slide 225
Student Notes
PSDAEMON
PSDAEMON is intended for recurrent jobs. These jobs are collected in a daemon group, and have specific criteria that must be met before they run. The daemon polls the system, checking for these conditions and events. When a condition is met, it schedules the process to handle the event.
Note these points:
• Daemons are event-driven.
Programs run based on an event, rather than chronological timing. In this way, unlike a program set up to recur inside of the Process Scheduler environment, they will run only when the triggering event occurs.
• A daemon triggers programs based on changes external to the application.
An example of how a daemon-type program is applied is to import files for the Integration Broker. The program is activated dynamically when some change occurs in the environment: a message is received, a file appears in a directory, and so on. This is compared to other processes that are triggered on-line when a user pushes a button, or within the batch environment, when a process is scheduled to run on a batch server.
PSDAEMON can help reduce overhead and maintenance for some processes.
• The processes spawned by daemons run only when needed rather than at a specific interval.
This also means that when work is ready to be performed, it will be done immediately, rather than having the job wait until a scheduled execution time is reached.
• They do not need scheduling; they can be set up once and run automatically.
This reduces Process Scheduler overhead that would otherwise be incurred both when checking on whether it is time for a process to run, and when a process is run un-necessarily when there is no work to be done.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
425
Describing a Daemon-Only Application Engine Program
PSU_FND_FILE
PSU_FND_FILE is a daemon-only Application Engine program that:
• Monitors the Temp directory.
• Looks for a file DAL_SESSIONS_x.txt
• If it finds the file, it runs the specified Application Engine program through Process Scheduler to process the file.
Slide 226
Student Notes
Example: Daemon-Only Program
PSU_FND_FILE is a daemon-only program.
Important! A daemon program only runs in a PSDAEMON group. It cannot be launched in two-tier, from the command line, or using the Process Scheduler.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
426
Describing a Daemon-Only Application Engine Program (continued)
PSU_FND_FILE Summary
Here is a summary of PSU_FND_FILE:
• StepM01 of MAIN contains a SQL statement that will select the current sequential file number for the DAL_FILE_NBR and place it in the state record (PSU_CRS_FND_AET).
• StepM02 contains a PeopleCode statement that will concatenate the file name string using the most current number and then look for the file on the local workstation in the temp directory.
• Step01 of the IMPORT section contains a PeopleCode statement that will insert a request into the Process Request Table for the Application Engine program IMP_DAL_SESS.
• In the program properties, Advanced tab, the Program Type is set to Daemon Only.
Slide 227
Student Notes
PSU_FND_FILE Code
Here is the code from StepM01:
%Select (NUM1) SELECT DAL_FILE_NBR FROM PS_CRS_FILE_NBR
Here is the code from StepM02:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
427
/* This is a sample daemon program for the PSU AE Course */Local string &FileName, &Num, &FileType, &NewFile;Local File &MYFILE, &MYFILE1;
&FileName = C:\temp\DAL_SESSIONS_;&Num = PSU_CRS_FND_AET.NUM1;&FileType = .txt;&NewFile = &FileName | &Num | &FileType;
/* This segment of code is for testing purposes.** Uncomment to test *//*&MYFILE = GetFile(C:\temp\test1.txt, A, %FilePath_Absolute);&MYFILE.Open(C:\temp\test1.txt, A, %FilePath_Absolute);&MYFILE.WriteLine(&NewFile);&MYFILE.Close();*/If FileExists(&NewFile, %FilePath_Absolute) Then &MYFILE1 = GetFile(&NewFile, R, %FilePath_Absolute); &MYFILE1.Open(&NewFile, R, %FilePath_Absolute); Exit (0);Else Exit (1);End-If;
Here is the code in the IMPORT section:
Local ProcessRequest &RQST;/* Create the ProcessRequest Object */&RQST = CreateProcessRequest();/* Set all Required Properties */&RQST.RunControlID = 'imptest';&RQST.ProcessType = 'Application Engine';&RQST.ProcessName = 'IMP_DAL_SESS';/* Schedule the Process */&RQST.Schedule();
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
428
Defining Daemon Groups
Daemon Groups
A collection of daemon programs for a Process Scheduler server definition is called a daemon group.
Unlike scheduled processes, the daemon group is re-initialized when a batch server restarts.
Grouped programs are run sequentially.
Each Process Scheduler server can have only one daemon group assigned to it.
Slide 228
Student Notes
Note These Points:
• Unlike scheduled processes, the daemon group is re-initialized when a batch server restarts
The PSDAEMON automatically restarts its processing when activated, without any intervention from an operator. It also re-initiates the process of checking for the conditions that trigger daemon Processes
• Group programs are run sequentially.
Daemon group programs run serially. One program must complete before the next will start. Daemon-type programs will not run in parallel, though they can trigger other programs that may run in parallel.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
429
Defining Daemon Groups (continued)
Daemon Groups
PSDAEMON programs are run by assigning them to a daemon group and associating that group with a Process Scheduler server definition that is used by a Process Scheduler server.
This diagram shows how PSDAEMON is tied to a Process Scheduler server.
Slide 229
Student Notes
Page Used to Assign Daemon Groups
Page Name Navigation
Daemon Group Definition PeopleTools, Process Scheduler, Daemon Group
Use the Daemon Group page to assign Application Engine programs to a daemon group.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
430
Page Used to Set Daemon Attributes
Page Name Navigation
Server Definition-Daemon PeopleTools, Process Scheduler, Servers, Server Name: PSNT, Daemon page.
Use the Server Definition component, Daemon page to determine whether the daemon is started, and to set attributes of the daemon's behavior.
Enabling Daemon Processes
To enable a daemon process for the selected server:
1. PeopleTools, Process Scheduler, Daemon Group.
2. Select the Add New Value page.
3. Enter a new daemon procedure group name.
4. Click the Add button.
The Daemon Group page displays.
5. Click the Load All Programs button to load all available application engine programs, or select a program to add.
(In a production environment you might not have all daemon programs loaded into one group. They couldbe split into separate groups assigned to different Process Scheduler servers.)
Programs must be marked as daemon in their properties to be available.
6. Click the Save button.
Programs can be assigned to this page by adding them to the list, or by clicking on Load All Programs, whichwill load all available Daemon programs into this group.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
431
Daemon page
Once the daemon procedure group has been defined, you need to add it to a server. A daemon process is an Application Engine process that runs continuously when PeopleSoft Process Scheduler is operational. It triggers other Application Engine processes based on the daemon group that is entered.
Daemon Sleep Time: Schedule a sleep time to control the activity of the process. Because the daemon is a process that runs in the background, it should not run continuously. A sleep time is the number of minutes for which the daemon process sleeps, or waits, before it checks for work. When it wakes, it checks for processes that need to be run on this process server.
Recycle Count: A cycle is the sequence of sleeping and working. The system automatically counts the number of times that it sleeps and works. When it reaches the recycle count value, the daemon process reboots itself.
You activate PSDAEMON in PeopleSoft Process Scheduler or from the command line.
Note. One PSDAEMON can run for each row in PS_SERVERDEFN. PS_SERVERDEFN.DAEMONENABLED must be set to 1(Daemon Enabled checkbox).
Note. PSDAEMON can be started from the command line.
Syntax:
psdaemon -CT <dbtype> -CD <dbname> -CO <userid>-CP <passwd> -R <servername>
The "-R " parameter is used to retrieve the Daemon Group, Sleep Time, and Recycle Count (restart the daemon after N iterations), from the server definition in PS_SERVERDEFN. <servername> is the key to PS_SERVERDEFN. You do not need to pass Process Instance (-I) or Application Engine Program ID (-AI).
This particular feature is not commonly used to launch the Daemon.
Recycle Count
The recycle count determines how many times PSDAEMON will run all Application Engine programs for thespecified sleep time. When it reaches the end of the recycle count the system will reboot the daemon process and reload any new recycle or sleeptime values, or load any changes to the code in the daemon programs in that group.
So, say you have bad code in a daemon program that is in a running daemon group and you change that code while the daemon group is running. If your recycle count is set to 100, you will have to wait until the group runs 100 times before the group reboots and thus reloads the new version of your program before you see thatfix.
Another way to restart your Daemon Group is to bounce the Process Scheduler server. Then you force the Daemon process to reboot and reload the new versions of your programs.
You can still add and delete Daemon programs to the Daemon group while it is in the middle of a full-cycle and they will be recognized immediately and run on the next single-cycle.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
432
Monitoring a Daemon Process
Process Monitor
Use Process Monitor to track daemon activity.
Once the daemon has been active for some time, status messages about its activity will begin to appear in the server Message Log
Use the Message Log link on the Server Detail page of Process Monitor to view messages.
Slide 230
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
433
Student Notes
Pages Used to Monitor Daemon Activity
Page Name Navigation
Process Monitor 1. Process Scheduler, Process Monitor.
2. Access the Server List tab.
3. Select the Details link.
Message Log Select the Message Log link.
• Use the Server Detail page to track daemon activity.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
434
• Use the Message Log page to view messages generated by the daemon process.
Use the Process Monitor to monitor messages that are issued directly by the daemon and messages that are issued by the application engine programs that the daemon initiates.
The Message link will display the message log page. A Delete button is located on this page, but it remains hidden when the daemon is running. When the Delete button appears, click it to delete all of the messages in the log.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
435
Activity 31: Creating a Daemon Group and Tracking Daemon Activity
In this activity, you will review the activity overview and:
1. Modify PSU_FND_FILE Application Engine Daemon program.
2. Create a Daemon group for the Process Scheduler.
3. Activate PSDAEMON.
4. Stop and start Process Scheduler.
5. Modify the IMP_DAL_SESS Application Engine program.
6. Move the files to be processed.
See Application Engine: Activity Guide, "Using PSDAEMON," Activity 31: "Creating a Daemon Group and Tracking Daemon Activity"
Slide 231
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
436
Activity OverviewIn this activity, you will modify the Daemon program PSU_FND_FILE to have the program search for the file on your local workstation. You will then create a new daemon group. Then you will add the new group tothe PSNT server definition and activate it. Finally, you will track execution of the daemon using Process Monitor.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program. If PSDAEMON is not executing, then please start it manually by typing following commands on command prompt.Cd /d C:\PeopleTools\bin\server\WINX86C:\PeopleTools\bin\server\WINX86>set PS_SERVER_CFG=C:\Documents and Settings\Administrator\psft\pt\8.50\appserv\prcs\T1B85001/psprcs.cfgC:\PeopleTools\bin\server\WINX86>set PS_SERVDIR=C:\Documents and Settings\Administrator\psft\pt\8.50\appserv\prcs\T1B85001C:\PeopleTools\bin\server\WINX86>psdaemon.exe -CT ORACLE -CD T1B85001 -CO PTTRN -CP PTTRN-R PSNT
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
437
Activity Detailed StepsPerform the detailed steps to complete the activity.
Modifying PSU_FND_FILE Application Engine Daemon program
To modify the daemon program:
1. Open the Application Engine program PSU_FND_FILE.
2. In the MAIN, STEPM02, open the PeopleCode action.
3. Edit, Replace.
4. In the Find what field enter \\<WORKSTATION>.
5. the Replace with field enter C:.
6. Replace All.
You should get 3 replacements. Verify that the new paths look something like this:
C:\temp\DAL_SESSIONS_
7. Save.
Creating a Daemon Group for the Process Scheduler
To create a daemon group for the Process Scheduler:
1. Navigate to the Daemon Group Definition Page.
a. Select PeopleTools, Process Scheduler, Daemon Group
b. Click the Add a New Value tab
c. For Daemon Procedure Group, enter PSUDAEMO.
d. Click Add.
2. In the Daemon Group page, click the lookup icon on the Program Name field and select PSU_FND_FILE to add the program to the Daemon group.
3. Click Save.
Activating PSDAEMON
To activate PSDAEMON:
1. Add the Daemon Group to the PSNT Server definition.
a. Select PeopleTools, Process Scheduler, Servers.
b. Search for Server Name, select PSNT.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
438
2. Click the Daemon Tab.
3. Enter the following information:
Page Element Value or Status
Daemon Enabled Selected
Daemon Group PSUDAEMO
Daemon Sleep Time 2
Recycle Count 2
4. Save.
Stopping and Starting Process Scheduler
To stop and start Process Scheduler:
1. Double-click the PeopleTools folder on the desktop.
2. Double-click the icon for psadmin.exe.
3. Type 2 and Enter to select Process Scheduler.
4. Type 2 and Enter for Stop a Process Scheduler Server.
5. Type the number corresponding to your database and Enter.
6. Type 1 and Enter to select Start a Process Scheduler Server.
7. Type the number corresponding to your database and Enter.
8. Type Q and Enter twice to quit.
Modifying the IMP_DAL_SESS Application Engine program
Now that you have the daemon group active, it is looking for the file DAL_SESSIONS_1.TXT. When PSU_FND_FILE daemon program finds the file, the IMP_DAL_SESSN Application Engine program will run.
This program will import the course session data into a staging table PS_CRS_SESSN_STG. The file layout CRS_SESSN_STG contains the record CRS_SESSN_STG.
To modify the IMP_DAL_SESS Application Engine program:
1. Open the IMP_DAL_SESS Application Engine program in the Application Designer.
2. In MAIN section, StepM02, open the PeopleCode action by right clicking and selecting View PeopleCode.
3. Edit, Replace.
4. In the Find what field enter \\<WORKSTATION>.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
439
5. In the Replace with field enter C:.
6. Replace All.
7. You should have 2 replacements.
Verify that the paths are in this form:
C:\temp\DAL_SESSIONS_
8. Save.
Moving the Files to be Processed
To move the files to be processed:
1. Copy the files DAL_SESSIONS_1 and DAL_SESSIONS_2 from C:\labs\0411_AppEngine\Files to the C:\TEMP directory.
Copy the files DAL_SESSIONS_1 and DAL_SESSIONS_2 from C:\labs\0411_AppEngine\Files. to the C:\TEMP directory.
2. Navigate to Process Monitor and follow the Process List display, occasionally refreshing it by clicking theRefresh button.
3. Click the Details link to view log information about the Process.
Checking Process Monitor to be Sure the Process Ran Successfully
To check Process Monitor to be sure the process IMP_DAL_SESS Application Engine program ran successfully:
1. Process Scheduler, Process Monitor.
2. Search for processes run by User ID PTTRN.
The Process Scheduler server runs the daemon process as user PTTRN.
3. Follow the Process List display, occasionally refreshing it by clicking the Refresh button.
4. Click the Details link to view log information about the process.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
440
Activity 32: Creating PSU_ENR_STU as a Daemon ProcessIn this activity you will review the activity overview and write the PSU_ENR_FND Application Engine program, then test the running of the program by PSDAEMON.
See Application Engine: Activity Guide, "Using PSDAEMON," Activity 32: Creating PSU_ENR_FND as a Daemon Process.
Slide 232
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
441
Activity OverviewCurrently there are customers that use messaging for their student enrollments. The message data received is stored in a staging table, PS_STU_ENROLL_STG. An existing Application Engine program, PSU_ENR_STU, reads the staging table and updates the student enrollment table, PS_PSU_STU_ENROLL.
Rather than running this program manually or setting up a recurring job in the Process Scheduler, management has decided they would like to have the program run when 5 messages have been entered in the PS_STU_ENROLL_STG table.
Write a daemon program that will run PSU_ENR_STU when at least 5 rows of data are present in the PS_STU_ENROLL_STG table.
Do you need a state record?
Name the program PSU_ENR_FND.
Add the program to the PSUAEMO daemon group.
Here is code that you could use.
• In a Do When, or any conditional action
%Select(TEMP_FLD) SELECT 'X' FROM PS_STU_ENROLL_STG HAVING COUNT(*) >= 5
• In a PeopleCode Action
Local ProcessRequest &RQST;/* Create the ProcessRequest Object */&RQST = CreateProcessRequest();/* Set all Required Properties */&RQST.RunControlID = 'Enroll';&RQST.ProcessType = 'Application Engine';&RQST.ProcessName = 'PSU_ENR_STU';/* Schedule the Process */&RQST.Schedule();
To simulate messages being received, here are three SQL scripts that you can run in SQL Developer to populate the PS_STU_ENROLL_STG table.
• C:\Labs\0411_AppEngine\SQL\Activity32 A.sql
• C:\labs\0411_AppEngine\SQL\Actvitiy 32 B.sql
• C:\labs\0411_AppEngine\SQL\Activity 32 C.sql
Run each script in turn and watch to see how the daemon processes it.
Once the tables have been populated, you can check whether or not your program ran by watching Process Monitor:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
442
Note. Disconnect from the database in SQL Developer before running an Application Engine Program. If PSDAEMON is not executing, then please start it manually by typing following commands on command prompt. Cd /d C:\PeopleTools\bin\server\WINX86 C:\PeopleTools\bin\server\WINX86>set PS_SERVER_CFG=C:\Documents and Settings\Administrator\psft\pt\8.50\appserv\prcs\T1B85001/psprcs.cfg C:\PeopleTools\bin\server\WINX86>set PS_SERVDIR=C:\Documents and Settings\Administrator\psft\pt\8.50\appserv\prcs\T1B85001 C:\PeopleTools\bin\server\WINX86>psdaemon.exe -CT ORACLE -CD T1B85001 -CO PTTRN -CP PTTRN-R PSNT
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
443
Activity Detailed StepsPerform the detailed steps to complete the activity.
Creating PSU_ENR_STU as a Daemon Process
To create PSU_ENR_FND as a Daemon Process:
1. Write PSU_ENR_FND.
2. Add the program to the PSUDAEMO daemon group.
3. Populate the PS_STU_ENROLL_STG table.
4. Check Process Monitor to be sure the process ran successfully.
Writing PSU_ENR_STU
To write PSU_ENR_FND:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
444
1. In Application Designer, create a new Application Engine program.
a. Save as PSU_ENR_FND.
b. Access the program properties by selecting File, Definition Properties.
c. On the State Records tab, assign the state record ENR_FND_AET.
d. On the Advanced tab, select the disable restart checkbox.
e. Also on the Advanced tab, for Program Type select Daemon Only from the dropdown list and click OK.
Also on the Advanced tab, for Program Type select Daemon Only from the dropdown list and click OK.
f. In the MAIN section, in Step01, add a Do When action.
g. Insert the following code:
%Select(ENR_FND_AET.TEMP_FLD) SELECT 'X' FROM PS_STU_ENROLL_STGHAVING COUNT(*) >= 5
h. Insert an action in Step01 after the existing Do When action.
i. Change the action type to PeopleCode
j. Insert the following PeopleCode:
Local ProcessRequest &RQST;/*Create the ProcessRequest Object*/&RQST = CreateProcessRequest();/*Set all Required Properties */&RQST.RunControlID = "Enroll";&RQST.ProcessType = "Application Engine";&RQST.ProcessName = "PSU_ENR_STU";
/*Schedule the Process*/&RQST.Schedule();
2. Save.
Adding the Program to the PSUDAEMO Daemon Group
Paragraph automatically inserted
1. PeopleTools, Process Scheduler, Daemon Group.
2. For Daemon Procedure Group, enter PSUDAEMO and click SEARCH..
3. Click on the Insert Row button (+) and select the lookup icon to select the Program Name of PSU_ENR_FND.
4. Verify that the PSU_ENR_FND program is added.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 13 Using PSDAEMON
445
5. Click Save.
Populating the PS_STU_ENROLL_STG Table
To populate the PS_STU_ENROLL_STG table:
1. Open the file C:\labs\0411_AppEngine\SQL\Activity32 A.sql.
2. Copy the text into SQL Developer and execute the SQL statements in Activity32 A.sql one by one.
Note. When a SQL statement (DML) is being executed using SQL developer, it is a recommended practice tomanually perform a commit by clicking the commit toolbar button or pressing the F11 key.This needs to be followed even in cases where an Application Engine program is executed after executing DML statements in SQL developer.
Checking Process Monitor to be sure the process ran successfully
To check Process Monitor to be sure the PSU_ENR_STU Application Engine program ran successfully:
1. Process Scheduler, Process Monitor.
2. Search for processes run by User ID PTTRN.
The process scheduler server runs the daemon process as user PTTRN.
3. Follow the Process List display, occasionally refreshing it by clicking the Refresh button.
4. Click the Details link to view log information about the Process.
5. Run the SQL in the following files and observe the effects in Process Monitor:
• C:\labs\0411_AppEngine\SQL\Activity32 B.sql
Execute the SQL statements in Activity32 B.sql one by one.
• C:\labs\0411_AppEngine\SQL\Activity32 C.sql
Execute the SQL statements in Activity32 C.sql one by one.
Note. When a SQL statement (DML) is being executed using SQL developer, it is a recommended practice tomanually perform a commit by clicking the commit toolbar button or pressing the F11 key.This needs to be followed even in cases where an Application Engine program is executed after executing DML statements in SQL developer.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Using PSDAEMON Lesson 13
446
Review
In this lesson you learned that:
• PSDAEMON is a process that runs continuously when the Process Scheduler is running, and is intended forrecurrent jobs.
• A daemon-only Application Engine program polls the system checking for certain conditions to be true, andwhen true, it schedules a process.
• A daemon group contains a list of daemon programs.
• Daemon activity can be tracked using the message log from the Server Detail page of the Process Monitor.
• Once a daemon group is associated with a server and enabled, PSDAEMON will run.
Slide 233
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
PSDAEMON Enterprise PeopleTools 8.50 PeopleBooks: PeopleSoft Application Engine, "Understanding Application Engine"
Daemon Groups Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler, "Setting Server Definitions"
Process Monitor Enterprise PeopleTools 8.50 PeopleBook: PeopleSoft Process Scheduler,"Setting Server Definitions"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
447
Lesson 14
Measuring Application Engine Performance
Objectives
By the end of this lesson, you will be able to:
• Describe traces.
• Pass trace values to psae.exe.
• Interpret Application Engine trace data.
• Interpret the PeopleTools trace.
• Describe advanced trace options.
Slide 235
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
448
Describing Traces
Three Traces
You will look at three traces:
• Application Engine Trace.
• SQL Trace.
• PeopleCode Trace.
Slide 236
Student Notes
Performance
Throughout this course we have focused purely on the creation of your Application Engine program. However, creating your Application Engine program to perform the job your customers have requested may only be part of your effort. Once you have thoroughly tested the program to verify that it is accomplishing thetask required, you may now need to fine-tune it to perform the task faster and more efficiently.
As your Application Engine program gets more complex and works with more rows of data, the time for it to complete will increase and its efficiency will decrease. Performance tuning your program can shave significant amounts of time off its execution. Why have a job run 2 hours when a few simple changes could cut that time in half?
Performance may also be a business-critical issue. For example, let's say you have a process-intensive Application Engine program that needs to run each night to perform a task before the next business day. It needs to be run in a 4-hour window when no one is on the system. Once the Application Engine program is created the job takes 6-hours to complete. A means must be found to fit the program into the allotted time. Performance tuning is key to solving this type of problem.
Traces
Measurement is essentially gathering and interpreting performance statistics for your Application Engine program. There are three types of traces in PeopleSoft for Application Engine:
• Application Engine trace.
The Application Engine trace is used to trace the Application Engine program as it is executing. We have already looked at the step and SQL traces to assist in debugging your Application Engine programs; however there are also options for timings and optimization that will assist in determining the efficiency of your program.
• SQL trace.
The SQL trace is used only when the information gathered in the Application Engine trace is not sufficient. The SQL trace options are used to measure the line-by-line details of your program execution.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
449
• PeopleCode trace.
The PeopleCode trace is used when you are executing PeopleCode within your Application Engine program.
Interpretation of the measurement data is a vital part of the tuning process. It cannot be emphasized enough how significant this step is. Without a good understanding of which aspects of your program are slow, tuning it would be like trying to hit a target in the dark. Once interpreted, you can direct your focus to the specific area that stands to gain the most from your tuning efforts.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
450
Describing Traces (continued)
PSAE.EXE Command-Line Parameters
This table summarizes PSAE.EXE command-line parameters for tracing.
Trace Name Trace Description ParameterTypical Trace Value
Application Engine Trace
Application Engine Trace File -TRACE <tracevalue> 384
SQL Trace Tools SQL Trace -TOOLSTRACESQL <tracevalue> 31
PeopleCode Trace Tools PeopleCode Trace -TOOLSTRACEPC <tracevalue> 2048
Slide 237
Student Notes
Trace Options
You collect performance measurements for your program by turning on one of the Application Engine trace options. These trace options send your trace output to a trace file or in some cases an output table.
We discussed the basics of tracing and debugging your Application Engine program in lesson 4 "Testing and Debugging." However, it is important to understand more details about collecting trace data for performance tuning in order to be most effective.
Along with the mandatory list of parameters that must be passed to the psae.exe, there are three optional traceparameters that can be passed to gather performance data and send it to a file output or a table output.
The <tracevalue> entered determines the amount of detail sent to your trace output.
Within each of these three trace parameters there are several trace options. Each trace option has a number value assigned to it. When the numbers of all the trace options you desire are added together, you end up withthe <tracevalue> you will assign to one of the three trace parameters.
Typical Performance Tuning Trace Values
Which trace parameter you use depends on the level of details you are looking for. For performance tuning it is always best to start with the simplest trace that takes the least amount of time to run and decipher. Using -TRACE 384 is the best place to start. If more details are desired -TOOLSTRACESQL 31 and -TOOLSTRACEPC 2048 would be the next step.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
451
Describing Traces (continued)
Trace Values
Here are 4 of the 8 trace values available to you for the -TRACE parameter:
Value Description
1 Step Trace
2 SQL Trace
128 Timings Trace
256 PeopleCode Detail Timings
If you want Timings Trace Option (128) and PeopleCode Trace Option (256), add their values together to yield a trace value of 384.
Slide 238
Student Notes
Trace Values
Warning! Using all possible trace values for all three trace parameters simultaneously and executing your program will give you measurement data that is unnecessary and redundant, causing the program to be slow.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
452
Passing Trace Values to PSAE.EXE
Two-Tier Trace Settings
Use the Configuration Manager trace tab to select two-tier trace settings for:
• Application Engine Trace.
• SQL Trace.
• PeopleCode Trace.
Slide 239
Student Notes
Two-Tier Trace Settings
Use Configuration Manager to set traces for two-tier run processes only.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
453
One way you can pass the parameter values for a two-tier run Application Engine program is through the Configuration Manager. Settings here apply only to those processes that are run via Application Designer, typically when testing Application Engine programs during development. You would not use trace settings here to trace a program running from the command line, the Process Scheduler, or via an on-line call (CallAppEngine).
Application Engine Trace
Selecting the options above is equivalent to the -TRACE 384 parameter sent to psae.exe. This is always the best place to start your tuning measurement and analysis.
You do not have to log off after changing these settings.
Note. Trace file locations are discussed in the lesson 5, "Testing and Debugging."
SQL Trace
Selecting the options above is equivalent to the -TOOLSTRACESQL 31 parameter. This trace file gives line-by-line details of your execution.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
454
PeopleCode Trace
Selecting the options above is equivalent to the -TOOLSTRACEPC 2048 parameter. This trace file gives line-by-line details of your execution.
This trace gives you details of every line of PeopleCode executed in your Application Engine program. If your Application Engine program does not contain any PeopleCode Actions, you will not get any additional output.
PeopleTools and SQL Trace
Because these traces are far more detailed and take more time to run they should be used only when the information gathered in the -TRACE 384 is not sufficient.
Important! Note: You must log off of all PeopleSoft applications and re-log on before any new SQL Trace and PeopleCode Trace settings set in Configuration Manager take effect.
PeopleTools and SQL Trace Output File Location
If no trace location is entered the default for the debug file will be C:\Temp\dbg1.tmp. The trace file will be inC:\TEMP\.
Warning! When this two-tier only trace is used, in addition to tracing your Application Engine program, all SQL generated by other PeopleSoft Applications on the two-tier client (for example, Application Designer) will be traced by using this method. This can fill the trace file with data that is not relevant to your Application Engine program's run. Moreover, the trace file will be appended to the existing trace data until trace is turned off. Multiple Application Engine executions will all be stored on the same trace file. You may want to rename or delete the old trace file before starting a new trace.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
455
Passing Trace Values to PSAE.EXE (continued)
Process Scheduler Trace
If your program is being run through Process Scheduler, you can pass the additional trace parameters to the Process Definition, on the Override Options page.
Slide 240
Student Notes
Page Used to Set Trace Settings
Page Name Navigation
Override Options PeopleTools, Process Scheduler, Processes
Use the Override Options page to set trace settings for a process definition.
Access the Trace File from a process run through Process Scheduler.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
456
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
457
Passing Trace Values to PSAE.EXE (continued)
Command Line Trace
To pass the additional tracing variables when executing your program from a command line, add on any additional parameters that you need with the trace value you want.
Slide 241
Student Notes
Command Line Trace Settings
Command Line Trace File Locations
Command Prompt or .bat file
Here is a sample dialog:O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
458
C:\Labs\0411_AppEngine\Bat>NOTEPAD PERF_TUN.BAT C:\Labs\0411_AppEngine\Bat>PERF_TUN C:\Labs\0411_AppEngine\Bat>C:\peopletools\bin\client\winx86\PSAE.EXE -CT ORACLE -CD T1B85001 -CO PTTRA -CP PTTRA -R PERF_TUN -AI PERF_TUN -TRACE 384 -TOOLSTRACESQL 31 -TOOLSTRACEPC 2048 PeopleTools 8.50 - Application Engine Copyright (c) 1988-2003 PeopleSoft, Inc. All Rights Reserved PeopleTools SQL Trace value overrides configuration setting after db login. Configuration setting: 0 (0) PeopleTools SQL Trace value: 31 (0x1f): C:\TEMP\TRACE.TXT PeopleTools PeopleCode Trace value: 2048 (0x800): C:\TEMP\TRACE.TXT Process Completed (30000,1) Application Engine program PERF_TUN ended normally Timings written to trace file (c:\temp\AE_0403155652_528.AET) C:\Labs\0411_AppEngine\Bat>
Trace File Locations
The last two lines of the sample dialog show the trace file locations.
When run in a Command window, the name of the trace files will differ slightly from other execution methods:
• -TRACE
• If you do not specify a -I parameter: AE_<Date/Time_Stamp>_<OS_PID>.AET
• If you do specify a -I parameter: AE_<Program_name>_<Process_Instance>.AET
• -TOOLSTRACESQL, -TOOLSTRACEPC
The file names and file locations may differ depending on the exact PeopleTools release you are operating on. The best way to find your trace files is to look at your command window while your program is operating. In the first few lines you will see the exact directory paths and file names.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
459
Passing Trace Values to PSAE.EXE (continued)
CallAppEngine Trace File Settings
Application Engine trace (-TRACE) settings are turned on in the Application Server configuration file using PSADMIN.
Trace settings made here affect all users and all online activity.
The SQL and PeopleCode traces may be activated for individual users via PIA trace options if available at logon.
The trace files will be sent to the Application Server's log file directory.
Slide 242
Student Notes
CallAppEngine Trace File Settings
Under some circumstances, it may be necessary to test the performance of Application Engine programs that are executed online using the CallAppEngine PeopleCode function. If this is the case, the settings to trace the program must be made on the application server domain that will execute the request. Similarly, the trace files will be located in the domain's log file directory.
All three can be turned on via PSAdmin.
There is also a logon trace option that can be used by users if the environment settings have been configured to allow it. This allows users to type &trace=Y at the end of the browser's URL on the Signon Page. If the user-defined logon trace is enabled, from PIA and at logon, the user can only set TOOLSTRACESQL and TOOLSTRACEPC.
Note. Turning on trace for Application Engine at the application server level is discussed in the Server Administration class.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
460
Activity 33: Tracing Application Engine ProgramsIn this activity, you will review the activity overview and:
• Trace WAITLIST through Process Scheduler.
• Trace PERF_TUN from the command line.
See Application Engine: Activity Guide, "Measuring Application Engine Performance," Activity 33: Tracing Application Engine Programs.
Slide 243
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
461
Activity OverviewIn this activity, you will set up tracing for WAITLIST and PERF_TUN. First, you will modify the parametersfor the WAITLIST process definition to add tracing, and then execute the program using Process Scheduler. You will open the trace files that are generated using Process Monitor.
In the second part of the activity, you will modify a batch file to run PERF_TUN.
Important! All trace parameters and trace values must be separated by a space.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
462
Activity Detailed StepsPerform the detailed steps to complete the activity.
Tracing WAITLIST through Process Scheduler
For the WAITLIST Application Engine program, you will record trace data for all three trace parameters when the program is run through Process Scheduler.
To trace WAITLIST through Process Scheduler:
1. Append to the Parameter List parameter on the process definition.
a. Select PeopleTools, Process Scheduler, Processes.
b. Choose the WAITLIST process definition.
c. Click the Override Options tab.
d. In the Parameter List field, select Append.
e. In the Parameter field, enter the following:
-TRACE 384 -TOOLSTRACESQL 31 -TOOLSTRACEPC 2048
f. Save.
2. Run the program from your web browser.
a. Select Courses, Process Course Information, Waitlist.
b. Click Search and choose any run control ID.
c. Click Run.
d. On the Run Control Request page, click OK.
3. View the trace file.
a. Select the Process Monitor link on the run control page.
b. Verify that the User ID is PTTRA.
c. When the process completes successfully, select the Details link in Process Monitor.
d. Select the View Log/Trace link.
e. Select the Application Engine Trace File link (.AET) to view the Application Engine trace.
f. Select the PeopleSoft Trace File link (.trc) to view the PeopleCode and SQL traces.
Tracing PERF_TUN from the Command Line
To demonstrate trace measurements, you will run an Application Engine program that incorporates a Do While loop, incrementing a counter up to 500. On each loop it inserts a row of data on a table with a key value that is equal to the counter's value.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
463
Ideally you would test your program in the same location it will be run by its users. However, that is not always realistic and generally speaking, you will test the program on a client machine in a development or test environment. In class we will do most of our testing as if we were in development and run our programs on the client. We will execute the program on the client via a .bat file using all three trace parameters.
To trace PERF_TUN from the command line:
1. Modify PERF_TUN.bat.
The bat file, PERF_TUN.bat, is located in C:\labs\0411_AppEngine\Bat. You will need to change some of the parameters so the program will work.
a. Open the file for editing using Notepad.
b. Replace <PSHOME> with the appropriate path for your environment.
c. Replace <database> after the -CD parameter with the name of your classroom database.
d. Save the file.
Notice how we are executing psae.exe on the client. Therefore all our trace files will be sent to the client.
Scroll to the right in Notepad to view the trace parameters.
2. Set the trace file location in Configuration Manager.
a. In Configuration Manager on the Trace tab, click the Clear Trace Settings button.
b. For PeopleTools Trace File, enter C:\Temp\Trace.txt.
This file will contain the output from the -TOOLSTRACESQL and -TOOLSTRACEPC settings. The actual trace settings on the tab are irrelevant, because the trace is controlled by the parameters supplied on the command line.
3. Turn off the Debugger. This is IMPORTANT!
a. In Configuration Manager, click the Profile tab.
b. Click the Edit button.
c. Click the Process Scheduler tab.
d. Clear Debug.
e. Click OK, and OK again.
4. Double click the PERF_TUN.bat file to run the Application Engine program.
5. Locate the trace files created, in C:\Temp\Trace.txt (for SQL and PeopleCode), and %TEMP%\PS\T1B85001 folder for the Application Engine Trace.
Locate the trace files created, in C:\Temp\Trace.txt (for SQL and PeopleCode), and C:\temp for the Application Engine Trace.
6. Compare your Application Engine trace file with the results below.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
464
Results
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
465
Interpreting Application Engine Trace Data
Application Engine Trace File
The Application Engine trace file contains:
• Columns for Compile, Execute, and Fetch counts and time.
• A Total Time column.
• A summary of PeopleCode actions.
• Timing for PeopleCode built-in functions and methods.
• A summary section.
Slide 244
Student Notes
SQL Counts and Timing
This is an example of SQL counts and timing:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
466
Batch timings from -TRACE parameter
The most valuable information for assessing your program's performance would be the batch timings trace information gathered by the -TRACE parameter. It will give you a helpful overview of the timings associated with your program's execution. This trace is by far the best place to start your performance analysis.
SQL counts and timings
The SQL counts and timings section is the place to start to decipher your trace file and ultimately assess your program's performance. This section gives a combination of total time as well as detail timings.
The last column ,Total Time, shows at a high level which sections, steps and actions of your program are taking the most time to execute.
When an Application Engine program has many PeopleCode actions accomplishing similar things it becomes difficult to decipher which action is which in your trace file.
Using a property of the SQL class called TraceName can change the SQL statement names for the PeopleCode actions.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
467
Performance analysis
For the most part, the best use of your performance tuning time is by focusing your attention on areas that are taking the most time but accomplishing the least amount of work towards your program's central goal.
For example: The Total Run Time for the program run for this guide is 450.6 seconds. 253.7 seconds of this time-over half the total time-is being spent executing tasks in the Application Engine section of our trace. These tasks are 1004 commits and 1004 checkpoints. In the next lesson "Tuning Application Engine Programs," we will see how we can improve our performance by restructuring the commits of our program.
Let's examine the three SQL statement columns in more detail:
• Compile
• Execute
• Fetch
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
468
Interpreting Application Engine Trace Data (continued)
Compile Logic
This diagram illustrates that a SQL statement generated by Application Engine is sent to the database and the database uses its table statistics to create an execution plan.
Slide 245
Student Notes
Compile Columns
This segment of the trace file shows the Compile columns:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
469
The Compile column indicates the number of times (Count) a specific SQL statement was sent to and interpreted by the database, and the total amount of time (Time) that took. When a database compiles a SQL statement it is essentially preparing the SQL statement for execution. Preparation is essentially checking the syntax of the SQL statement (parsing) and optimizing and creating the execution plan.
As you can see in the trace file, MAIN.PcodLoop Do While was sent to, and interpreted by the database 501 times, taking 5.8 seconds. Because the task this program is performing is so simple, the extra compiles do not add much to our overall time. However, on a larger program, additional and unnecessary compiles can add a lot of unnecessary time to your program. In the next lesson, we will show how you might be able to avoid some additional compiles.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
470
Interpreting Application Engine Trace Data (continued)
SQL Select Execute Logic
This diagram shows that the database executes the compiled SQL select statement to gather the rows into its database fetch buffer:
Slide 246
Student Notes
Execute Time
For a Select statement the execute time also includes the time necessary to retrieve the initial set of data into the fetch buffer. When the amount of data retrieved by the Select exceeds the space available, the database engine may refill the buffer several times, but this does not require a re-execution of the SQL statement.
This segment of the trace file shows the Execute columns:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
471
The Execute columns show the count and the total time to run the SQL statement. The statement could have been a SQL Insert or an Update, for example. Working with indexes, restructuring your SQL syntax, or other database-level tuning might be a good place to improve the time of your executes.
If it is a Select statement that is being executed, the rows are retrieved and placed into the database's fetch buffer. These rows will be considered the active set.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
472
Interpreting Application Engine Trace Data (continued)
Application Engine Fetch Logic
This diagram shows how the fetch moves the data from the fetch buffer back to the Application Engine program's memory:
Slide 247
Student Notes
Fetched Rows
The state record allocates memory for fetched rows, one row at a time.
Fetch measures the time to move data from the database to the Application Engine program.
This segment of the trace file shows the Fetch columns.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
473
Fetch Buffer
Fetch buffer is a term that may not apply to all database platforms. For instance in Oracle it is just called the data buffer. However, in all cases the concept of a memory buffer space used to hold onto the rows retrieved in the Active Set is still the same.
Fetch Column
You will only see counts and timings in these columns when you are executing a SQL Select. Once the active-set of rows is retrieved and held in the database's fetch buffer, a fetch is done to get the data from the fetch buffer to the Application Engine program. If a program has bad fetch times both on the client and on theserver, this may indicate that you need to do some tuning at the SQL or database level of your program.
For best performance, it would be ideal to see significantly higher fetch counts than compile counts or execute counts in your timings trace.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
474
Interpreting Application Engine Trace Data (continued)
Application Engine Trace Sort
Each line of an Application Engine trace is sorted alphabetically and begins with the section name, the step name, and a code that indicates the type of action.
For example:
AE Program: WAITLISTADDCOUNT.StepA1.SCOMPARE.StepC1.SCOMPARE.StepC2.HMAIN.StepM1.DMAIN.StepM1.NMAIN.StepM2.H
Slide 248
Student Notes
Trace Codes
Here is a list of the codes and the actions they represent:
Trace Code Action
H Do When
W Do While
D Do Select
S SQL
N Do Until
Supplemental Trace File Information
Call Section, Log Message, and PeopleCode actions do not have a corresponding code because they appear ina different section.
When the trace file lists the trace timing details for each individual action within a step, they are not listed in their execution order. The actions are listed alphabetically by their section names and action codes.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
475
Interpreting Application Engine Trace Data (continued)
PeopleCode Actions
This portion of the PERF_TUN's trace file shows timings for the PeopleCode actions:
Slide 249
Student Notes
PeopleCode Timings
Look at your trace file for the PERF_TUN execution.
The timings for any PeopleCode actions will appear in two separate areas of the timings trace file.
The Non-SQL Time column relates to time spent performing PeopleCode tasks such as manipulating object's methods and properties, while the SQL time column relates to any actual SQL performed within your PeopleCode.
If you see a large percentage of your program's time dedicated to SQL in PeopleCode (SQL Time column above) this is an immediate red flag, as you are likely taking a performance hit. In the next lesson we will discuss the execution of SQL with a PeopleCode Action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
476
Interpreting Application Engine Trace Data (continued)
PeopleCode Built-in Functions and Methods
This section of the trace shows the timing for PeopleCode built-in functions and methods:
Slide 250
Student Notes
PeopleCode Built-in Functions and Methods
This section of the trace shows details about the time it took to execute specific methods within PeopleCode in your program. Some of the data in this section is present because of the PeopleCode Detail Timing option. In this trace the option was turned on by using -TRACE 384 (128 + 256 =). The 256 value is what generated this number.
The Type in parentheses is an internal representation of the PeopleCode type.
To improve these numbers you could create a global object and fetch it several times for speed improvements.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
477
Interpreting Application Engine Trace Data (continued)
Totals Summary
This section of the trace file shows the overall totals:
Slide 251
Student Notes
Totals Section
This chart shows how the totals section of the trace file is calculated:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
478
This table summarizes time calculations based on the trace file:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
479
Item Calculation
Total run time: B + C + D + Application Engine overhead + time in cache.
Total time in application SQL: A + B + C
Percentage time in application SQL: Time in Application SQL / Total Run Time
Total time in PeopleCode: E
Percent time in PeopleCode: Time in PeopleCode / Total Run Time
Total time in cache: Total time PeopleTools spent retrieving meta data from PeopleTools Cache. This meta data could have been foundlocally in memory, locally in a file or remotely on the database.
Number of calls to cache: Internal measurement used to diagnose cache bugs.
Percentage Time in Application SQL
Ideally, you want the Percentage Time in Application SQL to be the largest percentage of your program's execution. That means your Application Engine program is doing what it is best at doing, SQL. But a low percentage number is not necessarily bad.
If your time in SQL is low and your time in PeopleCode is high, there is a good chance you are spending additional time in remote calls to COBOL or an outside process like Business Interlinks.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
480
Interpreting Application Engine Trace Data (continued)
Trace Values
This section of the trace file shows the trace values:
Slide 252
Student Notes
Trace Values
At the very bottom of the trace file you can see information that tells you what the overall trace settings were when your program was run.
The last line is the value passed to -DB FLAG psae.exe parameter. This is used for disabling any %UpdateStats Meta SQL in your Application Engine program. This will be discussed in the next lesson " Tuning Application Engine Programs."
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
481
Interpreting Application Engine Trace Data (continued)
Dedicated Temporary Table Trace
This is a segment of a trace generated by a dedicated temporary table trace:
Slide 253
Student Notes
Ded. Temp. Table Trace Option
The Ded. Temp. Table trace option is useful only when your program is utilizing Dedicated Temporary tables(Temporary Table type Record Definitions). If turned on, you will see trace information for the various activities that surround the usage of your temporary tables.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
482
Activity 34: Interpreting the WAITLIST Trace FileIn this activity, you will review the activity overview and examine the trace file for WAITLIST to identify what processing was performed.
See Application Engine: Activity Guide, "Measuring Application Engine Performance," Activity 34: Interpreting the WAITLIST Trace File.
Slide 254
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
483
Activity OverviewExamine the Application Engine trace file generated when you ran the WAITLIST program. From the information it contains answer the following questions:
1. Determine the following in Main StepM01.
Question Answer
How many times we are doing a COMPILE?
How many times we are doing an EXECUTE
How many times we are doing a FETCH?
2. Looking all the steps and actions, answer the following question:
Question Answer
Which single task seems to be taking the longest?
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
484
Interpreting the PeopleTools Trace
TOOLSTRACESQL and -TOOLSTRACEPC
Use -TOOLSTRACESQL and -TOOLSTRACEPC only when:
• The level of detail in the -TRACE parameter is not enough or
• You required more specific details about the activities surrounding your program's execution.
• The PeopleTools Trace file will have the combined data collected for the PeopleCode trace and the SQL trace.
Slide 255
Student Notes
TOOLSTRACESQL and -TOOLSTRACEPC
The two trace options -TOOLSTRACESQL and -TOOLSTRACEPC gather a lot of data and are typically only used if the level of detail in the -TRACE parameter is not enough or you required more specific details about the activities surrounding your program's execution. There is significant overhead involved with running these trace options and they should be used only when necessary.
The PeopleTools Trace file will have the combined data collected in the -TOOLSTRACESQL trace parameter and the -TOOLSTRACEPC trace parameter.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
485
Interpreting the PeopleTools Trace (continued)
Column Definitions
This diagram shows the SQL trace information in the PeopleTools trace file:
Slide 256
Student Notes
Column Definitions
There are many details in any SQL trace. We will limit our discussion to the areas that are significant to performance tuning an Application Engine program.
Session Window and Line Number
The first number will only be present if the trace was run on the client. This indicates the session window. The second is the line number of your execution.
Execution Timestamp
This is a time stamp. This timestamp comes from the machine in which PeopleTools is running, NOT the database.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
486
Time since last write to this file
This indicates the amount of time since the last line in this file was written. This time is the time since the beginning of the last line of code. It includes the time it took to execute the last line of code and the time in between. The time 3 columns over is the time spent to perform the line of code.
Cursor# and DB
This is the cursor number that your line is being executed from. There is a limit of 254 cursors available for every Application Engine Program; this includes Tools cursors accessing PeopleTools table data. It also displays the database the cursor is connected to.
Return Code from the RDBMS
RC = return code. This database return code is like a status of the line of code. RC = 0 indicates your execution went well. RC = 1 indicates the last fetch for the specific SQL statement to the database's fetch buffer did not return a row. RC = any number greater than 1 means something has gone wrong.
Time to Process
Displays the time in seconds to complete the action that generated this trace line.
Action
This tells you exactly what is being accomplished in this line.
COM = Compile a SQL statement. This will typically be followed by a statement (Stmnt) that is being compiled.
EXE = Execute the statement.
CEX = Compile and Execute (used if no bind variables are present).
Fetch = Access to the databases Fetch Buffer. You will only see this if we are retrieving data from the database as in a SELECT.
Additional Trace Data
PeopleSoft was originally developed on SQLBASE. When we ported to other platforms, we continued to use the SQLBASE API call syntax as the common language. Not all of these API calls result in a call to every database. For some platforms, our API may handle some of the non-SQL requests itself.
BNN: bind program variable data to bind variable by number (position).
BLK: bulk insert mode.
BEF: flush bulk insert buffer.
CEX: compile and execute a SQL statement (no bind variables, saves a round trip).
COM: compile a SQL statement.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
487
EXE: execute a previously compiled SQL statement.
Fetch: Would be FET in SQLBASE. Fetch the next row resulting from a SELECT query.
SIL: set isolation level.
SSB: set select buffer, opposite of BNN, associates an item in the select list with a data buffer when the data is fetched.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
488
Interpreting the PeopleTools Trace (continued)
SQL Statement Compilation and Execution And Fetch
This segment of the PeopleTools trace file shows SQL statement compilation and execution and fetch:
Slide 257
Student Notes
PeopleTools Trace
Note. Notice the return code (RC) of 0.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
489
Interpreting the PeopleTools Trace (continued)
TOOLSTRACEPC Parameter
This segment of the PeopleTools trace file shows information generated by the -TOOLSTRACEPC parameter:
Slide 258
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
490
Describing Advanced Trace Options
Advanced Trace Options
Two advanced trace options are:
• DB Optimizer (file).
• DB Optimizer (table).
Slide 259
Student Notes
Example: Configuration Manager Trace
You can use the Configuration Manager Trace page to set databases optimizer trace settings for two- tier.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
491
The trace measurement options we have discussed so far have been accomplished at the application level. Sometimes it will be necessary to utilize a trace at the database level. Depending on your database platform, there could be many options open to you for gathering performance information at the database level. One useful database level trace option is to use an optimization trace.
DB Optimizer Trace
The DB Optimizer trace deals with much finer details of your SQL executions at the database level. For most database platforms, the optimization trace can be initiated at the application level as a parameter value passed to the -TRACE parameter. It can also be turned on from Configuration Manager for any client run processes.
DB Optimizer(file)
This writes the optimization trace to a file on the Application Server in the %TEMP% directory. If there is nota directory assigned it will not write anything. Viewing the data from this trace file requires a utility likely provided by your database manufacturer.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
492
DB Optimizer(table)
If used, the data goes to a table on your database. The name of this table depends on the database type. In some databases such as Oracle and DB2 a PLAN table needs to be created by the DBA, for SQL Server a PeopleSoft table is used, PS_OPTIMIZER_TRC. For some databases the optimizer table may be queried directly, for others you have to use a utility provided by your database manufacturer.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
493
Describing Advanced Trace Options (continued)
Explain Plan
An explain plan may be helpful to tune your SQL code:
• Consult your DBA to generate the explain plan for each SQL statement you wish to tune and then analyze the access path.
• An explain plan allows the application developer or DBA to see how well the database engine is utilizing indexes, statistics, and so on, to execute the Application Engine SQL.
• PeopleSoft provides you with options that can be selected to generate this explain plan from within the PeopleSoft Application.
• Analysis of this explain plan data can be an extensive process and is done with specific database utilities or third party tools.
Slide 260
Student Notes
PLAN, PLAN TABLE and EXPLAIN PLAN
The Optimization trace is ultimately used to create what is known as an EXPLAIN plan with your databases utility. This EXPLAIN plan will ultimately help analyze the efficiency of your SQL code. The intricacies of the EXPLAIN plan are specific to your database platform. Therefore we will not be able to demonstrate them in this class.
EXPLAIN PLAN Overview
When a SQL statement is submitted for execution, the database engine's optimizer-the brain of the engine-takes the statement and goes through the parsing and optimization process. The outcome of this process is a plan, which can be thought of as an object module that contains the optimized SQL statement. This plan includes the access path that the optimizer has chosen to get to the data. The access path depends on many factors such as: how large the tables is, what index or indices exist on the tables, how the SQL statement is formulated, the statistics in the system catalog, etc.
DBAs often run a single SQL statement to see the plan of action-the access paths-in order to determine what needs to be done to tune the SQL for better performance. From the SQL's execution an Explain plan can be created. For example, on an Oracle platform, Explain is a command that is issued on the SQL statement. It is platform specific. The output of the Explain reveals how the database engine will obtain the data-through the use of indexes, a full table scan, or both, or other approaches that are platform specific.
In order for the DBAs to explain the plan of action, the output of the explain plan needs to be stored in a tablecalled PLAN_TABLE which has columns filled with information that are important for analyzing the access path and tuning the query. The explain output in an Oracle environment shown above indicates that the optimizer has chosen to use a full table scan to retrieve the data from the STOCK_TBL.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Measuring Application Engine Performance Lesson 14
494
The explain plan is a valuable tool for analysis of an optimizer's access path and the effect of indexes and SQL statement modifications on performance at the database level.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 14 Measuring Application Engine Performance
495
Review
In this lesson you learned that:
• When improving performance on any system, it is important to take into account all areas of your system and understand the big picture.
• The information gathered in a trace points to where to focus your tuning efforts.
• At the Application Level, three trace parameters are key to gathering trace data:
-TRACE, -TOOLSTRACESQL, -TOOLSTRACEPC
• The following trace settings are the most useful:
-TRACE 384, -TOOLSTRACESQL 31, -TOOLSTRACEPC 2048
• -TRACE is your Application Engine Trace; -TOOLSTRACESQL and -TOOLSTRACEPC are PeopleToolstraces.
• Advanced trace options trace the performance of SQL statements on the database.
Slide 261
Student Notes
Additional Resources
These additional resources provide more details about the topics discussed in this lesson:
Topic See
Trace Values Enterprise PeopleTools 8.50 PeopleBooks: PeopleSoft Application Engine, "Tracing Application Engine Programs"
Two-Tier Trace Settings Enterprise PeopleSoft 8.50 System and Server Adiministration PeopleBook, "Using PeopleSoft Configuration Manager"
Process Scheduler Trace Enterprise PeopleTools 8.50 PeopleBooks: PeopleSoft Process Scheduler,"Defining PeopleSoft Process Scheduler Support Information "
Command Line Trace Enterprise PeopleTools 8.50 PeopleBooks: PeopleSoft Application Engine,"Tracing Application Engine Programs"
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
497
Lesson 15
Tuning Application Engine Programs
Objectives
By the end of this lesson, you will be able to:
• Describe the process of performance tuning.
• Identify application level tuning opportunities.
• Explain the performance impact of PeopleCode.
• Describe how Do flow control affects program performance.
• Explain database-level tuning considerations.
Slide 263
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
498
Describing the Process of Performance Tuning
Performance Tuning Flow
This flow chart illustrates that tuning is a process rather than a list of settings for a given condition:
Slide 264
Student Notes
Tuning
In order to accurately tune your Application Engine program the ideal situation is to test and tune it under similar conditions to when it is run in production. Having a copy of the production data on your test system is the optimal situation for tuning applications. Unfortunately, this is not realistic and there will likely be some differences between your production run environment and your testing environment.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
499
Describing the Process of Performance Tuning (continued)
Performance Layers
This diagram illustrates the layers that affect application performance:
Slide 265
Student Notes
Performance Tuning
Performance tuning is a vast topic where improvements can be made in many areas of your system. The chart above shows the layers of your system that ultimately affect performance.
Performance tuning of any kind in any system can be broken down into:
• Performance measurement.
• Recording trace data.
• Analyzing and evaluating trace data.
• Performance tuning and testing.
Where to measure?
Generally speaking, the easiest place to performance tune your program is by taking the measurements as it isrun on the client. However, if you test and tune on the client the results may differ when you run the program from the server. For example: a program that is run in production on the server but tested and tuned on the client, may give you fetch times that are vastly different in test as compared to production. However, this effect may not be a significant enough difference to warrant always testing it in its production run location.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
500
How to measure?
Performance tuning will likely be done on a test database with a drastically scaled down amount of data compared to your production database. This is necessary, but be aware that this data reduction can give misleadingly fast results when tested, and your program may still be slow in production. It is impossible to predict how much data is necessary in your test environment, but you will probably need to think in terms of thousands of rows as opposed to hundreds.
Important! It is important that the test environment resemble production as closely as possible. This means having hardware that is close to that which the production system will be using, and as a rule, the equivalent of 15 to 20% of your production data. Testing can and should be accomplished with less than this, if more resources are unavailable. But the closer you can get to a system equivalent of your production environment, the easier it will be for you to come up with good solutions.
Where to focus tuning first?
Once you have decided to performance tune an Application Engine program, you will need to decide where tofocus your tuning efforts.
Important! A tuning solution may require changes to one or several or all of these performance layers
You should always begin in an area where you will gain the maximum benefit for the least amount of effort and the least impact to other areas of your system. For the least impact to other areas of your system, application-level tuning is a great place to start.
Here are some other specific areas that affect performance:
Hardware: Memory, Processor speed, disk speed, disk I/O controllers, etc.
Network: Network throughput, switching, traffic balancing, address resolution, etc.
Operating System: OS Parameters, buffers, program contention
Database: Which is the SQL that is executed by the RDBMS and the settings used to configure the RDBMS File locations, Segment (table, etc.) size, indexing method, optimizer, temporary buffers, logging, checkpointing (at the database level, not in Application Engine), etc.
Application Comprises the PeopleSoft programs which make up a PeopleSoft Application, Program Design, Use of PeopleCode, Commits, Re-use, etc
Code (SQL) Join methods and order, statistics, use of indexes, table access type, database hints.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
501
Describing the Process of Performance Tuning (continued)
Tuning Perspective
This diagram represents the balance that exists between online performance and program performance when you make changes on the database (indexes, and so on).
Slide 266
Student Notes
Tuning Balance
Depending on where you focus the tuning efforts for your Application Engine program, you may have a negative effect on the performance of your online access to the same SQL tables.
Tuning is a balancing act that should take into consideration many applications and many processes in your system. The changes you incorporate may improve one area of your system's performance while hindering another area. Only a good understanding of your system and a little detective work will create an optimal balance among all processes and applications.
Important! Tuning at the Application Engine level will typically avoid this balancing act.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
502
Identifying Application Level Tuning Opportunities
Application Engine Program Level Tuning
At the Application Engine program level, there are many aspects that can be manipulated to affect performance.
Five aspects we will discuss in this section are:
• How traces can affect performance. Too many trace settings will skew the results.
• How the ReUse option can reduce processing time.
• How Commits and Checkpoints can affect performance.
• Coding Bulk Insert SQL.
• SQL vs. PeopleCode.
Slide 267
Student Notes
Application Engine Program Level Tuning
Most of what we discuss in this lesson, Application level tuning, will have the least amount of impact on other areas of your system. The gains and losses discussed here will be limited to the specific Application Engine program you work on and will not affect the rest of your system.
At the Application Engine program level, there are many aspects that can be manipulated to affect performance.
Here are a few we have discussed in this course and others we will focus on later:
• Set-based processing vs. Row-based processing. (earlier).
• Temporary table usage and implementation (earlier).
• Program structure and looping techniques (covered later in this lesson).
• SQL in a PeopleCode action (covered later in this lesson).
• Effect of indexes (covered later in this lesson).
• Other Database tuning factors to consider (covered later in this lesson).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
503
Identifying Application Level Tuning Opportunities (continued)
Tracing
Tracing can affect performance.
Gather the minimum trace information you need.
For batch timings, trace 384 (SQL and PeopleCode timings) is recommended.
It is highly recommended you do not have trace turned on in the production environment.
Slide 268
Student Notes
Tracing
Your statement timings trace is used to determine which area of the Application Engine program to focus on first. Chances are you will gain the most benefit out of your tuning efforts by focusing on those actions wherethe program spends most of its time. Even the slightest improvements in these areas could mean tremendous improvements in its overall runtime.
The first thing to realize with your program's performance is how the simple act of using a trace option to record a lot of unnecessary trace data will cause a performance lag. When taking your performance measurements, gather the minimum information you need in your trace. Having trace turned on in your production environment is generally not recommended.
In the activity later, since we are only going to analyze the overall times our program produces and not get into the details of how it is doing it, we should only use the parameter -TRACE with a value of 384.
As a rule of thumb: Only activate the traces necessary! Also remember trace can be activated elsewhere besides the command line. In particular, be careful of traces set on the Application Server and on the client through Configuration Manager.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
504
Identifying Application Level Tuning Opportunities (continued)
ReUse
ReUse Option:
• Is generally most effective when looping.
• Replaces %Bind variables with real bind variables.
• Causes the program to reuse an execution plan.
Slide 269
Student Notes
Example: ReUse Option
The ReUse option is set on an action that contains SQL.
ReUse can dramatically affect what SQL is sent to the database.
An Application Engine program may look like this:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
505
MAIN STEPM01 Do Select %Select(DESCR)
Select DESCR
From PS_SOME_TBL
Where DEPT_ID = %Bind(DEPT_ID)
The program operates on data in PS_SOME_TBL that might look like this:
DESCR DEPT_ID
ABC 123
XYZ 456
EFG 789
HIJ 012
Depending on the ReUse option, the SQL generated by Application Engine would look like:
ReUse = No ReUse = Yes
SELECT SOME_FLD
FROM PS_SOME_TBL
WHERE DEPT_ID = '123'
SELECT SOME_FLD
FROM PS_SOME_TBL
WHERE DEPT_ID = :1
SELECT SOME_FLD
FROM PS_SOME_TBL
WHERE DEPT_ID = '456'
SELECT SOME_FLD
FROM PS_SOME_TBL
WHERE DEPT_ID = '789'
SELECT SOME_FLD
FROM PS_SOME_TBL
WHERE DEPT_ID = '012'
ReUse Option
The ReUse option can be a very quick and easy way to potentially shave a significant amount of time off the execution of your program.
The ReUse option is generally most effective when a looping construct is being used. It causes any %Bind functions in your action to be replaced at the database level with a real bind variable and instructs the Application Engine program to only request the database to parse, compile and generate one execution plan the first time it is executed. ReUse saves a small fraction of time but if done over and over in a loop it can be a significant timesaving.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
506
Explaining the tables
When SQL is sent to the database it is scanned to see if it is exactly the same as any recently executed SQL. Ifeven one thing is different, it is parsed, or taken apart, and an execution plan is created for it. These executionplans are stored up in memory on the database. When new SQL is sent to the database and scanned it is compared to the SQL that already has an execution plan. If nothing has changed and there is already an execution plan it will save time by reusing the same execution plan. If it has even one syntactical difference (like a different value in a loop), it will not be recognized and a new execution plan will be created.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
507
Identifying Application Level Tuning Opportunities (continued)
When Not to Use ReUse
Do not use ReUse:
• When limited by database platform functionality.
• When SQL changes dynamically in the program.
Slide 270
Student Notes
When Not to Use ReUse
ReUse can't be used everywhere for all database platforms. Your DBA should be able to tell you what your platform's bind variable limitations are. For example, on DB2 you cannot have bind parameters on both sides of a binary operator: COLUMN1 = :1 + :2.
When the Application Engine program is dynamically changing the structure of the SQL statement that is executed during the loop, ReUse is not useful, because every instance of the SQL being executed will be unique and will require re-compilation.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
508
Identifying Application Level Tuning Opportunities (continued)
Unnecessary Commits
Unnecessary commits can make a significant difference in your program's run time.
Commits (and corresponding checkpoints) are set:
• At the section level: Auto Commit After Step checkbox.
• At the step level: Commit After dropdown and Frequency field.
Every commit with restart enabled causes an update to PS_AERUNCONTROL.
Slide 271
Student Notes
Unnecessary Commits
Because of Application Engine's ability to be restarted, commits inside your program are very valuable. However, too many unnecessary commits can make a significant difference in your program's runtime.
Every time you issue a program level commit in your Application Engine program and restart is enabled, you are also updating a row of data on PS_AERUNCONTROL. If your commits are excessive, the extra update can add considerable overhead and lengthen your runtime. This does not mean you shouldn't issue commits for the sake of optimal performance. Commits should be strategically placed within your program's execution to maximize the benefits of the restartable checkpoints while not causing unacceptably long runtimes.
Important! PS_AERUNCONTROL is not updated if the commit is issued in a SQL or PeopleCode action.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
509
Identifying Application Level Tuning Opportunities (continued)
Commit and Checkpoint Timings
This segment of a trace file shows that the 1004 checkpoints and commits have significantly affected performance.
Slide 272
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
510
Identifying Application Level Tuning Opportunities (continued)
Commit and Checkpoint Timings (continued)
Slide 273
Student Notes
Checkpoints
Be aware that writing checkpoints for parts of your program that contain a PeopleCode Actions incurs a greater time cost than writing checkpoints when there is no PeopleCode Action. This is because PeopleCode checkpoints are written to an additional checkpoint table called PS_AERUNCONTROLPC. This table stores all component and global scope PeopleCode variables that might be necessary for restart.
Look at some sample timings trace for the test application.
Notice the tasks of CHKPOINT and COMMIT. These are performed over 1000 times in the program - doublethe amount of rows that are inserted to the table. All this activity amounts to about 57% of the program's run time (Total checkpoint plus commit time 253.5 divided by total run time 450.6 = 57%).
Note. Excessive log messages issued within your program can also lengthen your execution time. Excessive commits inside a loop using the Bulk Insert option will make Bulk Insert less effective.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
511
Identifying Application Level Tuning Opportunities (continued)
Bulk Insert
Bulk Insert takes advantage of your databases ability to place data in a memory buffer before the table insert.
To use this option your SQL must follow a specific structure to work properly.
• Incorrect syntax for Bulk Insert:
INSERT INTO PS_SOME_TBLVALUES (%BIND(FIELDX), %BIND(FIELDY), %BIND(FIELDZ))
• Correct syntax for Bulk Insert:
INSERT INTO PS_SOME_TBL (FIELD1, FIELD2, FIELD3)VALUES (%BIND(FIELDX), %BIND(FIELDY), %BIND(FIELDZ))
Slide 274
Student Notes
Bulk Insert
The Bulk Insert option is only applicable if the SQL in your SQL action contains a SQL Insert. The Bulk Insert option takes advantage of your database's ability to bulk, or buffer up, a number of rows in memory before it does the actual SQL Insert. The effectiveness of using this option depends on your database platformand its configuration. When Bulk Insert is used, ReUse option is also assumed.
The Application Engine program will not use bulk Insert when you are using an Insert/Select. Bulk Insert is only used when a Values clause follows your Insert and when a field list comes before your Values clause.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
512
Explaining the Performance Impact of PeopleCode
PeopleCode Actions
PeopleCode actions in Application Engine are meant to be limited to the following:
• Testing for conditions (If-Then-Else).
• Performing computations.
• Building dynamic portions of SQL.
• Sharing complex business rules between online and batch processing.
• Accessing PeopleTools integration technologies.
Slide 275
Student Notes
PeopleCode Actions
One of the biggest hits to your program's performance is through the misuse of PeopleCode within your Application Engine program. Just because you can execute PeopleCode in your Application Engine program to perform a task does not mean it is the best thing to do.
Accessing PeopleTools integration technologies:
• File Objects
• Component Interfaces
• Application Messaging
PeopleCode SQL Performance
Executing SQL from within a PeopleCode action incurs an additional time burden. Before the SQL can be executed it must be interpreted and converted by the Application Engine program from PeopleCode into executable SQL. This interpretation and conversion is where the time lag is. Avoiding this process will certainly give you performance improvements.
Simply put, Application Engine is excellent at executing SQL against your database; PeopleCode is far slower at executing the same SQL. When you try to execute SQL through PeopleCode, you are taking away the main thing Application Engine is excellent at, which is executing SQL.
You should also avoid trying to accomplish set-processing or looping techniques in a PeopleCode action. For these techniques, use Application Engine's Do Loop capability and its ability to use temporary tables to store the sets of data to be processed. You will find the use of arrays is particularly slow in an Application Engine PeopleCode action. This would be a perfect opportunity to use a dedicated temporary table.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
513
PeopleCode vs. SQL
Consider the two different methods below of updating a counter in an Application Engine Program:
SQCnt+1 Step: PCCnt+1 Step:
%Select(COUNTER) SELECT %Bind(COUNTER) + 1 FROM PS_INSTALLATION
PERF_TUN_AET.COUNTER = PERF_TUN_AET.COUNTER + 1;
PeopleCode is generally faster at performing mathematical calculations than accomplishing the calculation via SQL.
In practice, the PeopleCode will perform much faster than SQL coded to perform the same calculations.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
514
Activity 35: Tuning PERF_TUN In this activity you will review the activity overview and tune the performance of PERF_TUN.
See Application Engine: Activity Guide, "Tuning Application Engine Programs," Activity 35: Tuning PERF_TUN.
Slide 276
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
515
Activity OverviewIn this activity, you will go through the process of tuning a poorly designed Application Engine program. In the previous lesson "Measuring Application Engine Performance," you took measurements for the PERF_TUN program. It is a simple program that takes too long to perform a simple task and it needs improvement.
Here is the pseudo code for the program:
DELETE all rows from PS_TUNING1_TBL.Populate DESCR Field on State RecordDo While Insert LoopSQL Add 1 to State record COUNTERInsert row into PS_TUNING1_TBLWrite Finished Message
This Application Engine program simply does 500 iteration of a Do While loop. For each iteration of the loop, the program inserts a new number into a table along with the same DESCR value. Before each insert, the number is incremented to ensure each row is unique.
Here is the program layout
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
516
Section Step Action Type Code
Main Delete SQL %TruncateTable(PS_TUNING1_TBL)
* GetTEXT SQL %Select(DESCR) SELECT 'I will not chew gum in class.' FROM PS_INSTALLATION
* SQLLoop Do While %Select(TEMP_FLD) SELECT 'X' FROM PS_INSTALLATION WHERE %Bind(COUNTER) < 500
* * Call Section SQLLoop
* PCodLoop Do While %Select(TEMP_FLD) SELECT 'X' FROM PS_INSTALLATION WHERE %Bind(COUNTER) < 500
* * Call Section PCodLoop
* FinisMsg Log Message
PCodLoop PCCnt+1 PeopleCode PERF_TUN_AET.COUNTER=PERF_TUN_AET.COUNTER + 1;
* Insert PeopleCode Local Record &PFTUNING1_TBL, &PFPERF_TUN_AET;Local SQL &PFSELECT, &PFINSERT;&PFTUNING1_TBL = CreateRecord(Record.TUNING1_TBL);&PFPERF_TUN_AET = CreateRecord(Record.PERF_TUN_AET); &PFSELECT = CreateSQL(%SelectAll(:1) where PROCESS_INSTANCE = (SELECT MAX(PROCESS_INSTANCE) FROM PS_PERF_TUN_AET), &PFPERF_TUN_AET);&PFINSERT = CreateSQL(%Insert(:1));&PFINSERT.TraceName = SELECT PS_PERF_TUN_AET or Your Label Here;If &PFSELECT.Fetch(&PFPERF_TUN_AET) = True Then&PFTUNING1_TBL.SOME_ID.Value = &PFPERF_TUN_AET.COUNTER.Value;&PFTUNING1_TBL.DESCR.Value = &PFPERF_TUN_AET.DESCR.Value;&PFINSERT.Execute(&PFTUNING1_TBL); End-If;
SQLLoop SQL+1 SQL %Select(COUNTER) SELECT %Bind(COUNTER)+1 FROM PS_INSTALLATION
* PCCnt+1 PeopleCode PERF_TUN_AET.COUNTER=PERF_TUN_AET.COUNTER + 1;
* Insert SQL INSERT INTO PS_TUNING1_TBL (SOME_ID , DESCR) VALUES (%Bind(COUNTER) , %Bind(DESCR))
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
517
Note. The Main section, SQLLoop step is initially inactive and will not run. (These steps are in italics in the program layout.) Until it is activated, the SQLLoop step cannot call the SQLLoop section.
Two different loops have been created that accomplish the same thing. In the Main section there are two steps, each with a Call Section action to call one of the two loops. Each step can be activated or inactivated. One loop accomplishes the SQL inserts with a PeopleCode action and the other uses a SQL action. Only one loop will be used on each run. We will use the different loops to test various run options that affect performance.
The program settings are set so that Commits are performed after every step.
During the activity, after each modification you will re-execute the program to observe the changes in timing that occur.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
518
Activity Detailed StepsPerform the detailed steps to complete the activity.
Tuning PERF_TUN
To tune PERF_TUN:
1. Record initial timings.
2. Modify PERF_TUN to:
a. Use only the necessary traces.
b. Use ReUse.
c. Change PeopleCode actions to SQL actions.
d. Reduce commits.
e. Add Bulk Insert.
Recording Initial Timings
You already ran PERF_TUN and created a trace file. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Modifying PERF_TUN to use Only the Necessary Traces
Only utilize the trace options that let us see the overall timings of our test program.
To modify PERF_TUN to use only the necessary traces:
1. Navigate to the Configuration Manager
2. Access the Trace tab.
3. Click the Clear Trace Settings button
4. Select the check boxes for Statement Timings (file) and PeopleCode Detail timings. (This is equivalent to -trace 384).
5. Click Apply and click OK.
6. Return to Application Designer and open the Application Engine program PERF_TUN.
7. Run PERF_TUN by clicking on the traffic light or select Edit, Run program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
519
8. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Modifying PERF_TUN to use ReUse
To modify PERF_TUN to use ReUse:
1. In Application Designer open the Application Engine Program PERF_TUN.
the Main Section, in the step PCodLoop, on the Do While Action, change ReUse Statement to Yes.
2. Save.
3. Run the program using PERF_TUN in the Application Designer again.
4. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Modifying PERF_TUN to Change PeopleCode Actions to SQL
Currently our PERF_TUN selects from the State Record and inserts into PS_TUNING1_TBL via PeopleCode. Let's look at the time difference in completing the same selects and inserts via a SQL Action.
To modify PERF_TUN to change PeopleCode actions to SQL:
1. In the Main section, in step SQLLoop, select the Active checkbox.
This is the step that calls the SQLLOOP section.
2. In Main section, in the step PCODLOOP, clear the Active checkbox.
This is the step that calls the PCODLOOP section.
3. Save.
4. Run the program.
5. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Now that we have incorporated a new Section and Steps into our program, use the ReUse option to gain additional improvement.
6. Select ReUse, in all appropriate places in PERF_TUN test. (Hint: there are 3 places it should be selected).
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
520
7. Save.
8. Run the program.
9. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Modifying PERF_TUN to Change SQL Actions to PeopleCode
Currently our PERF_TUN uses SQL code to increment the counter by one on each iteration of the loop.
Examine the time difference when completing the calculation using PeopleCode.
To modify PERF_TUN to change SQL actions to PeopleCode:
1. In the SQLLOOP section, in step SQCnt+1, clear the Active checkbox.
2. In the SQLLOOP section, in step PCCnt+1, select the Active checkbox.
3. Save.
4. Run the program.
5. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Modifying PERF_TUN to Reduce Commits
Modifying PERF_TUN to reduce commits:
1. In the SQLLoop section, clear the After Step checkbox under Auto Commit.
(You may need to select View, Show All Details to display the checkbox.)
This will eliminate performing a Commit after every iteration of the loop.
Note. Once you do this however, you will not be committing anywhere inside the loop. We will use the commit Frequency option at the Step level to change this.
2. In the MAIN section, in the SQLLoop step, in the Frequency field, enter 100.
This will perform a Commit after every 100 iterations of the loop.
3. Save.
4. Run the program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
521
5. Open the trace file and answer the following questions:
Question Answer
How many commits are there?
How many checkpoints are there?
What is the total run time?
Modifying PERF_TUN to Use Bulk Insert
To modify PERF_TUN to use bulk insert:
1. In the SQLLOOP section, INSERT step, SQL Action, in the field ReUse Statement, select Bulk Insert.
2. Save.
3. Run the program.
4. Compare your trace file with the results below.
If the Bulk Insert option was used successfully, in your trace file you will see (Bulk Insert) indicated at the end of the SQL Statement line timings. Also notice the Compile column count is 1, indicating that the Insert statement was reused.
5. Open the trace file and answer the following question:
Question Answer
What is the total run time?
Results
This trace file shows timings with Bulk Insert activated.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
522
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
523
Describing How Do Flow Control Affects Program Performance
Do Select/Select Fetch
This flow chart illustrates a Do Select action with a Select/Fetch action type:
Slide 277
Student Notes
Do Select/Select Fetch
The type of Do Loop you use to process your rows of data will also have a significant impact on performance.
To investigate which Do Loops are the most efficient you will have to do some testing.
Limitations of Do Select with Type: Select/ Fetch
A Do Select with a type of Select/Fetch is more desirable than the ReSelect type for performance reasons. However it has some functionality limitations.
Do not use a Do Select loop with a Select/Fetch type if you are planning on dynamically changing the SQL orSQL values within the Do Select loop while the loop is in progress. This is because the SQL in your Do Select statement is going to be compiled only once as it appears on the first go around with all the rows it retrieves placed into the database's fetch buffer. Each subsequent loop will only be retrieving the next row in the fetch buffer and not executing the SQL again to get more rows. Therefore if your Do Select SQL or the criteria in your SQL changes in the middle of your loop it will not be recognized or executed.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
524
For example, in the following program we are trying to get all the SOME_ID values from PS_SOME_TBL toPS_OTHER_TBL. We accomplish this by writing the rows one at a time to the state record, and then we insert them into our PS_OTHER_TBL within a Do Select loop of type Select/Fetch. The pseudo code for the loop processing would look like this:
Select rows from PS_SOME_TBL and populate the bufferWhile there is a row in the bufferUpdate fields in the PS_SOME_AET state recordWrite a row to PS_OTHER_TBL using bind values from PS_SOME_AET
Once the data is selected, that list of rows cannot be updated by changing the SQL that originally produced it.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
525
Describing How Do Flow Control Affects Program Performance (continued)
Sample Program
The sample program below is going to have a problem because the code in STEPS2 will be irrelevant:
Section Step Action Type Code
Main STEPM1 Do SelectType: Select/Fetch
%Select(SOME_ID) SELECT SOME_ID FROM PS_SOME_TBL WHERE SOME_ID = %Bind(SOME_VALUE)
* * Call Section Section1
Section1 STEPS1 SQL INSERT INTO PS_OTHER_TBL (SOME_ID) VALUES(%BIND(SOME_ID))
* STEPS2 SQL %SELECT(SOME_VALUE) SELECT 'XYZ' FROM PS_INSTALLATION
Slide 278
Student Notes
Sample Program
The problem is in STEPM1 when we select all the rows from PS_SOME_TBL based on the 'ABC' value on the state record (WHERE SOME_ID = %Bind(SOME_VALUE)). These rows are the active set in the fetch buffer. Then after the first Insert in STEPS1 we change the 'ABC' value on the State Record to 'XYZ' in STEPS2. The fetch buffer's active set still has all rows having SOME_VALUE = 'ABC'.
The program will continue to process the 'ABC' rows only and will never do the 'XYZ' rows. Once the active set is complete it will not rerun the Do Select SQL again even though our WHERE condition value has changed to 'XYZ'.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
526
Activity 36: Examining Loop Performance with DO_LOOP_TST
In this activity you will review the activity overview and run the DO_LOOP_TST program to test loops underdifferent conditions.
See Application Engine: Activity Guide, "Tuning Application Engine Programs," Activity 36: Examining Loop Performance with DO_LOOP_TST.
Slide 279
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
527
Activity OverviewThe type of Do loop you use to process your rows of data will also have a significant impact on performance.
You will do some testing to measure which Do loops are the most efficient .
Using an Application Engine program called DO_LOOP_TST, you will change the Do loop type and execute your program two different times and compare the results of each run to see exactly how much performance difference there is.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Program Overview
Section Step Action Type Code
Main Delete SQL %TruncateTable(PS_TUNING2_TBL)
* DoLoop Do _________Type _______
%Select(SOME_ID, DESCR) SELECT SOME_ID , DESCR FROM PS_TUNING1_TBL WHERE SOME_ID > %Bind(SOME_ID) ORDER BY SOME_ID
* * SQL INSERT INTO PS_TUNING2_TBL VALUES (%Bind(SOME_ID) , %Bind(DESCR))
* Message Log Message 30000, 1
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
528
Activity Detailed StepsPerform the detailed steps to complete the activity.
Examining Loop Performance with DO_LOOP_TST
In this activity you will:
1. Edit a batch file that will run DO_LOOP_TST.
2. Test a Do Select loop with a type of ReSelect.
3. Test a Do Select loop with a type of Select/Fetch.
Editing a batch file that will run DO_LOOP_TST.
To edit a batch file that will run DO_LOOP_TST:
1. Edit the file C:\labs\0411_AppEngine\Bat.
The contents of the file are:
<PSHOME>\bin\client\winx86\PSAE.EXE -CT ORACLE -CD <Database> -CO PTTRA -CP PTTRA -R DO_LOOP_TST -AI DO_LOOP_TST -TRACE 384 -TOOLSTRACESQL 31
2. Replace <PSHOME> with the correct address.
3. Replace <Database>with the name of your database.
4. Save.
5. Delete the file C:\Temp\Trace.txt.
Testing a Do Select Loop with a Type of Reselect
To test a Do Select loop with a type of ReSelect:
1. In Application Designer, open the project DO_LOOP_TST.
2. Open the Application Engine program DO_LOOP_TST and verify that the Do loop step is a Do Select action with a type of Reselect.
3. DO_LOOP_TST.bat.
4. In Windows Explorer, navigate to C:\Temp and change the name of Trace.txt to TraceA.txt.
5. In Windows Explorer, navigate to C:\Temp and change the name of your Application Engine trace file to TraceA1.AET.
6. Open the TRACEA.txt trace file and compare it to the results below:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
529
Results
This is segment of a trace file using a Do Select action with a type of ReSelect.
Testing a Do Select Loop with a Type of Select/Fetch
To test a Do Select loop with a type of Select/Fetch:
1. In Application Designer, change the DoLoop step to be a Do Select action type of Select/Fetch.
2. Save.
3. DO_LOOP_TST.bat.
4. In Windows Explorer, navigate to C:\Temp and change the name of Trace.txt to TraceB.txt
5. In Windows Explorer, navigate to C:\Temp and change the name of your Application Engine trace file to TraceB1.txt
6. Open and your Application Engine trace file and compare it to the Reselect trace file.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
530
7. Answer the following questions.
Question Answer
Which is fastest.
Why?
8. Open your PeopleTools SQL Trace and compare to the Reselect trace file and to the results below.
9. Answer the following question.
Question Answer
What is different about the execution of the Do Select loop with the Select and Fetch Type option?
Results
This is a segment of a trace file using a Do Select action with a type of Select/Fetch:
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
531
Explaining Database-Level Tuning Considerations
Database-Level Tuning
At the database level, there are many aspects of the environment that can be manipulated to improve performance.
• Tablespace allocation.
• Indexes and how they affect data access.
Slide 280
Student Notes
Database-Level Tuning
If your tuning ultimately goes beyond application level tuning, it is important to keep in mind how things you do for improvement affect other aspects of your system's performance. For example, if you start changing a table's indexes or the structure of that table simply to gain the maximum speed benefit for your program, you may end up making the online PeopleSoft pages that access this table slower.
Beyond application level tuning the next step in tuning would likely be database level tuning.
This is generally the domain of a DBA, but is useful background information for developers when they are wrestling with performance problems. They may investigate database performance and make adjustments themselves, but should be aware that these are areas that need to be examined once the application and SQL-level tuning issues are addressed.
These topics are vast and are courses unto themselves. Our intention here is to simply define them and give anexample of how they might affect your Application Engine program's performance.
Tablespaces
Tablespace can be defined as the logical location of a table in a database. Manipulation of your tablespace's structure and its location can impact performance. The logical location of tables also corresponds to their physical location on your hardware. Whether it is online or batch execution, tables that are accessed simultaneously, while they reside in the same physical tablespace location, will have a drain on the performance of all systems that access them. Separating these tables into their own tablespace locations will likely give you faster input and output of your data for all those systems.
Using temporary table pools for parallel processing is a good example of when manipulating tablespaces might be beneficial to an Application Engine program. For example, let's say you have a program processing 500,000 rows of data by dumping the rows into a dedicated temporary table with 5 instances created in the "batch/ dedicated" temporary table pool. You may try to improve performance by implementing parallel processing to execute the job 5 times, with each execution placing 100,000 rows into a separate temporary table instance. You can gain further performance improvements by simply separating each of the temporary table instances into their own physical tablespace.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
532
Manipulating your tablespaces is an advanced database tuning technique that will involve consultation and help from your database administrator.
Impact of Indexes
Indexes help define specific access paths to your data based on your SQL statement, criteria, and the distribution of the data. Indexes are often referred to as table "statistics." Indexes exist primarily to enhance performance. However, indexes do come with a cost; therefore, indexing everything is not the solution. Proper and selective indexing is the solution for performance improvement. Missing indexes or too many indexes may hurt performance. For example the time required to Insert rows will increase dramatically as more indexes are added to a table.
Selectivity, or how unique the values of the columns making up the index are, is a common measure of the usefulness of the index. The more unique the index column values are, the more efficient the index will be. Inaddition, different database engines may have different methods of storing the index information (for example, hash table, bitmap, clustered), which may be applied when the index is created, which will make its use more efficient.
Only testing and certain database-level traces will be able to tell you if you are using your indexes most efficiently.
For indexes to be most effective they must be updated constantly as the data on a table is added to and changed over time. Updating your indexes on your production tables is a delicate matter that can be time consuming and costly. It is mostly done by your database administrator or with their complete knowledge of its occurrence.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
533
Explaining Database-Level Tuning Considerations (continued)
Indexes
Strategies to use for Application Engine when working with indexes:
• Use %UpdateStats to update indexes on temporary tables during a program's run.
• Enable and disable %UpdateStats using the -DBFLAGS command line parameter.
• Disable %UpdateStats -DBFLAGS 1
• Enable %UpdateStats -DBFLAGS 0 or do not include the parameter.
• Temporarily drop and then rebuild indexes when inserting rows.
• Index large temporary tables after creation.
Slide 281
Student Notes
Indexes
Because an Application Engine program might be moving and manipulating very large amounts of data, thereare several strategies you can apply to allow Application Engine to make better use of indexes.
Enabling UpdateStats
You may gain performance improvement by using a meta SQL function %UpdateStats(<tablename>) that will update your indexes during the course of your program's run.
An example of a good use of this meta-SQL would be after loading extremely large amounts of data into temporary tables where those rows will ultimately be selected from using specific criteria. After loading the rows into the temporary tables, and before you begin your selecting, you might consider using %UpdateStats in order to gain performance improvement.
Disabling UpdateStats
If for testing or system performance purposes you want to disable any %UpdateStats meta-SQL in your program, psae.exe has the -DBFLAGS parameter available to do this.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
534
Temporarily drop and then rebuild indexes when inserting rows
When inserting new rows into a table, each index associated with a table will trigger an additional write to the database. This can exponentially increase the amount of time required to complete a process. When processing large numbers of new rows, it is frequently more efficient to drop all but the index required to insure each new row in the table is unique. These indexes can be rebuilt after the insertions are complete. The rebuild of indexes at the end of processing will be more efficient, much as using bulk insert is more efficient at inserting data into a table. This may not be a useful strategy when there are a limited number of new rows, or when regardless of how many rows are inserted, updating indexes would take less time than recreating them.
Important! Very This is not recommended for production tables! The only case where this would be possibleis when all other users and processes are locked out of the application.
Index large temporary tables after creation
Any table created within PeopleSoft will have at least one unique index created if any key fields are specified.Temporary tables are no exception. In some cases however, adding an additional index may aid in retrieving information from the table. The additional or modified index can prevent full table scans - row by row reading of the table - when retrieving each row. In addition, if the fields being retrieved from the temporary table are in the index, the database may supply them to the Application Engine Program from the index directly, making a read of the actual table unnecessary.
To Illustrate, the record below would be built with an index that includes Processinstance, and Somekey:
Processinstance KeySomekey KeyDatafield1Datafield2
After populating the table, by building an index for the table that includes all 4 fields, the RDBMS can retrieve the values from the index rather than the table, eliminating one database read from the processing.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
535
Activity 37: Tuning EMPL_INCIn this activity you will review the activity overview and performance tune EMPL_INC using simple programlevel tuning options. Then you will execute and trace TND_EMPL_INC, which uses set-processing to gain a significant performance improvement.
See Application Engine: Activity Guide, "Tuning Application Engine Programs," Activity 37: Tuning EMPL_INC.
Slide 282
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
536
Activity OverviewABC Company has an Application Engine program called EMPL_INC running in their customized system. The way the program is currently written it does a lot of unnecessary processing, making it take longer than itshould to run. It needs to be overhauled to improve its performance.
The program's purpose is to give employees a raise based on the number of dependents and the country the employee resides in.
In Application Designer, all of the associated definitions for the program are in the project PSU_EMPL_INC.
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Program Overview
In ABC Company's system, all employees and their salaries are stored in a table called PS_PSU_PERS_DATA, an effective dated parent table of PS_PSU_DEP_DATA. Notice the shared key structure below.
The EMPL_INC Application Engine program first calculates the raise to be given to an employee, and then it inserts a new effective dated row into the parent table with the new salary and an effective date of 2002-02-02. In order to keep the parent-child relationship intact, the program selects the employee's dependents from the child table and inserts the new rows into the child table with the new effective date. This will maintain theparent-child relationship and ensure referential integrity between the two tables.
State Records
There are two state records:
• EMPL_INC_AET is to hold the employee ID's selected that meet our condition.
• EMPL_INC2_AET is used to hold the increase percentage determined for each EMPLID during the program's run.
We are using two state records to demonstrate the use of two state records.O
racl
e U
nive
rsity
and
BU
SIN
ESS
SUPP
OR
T SA
S us
e on
ly
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
537
Activity Detailed StepsPerform the detailed steps to complete the activity.
Tuning EMPL_INC
You will do this activity in two parts:
• Performance tune EMPL_INC.
• Execute and trace TND_EMPL_INC.
Performance Tuning EMPL_INC
The first step in performance tuning is to generate a trace file and analyze it.
If you run the untuned version of EMPL_INC in the classroom, it will take too long to process. Instead, open the trace file C:\labs\0411_AppEngine\Files\EMPL_INC.AET. The trace shows it takes over 12 minutes to run from Application Designer.
Analyze the trace file and try to determine:
• Which areas are taking the most time.
• What application level tuning opportunities exist to improve these times.
Tuning Hints and Possibilities:
Consider using all application-level tuning options we have discussed, including:
• The ReUse option.
• Commits and checkpoints.
• Bulk insert SQL.
• Substituting SQL for PeopleCode.
Not all of these options may be applicable in this program.
Running EMPL_INC:
To run EMPL_INC you should run the program through Application Designer and have the Configuration Manager Application Engine trace set to statement timings (file) and PeopleCode timings turned on (-Trace parameter set to 384 to record timing data).
Verify Results and Reset Data
To help you verify your results and reset your data after each run, open C:\labs\0411_AppEngine\SQL\Activity37.sql. Run the SQL in Section 1 in SQL Developer to reset the data.
Use the SQL in Section 2 to verify your program run was successful.
The SQL in Section 3 might be useful in your program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
538
Note. Execute the SQL statements in Activity37.sql one by one. When a SQL statement (DML) is being executed using SQL developer, it is a recommended practice to manually perform a commit by clicking the commit toolbar button or pressing the F11 key. This needs to be followed even in cases where an Application Engine program is executed after executing DML statements in SQL developer.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 15 Tuning Application Engine Programs
539
Executing and Tracing TND_EMPL_INCTND_EMPL_INC is a re-written version of EMPL_INC that makes better use of set-processing and temporary tables. The program and its associated definitions are in a project called TND_EMPL_INC. You will run the program using a batch file with some traces turned on, then analyze the trace files to compare the times of EMPL_INC to TND_EMPL_INC.
To execute and trace TND_EMPL_INC:
1. Reset the data to allow for another program execution.
a. Open the SQL file C:\labs\0411_AppEngine\SQL\Activity37.sql.
b. Copy the two SQL statements in Section 1. Paste them into SQL Developer and execute them.
2. Review this pseudocode for TND_EMPL_INC:
Insert all CAN and GBR Employees into a temporary table.For each unique country and DEP_COUNT on temporary table:Calculate the percentage increase of the condition with PeopleCodeUpdate the salary field on the temporary table for all employees meeting the conditionInsert/select all rows from temporary table with new effective date into the PERS_DATA tableInsert/select all child rows from DEP_DATA table of only those employees that received a raise. New rows should have the new effective date.
3. Run TND_EMPL_INC:
Open the program in the application designer and run locally. Verify your configuration manager has the Statement timings (file) and PeopleCode timings selected under the application engine trace options.
4. Review the trace file.
a. Open the Application Engine trace file and compare the total time to the time of your tuned EMPL_INC program.
b. Notice the number of loops being done and the number of rows processed in each loop.
This concludes the activity. Please do not continue.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Tuning Application Engine Programs Lesson 15
540
Review
In this lesson you learned that:
• Many factors tied to your database affect performance. Manipulating these factors can affect the performance of other systems.
• Application level performance tuning is by far the best place to start your Application Engine tuning.
• The ReUse option is an excellent way to easily reduce the amount of work your program is doing to executethe SQL in your Application Engine program.
• Executing SQL within a PeopleCode action is far less efficient than using the other Application Engine actions.
• The Bulk Insert option can speed up your SQL Inserts within a loop.
• Commits and checkpoints should be structured strategically.
Slide 283
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
541
Lesson 16
Final Course Activity
Objectives
By the end of this lesson, you will be able to create the LOAD_STU_CRS Application Engine program.
Slide 285
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
542
Activity 38: Creating the LOAD_STU_CRS Application Engine Program
In this activity, you will review the activity overview and implement an Application Engine program that willupdate the Student Courses table based on Enroll Status in the Student Enrollments table.
See Application Engine: Activity Guide, "Final Course Activity," Activity 38: Creating the LOAD_STU_CRSApplication Engine Program
Slide 286
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 16 Final Course Activity
543
Activity OverviewFor this activity, you will write an Application Engine program that will look in the Student Enrollments table(PSU_STU_ENROLL) for all courses that are marked as Complete (ENROLL_STATUS = 'CMP'), and insertthose rows into the Student Courses (PSU_STU_COURSE) table.
Remember that training coordinators will be updating the PSU_STU_ENROLL table at various times and may be accessing or running the Application Engine program at the same time.
When a course is completed, the instructor submits the sign-in sheet to the training coordinator. The training coordinator goes into the Course Enrollments component and updates the course session, changing Enrollment Status to Completed for each student that has completed the course. Then the training coordinator will run your new Application Engine program to update PSU_STU_COURSE.
To access the Course Enrollments application, select Courses, Course Enrollment.
To access the Student Courses component, select Courses, Student Courses.
Resources
You will use these tables in the activity:
Design
Design an Application Engine program to maintain the Student Courses table.
For each Student who has a Status of Complete in PSU_STU_ENROLL, insert a row into PSU_STU_COURSE with Student ID, Course Code, Session Number, and Course Type.
Upon a successful insert, set INSERT_FLAG on PSU_STU_ENROLL to "Y" so that row will not be processed again.
The program should also do the following:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
544
• Allow for the input of a Training Location.
The Training Location specified will define the scope of data the program will work on.
Note that TRAINING_LOC for a Course Session is on PSU_CRS_SESSN, not PSU_STU_ENROLL.
• Run concurrently.
Managers in different regions will be running the process at the same time. Hint: Temp tables.
• Run efficiently.
There may be many students enrolled in a course session, and many sessions will be taught in a quarter. Hint: Set Processing.
• Restart properly.
If an error occurs when transferring the student information, the program should be able to restart, ignoring previously processed rows.
• Commit frequently.
An error in processing data for one session should not affect the successful updates for previous sessions. Once a Course Session has been successfully inserted into Student Courses, those changes should be made permanent.
Hint: Commit frequency would require at least one Do loop.
Records
Consider these questions:
• What fields will you need on your state record?
• Do you need a temporary table? How many instances?
• You will need to add INSERT_FLAG to PSU_STU_ENROLL.
Temporary table
You will need to create a temporary table that joins the PSU_CRS_SESSN table for the TRAINING_LOC and the PSU_STU_ENROLL table for the students who have completed the course.
Test
Test your program initially from Application Designer, using the traffic light button.
Run control
After you successfully test your program, create a run control, so that the training administrator can run the LOAD_STU_CRS program from the Load Student Courses page.
Prompt for Training Location from the run control page.
Suggested navigation path to access this page:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 16 Final Course Activity
545
Page Name Navigation
RUN LOAD CRS Courses, Process Course Information, Load Student Courses
Note. Disconnect from the database in SQL Developer before running an Application Engine Program.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
546
Activity Detailed StepsTo create LOAD_STU_CRS:
1. Modify PSU_STU_ENROLL.
2. Create the state record STU_CRS_AET.
3. Create the temporary table STU_CRS_TAO.
4. Write the program LOAD_STU_CRS.
5. Test.
6. Create a run control record, page and component.
7. Register the Component.
8. Add the run control step to LOAD_STU_CRS.
9. Add a Process Definition.
10. Test LOAD_STU_CRS through the browser.
Modifying PSU_STU_ENROLL
To modify PSU_STU_ENROLL:
1. Add the field INSERT_FLAG to the record PSU_STU_ENROLL.
2. Alter the table.
Creating the State Record STU_CRS_AET
To create the state record STU_CRS_AET:
1. Create a new record with the following fields:
• PROCESS_INSTANCE (set as a Key and Required)
• COURSE
• SESSION_NBR
• TRAINING_LOC
2. Save as STU_CRS_AET.
3. Select Build, Current Definition and create the table.
Creating the Temporary Table STU_CRS_TAO
To create the temporary table STU_CRS_TAO:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 16 Final Course Activity
547
1. Create a new record with the following fields:
• PROCESS_INSTANCE (set as a Key, required)
• COURSE (set as a Key, required)
• SESSION_NBR (set as a Key, required)
• STUDENT_ID (set as a key, required)
• COURSE_TYPE
2. Set the Record Type to Temporary Table.
3. Do not build the table yet.
Writing the Program LOAD_STU_CRS
To write the program LOAD_STU_CRS:
1. Create a new Application Engine program according to this template:
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
548
2. The SQL script is found in: C:\Labs\0411_AppEngine\Scripts
LOAD_STU_CRS
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 16 Final Course Activity
549
Section Step Action Type Action
MAIN STEPM01 SQL INSERT INTO %Table(STU_CRS_TAO) (PROCESS_INSTANCE
, COURSE
, STUDENT_ID
, COURSE_TYPE
,SESSION_NBR)
SELECT DISTINCT %ProcessInstance
, A.COURSE
,A.STUDENT_ID
, B.COURSE_TYPE
, A.SESSION_NBR
FROM PS_PSU_STU_ENROLL A
, PS_PSU_COURSE_TBL B
, PS_PSU_CRS_SESSN C
WHERE A.COURSE=C.COURSE
AND A.SESSION_NBR=C.SESSION_NBR
AND A.COURSE=B.COURSE
AND A.INSERT_FLAG <> 'Y'
AND A.ENROLL_STATUS='CMP'
AND C.TRAINING_LOC = %Bind(TRAINING_LOC)
ORDER BY A.COURSE , A.SESSION_NBR
STEPM02 Do Select
Reselect
%Select (COURSE, SESSION_NBR)
SELECT COURSE
,SESSION_NBR
FROM %Table(STU_CRS_TAO)
WHERE PROCESS_INSTANCE = %ProcessInstance
AND COURSE > %Bind(COURSE)
OR (COURSE = %Bind(COURSE)
AND SESSION_NBR > %Bind(SESSION_NBR) )
ORDER BY COURSE ,SESSION_NBR
Call Section INSERT
INSERT STEPI01 SQL INSERT INTO PS_PSU_STU_COURSE (STUDENT_ID
, COURSE
, COURSE_TYPE
, SESSION_NBR)
SELECT STUDENT_ID
, COURSE
, COURSE_TYPE
, SESSION_NBR
FROM %Table(STU_CRS_TAO)
WHERE PROCESS_INSTANCE = %ProcessInstance
AND COURSE = %Bind(COURSE)
AND SESSION_NBR = %Bind (SESSION_NBR)
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
550
Section Step Action Type Action
STEPI02 SQL
Commit after step
UPDATE PS_PSU_STU_ENROLL
SET INSERT_FLAG = 'Y'
WHERE COURSE=%Bind(COURSE)
AND SESSION_NBR=%Bind(SESSION_NBR)
3. On the Program Properties:
a. Add STU_CRS_AET as the state record.
b. Add STU_CRS_TAO as a temporary table.
Set the instance count to 4.
4. Save the program as LOAD_STU_CRS.
5. Build the table for record definition STU_CRS_TAO.
Testing
Test your program from the Request AE page using FASTTEST Process Definition.
Input one of the following parameter values for the TRAINING_LOC field.
• ATL
• ONSTE
• PSW
• TEA
• WC
• WSTCH
Creating a Run Control
To create a run control:
1. Open the record PRCSRUNCNTL and save as RUNLOAD_STU_CRS.
2. Say yes to the save any PeopleCode message.
3. Add the field TRAINING_LOC.
4. Save the record.
5. Select Build, Current Definition.
6. Select the Create Tables checkbox and click Build.
7. Create a new page called RUNLOAD_STU_CRS.
8. Insert the subpage PRCSRUNCNTL_SBP.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Lesson 16 Final Course Activity
551
9. Add the field TRAINING_LOC to the page.
10. Create a new component called RUNLOAD_STU_CRS.
11. Add the run control page RUNLOAD_STU_CRS.
12. Open the component properties.
13. Access the Use tab and choose PRCSRUNCNTL as the Search Record.
Registering the Component
To register the component:
1. Select Tools, Register Component.
2. Use the following values in the Registration Wizard:
• Menu: PSU_TRAINING
• Registry Folder- PSU_COURSE_PROCESS
• Label: Load Student Courses
• Node: TRN
• Permission List: PSU5000
Adding the Run Control Step to LOAD_STU_CRS
To add the run control step to LOAD_STU_CRS:
Open the Application Engine program LOAD_STU_CRS and add a step RUN before the first step in MAIN.
Use this SQL in a Do Select action:
%Select(TRAINING_LOC) SELECT TRAINING_LOC FROM PS_RUNLOAD_STU_CRS WHERE OPRID = %OperatorId AND RUN_CNTL_ID = %RUNCONTROL
Adding a Process Definition
To add a Process Definition:
1. Select PeopleTools, Process Scheduler, Processes.
2. Create a new Process Definition named LOAD_STU_CRS, with a process type of ApplicationEngine.
3. Access the Process Definition Options tab.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Final Course Activity Lesson 16
552
4. Enter the following information:
Page Element Value or Status
Component RUNLOAD_STU_CRS
Process Group TLSALL
Testing LOAD_STU_CRS Through the Browser
Select Courses, Process Course Information, Load Student Courses.
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
553
Lesson 17
Course Review
Objectives
In this course, you learned how to:
• Describe Application Engine.
• Use the Application Engine Designer to write, test, and debug Application Engine programs.
• Develop robust Application Engine programs.
• Schedule the automatic execution of Application Engine programs.
• Monitor and tune Application Engine performance.
• Develop and test an Application Engine program.
Slide 288
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED
Course Review Lesson 17
554
Ora
cle
Uni
vers
ity a
nd B
USI
NES
S SU
PPO
RT
SAS
use
only
THES
E eK
IT M
ATER
IALS
AR
E FO
R Y
OU
R U
SE IN
TH
IS C
LASS
RO
OM
ON
LY.
CO
PYIN
G e
KIT
MAT
ERIA
LS F
RO
M T
HIS
CO
MPU
TER
IS S
TRIC
TLY
PRO
HIB
ITED