Application Engine Curriculum

PeopleSoft Application Engine
People Tools – Day 4 Class

4 Day Course
[A comprehensive 2 day tour on the capabilities of the SQR language and its usage in PeopleSoft]

Page | 1

Table of Contents
1.1 REVIEW AGENDA......................................................................................... 3 1.2 GETTING STARTED WITH PEOPLESOFT APPLICATION ENGINE................................... 4 1.3 APPLICATION ENGINE PROGRAM COMPONENTS.................................................... 7 1.4 UNDERSTANDING STATE RECORD................................................................... 22 2.1 DO SELECT IN DETAIL................................................................................. 28 2.2 APPLICATION ENGINE RESTART..................................................................... 32 2.3 USING DO ACTIONS.................................................................................... 34 3.1 PEOPLECODE AND APPLICATION ENGINE......................................................... 39 3.2 TESTING AND DEBUGGING APPLICATION ENGINE PROGRAM................................... 45 3.3 APPLICATION ENGINE PROCESS DEFINITION...................................................... 52 4.1 APPLICATION ENGINE PROGRAM EXECUTION..................................................... 60 4.2 TEMPORARY TABLE.................................................................................... 63 4.3 SET PROCESSING....................................................................................... 67 4.4 META-SQL............................................................................................... 68 4.5 COMMAND LINE PARAMETERS........................................................................ 74

Page | 2

1.1

Review Agenda

The following will be covered in Application Engine (AE): Day 1 will include Introduction of Application Engine, Understanding Application Engine Program Structure and Usage of State Record. Day 2 will include Details on Do Select and other Do Actions and understanding Restart Capability. Day 3 will include Use of PeopleCode in AE, Testing and Debugging AE and AE Process definition. Day 4 will include Application Engine Execution, Usage of Temporary Table, Set Processing and Usage of Meta SQL

Page | 3

time. This language is designed to replace RDBMS-specific SQL syntax with a standard syntax. While PeopleSoft Application Engine does not generate. row-by-row processing. We can use PeopleSoft Application Engine for straight. 2) Two views of our program. The Program Flow view allows us to see the actual order in which our program will execute the statements. we specify it as %DATEOUT(AE_DATE). This meta-string will be resolved to the appropriate value as required by the current RDBMS platform.1.2 Getting Started With PeopleSoft Application Engine Describe the major features and benefits of Application Engine. • Data Dictionary Integration: Unlike applications developed using COBOL or SQR. Application Engine Overview • PeopleSoft Application Engine is used for creating applications that perform background SQL processing against the data. • Application Engine Benefits • Graphical Developer Interface: Application Engine is fully integrated with PeopleTools. called meta-strings. This means that we use Application Designer to create Application Engine Program. The Application Designer offers Application Engine developers the following benefits: 1) Easy access to the new PeopleCode and SQL editors. Because Application Engine works in harmony within the PeopleSoft system and references the data dictionary for object definitions. This tool is intended to be used by developers with knowledge of SQL. which Application Engine supports. parse. In PeopleSoft Application Engine. For the most part. or understand SQL. but the most efficient Application Engine programs are written to perform set-based processing. and other numeric calculations. Application Engine programs reside completely within our database. or SQR programs for background SQL processing. it merely executes SQL that we provide. Enhance SQL/Meta SQL Support: RDBMS platforms have many differing syntax rules-especially in regard to date. changes to meta-data in the database have no impact on Application Engine programs. It provides an alternative to writing COBOL. This enables us to archive • • Page | 4 . The Definition view is where we create and modify our programs. and program control actions that enable looping and conditional logic. A program is defined in PeopleSoft Application Designer and performs a business process. if we reference a date field called AE_DATE in a SELECT clause. we can work around this problem using PeopleSoft meta-SQL. Effective Dating: Application sections are effective-dated—meaning we can activate/deactivate a section as of a particular date. PeopleCode. For example. SQL tools and PeopleTools. a program is a set of SQL statements.

in addition to the Page | 5 . a program type used to support Extensible Stylesheet Language Transformations (XSLT). Import Only. need to code it in your programs yourself. In the future if we decide to revert to a previous incarnation of a section. there may still be times when we have to write and execute different SQL in our Application Engine program. because it runs indefinitely. depending on the RDBMS platform on which we intend our program to run. Conversely. Daemon Only. Then we upgrade the entire project all at once. It polls the system. and is intended for recurring jobs. • • • Application Engine Program Types There are five types of Application Engine programs. PSDAEMON schedules a process to handle the event. Upgrade Support: Since Application Engine program definitions are defined in and stored as Application Designer objects. The restarted Application Engine program locates the last checkpoint. which is used in PeopleSoft upgrade utilities. A predefined set of conditions is an event. we must define how frequently our program will issue a COMMIT. This means that we can call common PeopleCode functions from Application Engine. and so on. The types are: • • • • • Standard. we have the ability to call different versions of a Section for different platforms. We can insert records and Application Engine programs in the same project. we would. this is a normal entry-point program. stored as callable sections. which is used by PeopleSoft import utilities. Upgrade Only. Built-in Restart Logic: Within each Application Engine program. and we can then also include in the project any Application Engine programs affected by the change—along with affected pages. instead of destroying them. Reuse Business Logic: Application Engine programs can invoke PeopleCode. called PSDAEMON that runs continuously when PeopleSoft Process Scheduler is running. as needed. PeopleCode can now invoke an Application Engine program synchronously. it only allows PeopleSoft Application Engine tracing at the step and SQL levels. or the last successfully executed and committed Step. Daemon Program Type • • PeopleSoft Application Engine provides a daemon process. Transform only. You specify the type in the Program Properties dialog box for your program definition. This type of built-in logic does not exist with COBOL or SQR. In Application Engine. PSDAEMON supports limited tracing. a type of program used as a daemon process. each COMMIT becomes a checkpoint that Application Engine uses to locate where within a program to restart after an abend. we can put the modified record into a “project”. This means that if we change our record definition. • Platform Flexibility: Even with the use of Meta-SQL. AE libraries are used to store common routines. When the conditions are true. we can simply reactivate it.sections as we modify them. and continues with the processing from that point. checking for certain conditions to occur. Specifically. After doing so. of course. These sections can then be called by multiple programs. we can easily upgrade using Application Designer.

When you specify an Application Engine program as a Transform Only program. such as Timings and DB Optimizer tracing. Page | 6 . • Determine whether to pass a message through to its target. Other options.• standard PeopleSoft SQL and PeopleCode tracing. you must specify actions of type XSLT or PeopleCode. You activate PSDAEMON in PeopleSoft Process Scheduler or from the command line Transform Program Type Transform Only type programs enable different systems to communicate with one another by transforming messages into appropriate formats. are not supported. • Perform a data translation on a message so its data is represented according to the target system’s conventions. You can use transform programs to do any of the following: • Apply a transformation to a message to make its structure comply with the target system’s requirements. by filtering it based on its content.

PeopleTools. by either using the all nodes toolbar button icon next to the MAIN folder. In the Application Designer. The UserId is PS and the password is PS. Expand all the nodes.1. Programs. Expand All (Ctrl+Shift+X). • Select the program PER099 by double clicking on the program name. Start. or selecting View. open the Application Engine Program PER099. PeopleSoft 8. the expand • . • • Log on to the PeopleSoft development environment. Page | 7 .3 Application Engine Program Components Application Engine Designer Application Engine programs are created and modified in the Application Designer.

” Page | 8 . An Application Engine program comprises of several key elements: • • • • Program. to create your Application Engine program. A program must contain at least one Section. This means that you use the Application Designer. Users of previous versions will know that this is a change from only being allowed to work on a Section at a time. an intuitive graphical interface. Actions. Application Engine is fully integrated with PeopleTools. Two views of your program. The execution of the program always starts with the Section defined as “MAIN. Ability to work on the entire Application Engine program at once. Program Flow tab Click on the SQL or PeopleCode icon and the content of the action is displayed. The Application Designer offers Application Engine developers the following benefits: • • Ability to open multiple Application Engine programs concurrently. • • The Definition view is where you create and modify your programs. The Program Flow view shows a graphical representation of your program execution. Sections. Program An Application Engine program identifies the set of processes to execute a given task. Easy access to PeopleCode and SQL editors.With PeopleSoft 8. Steps.

The four types of Do actions are: • • • • Do While Do When Do Select Do Until We will look into each of the Do Action in details later. You can call sections (and other programs) from steps within other sections. Although you can use a step to execute a PeopleCode command or log a message. When a section gets called. • A program must contain at least one section. if a Select statement returns no rows. A Do action is equivalent to a COBOL and has similar constructs. The SQL or PeopleCode that a step executes are the actions within the step. Do Actions Do actions contain subsequent actions subsequent actions Perform statement a SQL Select statement designed to return results on which depend. typically you use a step to execute a SQL statement or to call another section. Steps • Steps are the smallest unit of work that can be committed within a program. • A section is a set of ordered steps that gets executed as part of a program. These actions can perform the following types of SQL statements: • • • • Update Delete Insert Select Page | 9 . • Actions There are multiple types of actions that you can specify to include within a step. Every program begins by executing the first step of the required section called MAIN and ends after the last step in the last section completes successfully. its steps execute sequentially. may not need to execute.Sections • Sections comprise one or more steps and are equivalent to a COBOL paragraph or a Structured Query Report (SQR) procedure. It is common to have multiple actions associated with a single step. The execution of the program always starts with the section defined as MAIN. All Application Engine programs must contain at least one section titled MAIN. For instance. SQL Most SQL actions contain a single SQL statement.

and parameter values. UPDATE. • ReUse . The program continues processing. The following list contains the options that you have when no rows are returned. which also contain SQL. Continue. For SQL Actions. and DELETE) associated with the SQL Action does not return any rows. Skip Step. the system retrieves the appropriate message string from the message catalog based on the user’s language preference. Log Message You use a Log Message action to write a message to the message log based on a condition in your program. there are two properties that can be set. and file processing. perform simple if/else edits.  Abort.The SQL action differs from the Do actions.In the event that the SQL (INSERT. When using Skip Step keep the following in mind: • • Application Engine ignores the commit for the current step at runtime. It also enables you to reference and change active Application Engine state records. PeopleSoft Application Engine PeopleCode provides an excellent way to build dynamic SQL. and control returns to the calling Step. you need to specify what your Application Engine program should do. and other operations that don't require a trip to the database. • PeopleCode You can include PeopleCode in the PeopleCode action. Most importantly. message number.    Section Break. only use Skip Step to bypass the commit. No Rows. The program terminates. Component Interfaces. PeopleCode provides access to the PeopleSoft integration technologies such as PeopleSoft Integration Broker.ReUse is an option you can enable to optimize the SQL components of your batch program. Application Engine exits the current Step immediately and moves on to the next Step. This gives your program multilanguage capability. When a user views the messages using the Application Engine Message Log page. Business Interlinks. in that the SQL action does not control the flow of the program. If the current Step contains only one Action. set defaults. Application Engine exits the current Section immediately. The system stores the message generically as a message set. Call Section Page | 10 .

reusable pieces. just call it. as we are not going to add any SQL statements. Page | 11 . we will go through the mechanics of creating a new program shell.You can also insert an action that calls another section. Activity 1 – Writing the first Application Engine Program Shell In this activity. We will use this to understand the various properties that we can set. This will not be a working program. or it can be in an external program. This enables you to chunk your program into more maintainable. The called section can be in the same program as the calling section. If a section already exists in one program. rather than copying it into another program.

• • • Change the Insert Definition into Project group box to use “When definition is modified and saved. New. Click OK to save the setting. Initially you get the MAIN section and Step01 (with no Actions yet). Inserting Section and Steps An Application Engine toolbar will be associated with your new program to allow you to insert Sections. App Engine Program. expand and collapse the program's tree for better visibility. or deleted”. we want to make sure that our new definitions are automatically added to the PSTRN_AE project. Steps. and Actions. You create an Application Engine program using File. You also have icons to refresh.Before we start building Application Engine programs and related definitions. In se r t Ste p an d Actio n In se r t Se ctio n In se r t Actio n Ru n Pr og r a m R e fr e sh Vie w Expa n d a ll N o de s C o lla p se a ll No de s Page | 12 .

If you have your cursor on a section.You can also add sections. Enter a descriptive name for the section. steps and actions using the Insert menu option or by using the right mouse to invoke the popup menu. Section Properties For each section. To make a particular Description Market Platform Effective Date Page | 13 . keeping in mind that you only have an 8-character limit. In some cases. Develop a naming convention and be consistent throughout your projects. you can set properties for the section. This enables you to take advantage of any RDBMS-specific optimizations or to change your section logic because of RDBMS limitations. you may be developing an application to run on a particular platform or RDBMS. The default effective date will be 01/01/1900. Control Section Name Description Be as descriptive as you can. If a particular Market is irrelevant to your batch program. the Insert Action will be grayed. Notice that the Insert is dependent on where the cursor is placed. Select the Market for which the Section is intended. you can leave the Market value as GBL.

Effective Status Section Type You can indicate whether or not this section is active. Step Properties Each section contains one or more steps. which is similar to the Platform value of default. The steps contain the logical groupings of actions to be performed. Application Engine then looks for an Oracle version of the SECT01 for Public Sector. Show all Comments (F2) from the menu or right mouse on the section and select Show Comment. If a Section for the current Platform or RDBMS exists. execute it.section effective-dated. Page | 14 . If a “unique” Section does not exist. For example. effective date and market. If the program is running on Oracle. Auto Commit Access Comments To view comments. If you request to run the Public Sector version of the program. This property controls the Call Section Action. execute it. The default Market value is GBL for Global. In the case of an abnormal termination of the program. Application Engine just executes the “default” Section. enter the effective date. it executes Sections based on the following order of precedence: • • • • If a Section for the current Market exists. The steps are executed in the order that they are displayed in the application designer. When you execute an Application Engine program. Here you specify the Commit level for the Section. the value of this system field specifies whether or not you will need to Restart the Section. section names. RDBMS platform. If a Section for the current Effective Date exists. You can specify that a Section can or can’t be called from another program. You can opt to have no Commit or you can have Application Engine Commit after each Step successfully completes. execute it. suppose you have two versions of a particular Section: SECT01 for Public Sector and SECT01 for Global use. Use the comments section to document the section. you can select View. Execution Precedence A Section is unique based on the program. Application Engine executes the Public Sector version of SECT01.

Page | 15 .no message will be written. Determines when commit will be executed: Default . execute PeopleCode. But you also have the ability to log messages.click the Add action 8 more times. Action Properties Actions are the reason for your program. Enter a descriptive name for the step.uses value supplied for the section Later . call other Sections and perform transformations.commit when step completes Frequency On Error Only available in loops Determines the action to take when an error occurs: • • • Abort .program will write message to message log and continue Suppress .program will write message to message log and terminate Ignore . The primary type is a SQL statement. They contain the code you wish to execute. Moreover. With you cursor on Section1. but program will continue Active Comment Determines if the step is active (ticked) or inactive (blank).Control Step Name Step Description Commit After Description Consecutively numbered based on last step name. Step01 . In a given Step you can have multiple actions but only one instance of each action.do not commit now After step . Add any additional comments to document your program. the actions execute in a given sequence.

Click OK. Page | 16 . To refresh. the actions will be reordered into the order of execution.On the eighth insert. you will receive the following message. You will also notice that there are 8 actions out of the available 9. Refresh or F5. either select the Refresh Icon or View. When you refresh.

Descriptions and documentation are updated via the general tab in program properties. If you modify existing programs. Page | 17 . you will want to document your changes. Definition Properties or . Open the Application Engine program PER099. Program Properties When you create a new program. File.N o t e : SQL and Call Section are mutually exclusive. you will want to give your program a name. Open the Program Properties.

or routines. In some cases. that exist in the Page | 18 . or “library. you may want a program to contain only a collection.Item Disable Restart Application Library Description Select this to disable the Application Engine built-in restart capabilities for this program.” of common routines (in the form of "callable" sections) that you do not want to run as a standalone program." other programs can call the sections. When sections are defined as "Public.

you may want a program to only contain a collection. Import Only. Setting this option renames or removes any existing MAIN section. Message Set Program Type Application Library Most Application Engine programs are defined to be executable. However. Testing Application Engine Program There are several methods that developers use to test Application Engine programs: • • • Execute directly from Application Designer in 2-tier. or "library". Because this type of program is not designed to run as a stand-alone program. Select the appropriate program type from the list: Standard. or initial entry point. Run Program or the Run Program push button . you can select Edit. Because this type of program is not designed to run as a standalone program. it does not require the MAIN Section. During the course of this class we will only be dealing with Standard or Daemon Programs. or routines. The system uses this Message Set value for all Log Message actions where the message set isn’t specified. This method is fast and simple. Daemon Only or Transform Only. Command Line We will look at the first two methods here and the last will be discussed later. such as command line or Process Scheduler. Batch only programs are not executed from the CallAppEngine() PeopleCode function. that exist in the "library" at runtime. in some cases. Developers Shortcut (Generic Application Engine Test Type) through the Process Scheduler. Any dedicated temporary table used for Batch Only programs do not have online instances created.Item Description “library” at runtime. Upgrade Only. Execute Directly from App Designer In the application designer. or initial entry point. can initiate the program. When sections are defined as "Public". of common routines (in the form of "callable" Sections) that you do not want to run as a standalone program. Specify the message set value that you want assigned as the default message set number for this Application Engine program. other programs can call the Sections. This defines the entry point so whatever method you choose to invoke the program. Batch Only Select this check box for batch only programs. An executable program has a main entry point in its definition: the Section MAIN. but does not allow you to add any run control parameters at execution time. Page | 19 . Setting the Application Library option renames or removes any existing MAIN Section. it does not require the MAIN Section.

Developer’s Shortcut PeopleSoft come delivered with a page called Request AE. Specify the log file name (enabled only when Output Process Instance number will default to 0.Run Control ID Run Minimized Output Log to File Log File Name Process Instance Enter the run control ID of the program that you are testing. This page is designed for developers to test Application Engine programs. Application Engine. The Request AE page allows you to enter parameters associated with the Application Engine program. Select PeopleTools. If your program requires run control parameters. you will need to populate the fields on the run control and specify the run control when executing from Application Designer. Select this to have the window of the requested process minimized when it is submitted to run. Process Origin Displays where the program was invoked: from PeopleSoft Process Page | 20 . Select this if you want the output log to be written to a file. Request AE to access the Application Engine Request page.

pending. Displays the status of the last program run. whether it is successful. Variable Enter the appropriate field or bind variable for which you are inserting a value. and so on. so that no one invokes it and potentially corrupts data. and so on.Scheduler. Specify how long a particular process request will remain active or valid: • • • Always: Select to run the process request as needed. from the command line. Don’t: Select to disable a process request. Once: Select if a process request is a one-time-only request. As Of Date Bind Name Value If you are requesting retroactive processing. Enter the initial value that you want to set for the specified field Page | 21 . Process Instance Status Process Frequency Displays the process instance assigned to the previous program run. specify the appropriate as of date.

If the state record is a physical table. A State Record is the method by which you allocate variables for your Application Engine program. therefore the values would be lost during a restart. • • • • • • The first field must always be PROCESS_INSTANCE and it must be a key field. Steps and Actions Results of SQL Selects Values for SQL Updates. Any additional fields on the record will be variables that you will use within your Application Engine program. Inserts. Page | 22 . this field will be populated with the process instance assigned by the system for this job.1. The only difference is that derived state records cannot have their values saved at commit time. one or more Application Engine State records associated with it. Deletes Computed values or counters Program working values Programmable switches or flags How to Create State Record Open the record HR_AET in the Application Designer. The state record is used as a worktable for: • • • • • • • Initial values Values to be passed to program Steps from prior Sections. Any data types except character or numeric must not be required fields.4 Understanding State Record Each Application Engine program can have zero. The state record can be a derived work record or an SQL table. you must perform a build before using the table. When you execute an Application Engine program. This is how the system identifies the record as a state record. The name of the state record must end in AET.

use the with AET. To add a new state record. push button.• • No PeopleCode fires on an Application Engine state record. Notice that all state records end Page | 23 . No validation of translates values or prompt tables are done. Using State Record State records are associated with Application Engine programs using the program properties for the program.

it can be accessed using the %Bind(fieldname) to execute the SQL. %Select(ASOFDATE) SELECT %DateOut(ASOFDATE) FROM PS_RUN_CNTL_HR WHERE OPRID = %OperatorId AND RUN_CNTL_ID = %RUNCONTROL %Bind The %Bind function can be used anywhere in a SQL statement SELECT ITEM_CODE. Use the record to the program. Once a value is inserted into the state record. When the Application Engine program completes successfully. the row of data in the state record is deleted. %Select A %Select is required at the beginning of any and all SELECT statements. either by the run control (as we have seen in this example) or by using %Select in your Application Engine program.Highlight the state record you wish to use. ITEM_DESCR FROM PS_ITEM_TBL WHERE VENDOR_CODE = %BIND(FIELD1) Page | 24 . pushbutton to add the state %Select() State Record XX_XXXXXX_AET %Bind() Application Engine Program Contains Actions(s) using specific SQL statements that load or pull 1 row of data from the State Name Record(s) Values are inserted into the state record.

state records that are common to both programs retain their current values. use the following: %BIND(fieldname) Unless a specific record name is specified preceding the fieldname. For those state records that are shared between programs (during an external call section). any additional state records defined for that program (as in state records that are not already in use by the calling program) are initialized. yet it can also cause unforeseen errors. Generally. In theory. Most programs have their own set of state records unless a program calls another program that requires specific input or output variables. a called program should not share state records with the caller unless you need to pass parameters between them. However. any changes made by the called program remain when control returns to the calling program. Solution: 1) Create the following entry in the Message Catalog. use the following: %BIND(recordname. When you call a section in another program. even if the program has been called previously during the run. In that case. Otherwise. the called program inherits the calling program's default state record. Any subsequent actions in the calling program can access residual values left in the common state records by the called program. and make sure to set the input values before issuing the call section.fieldname) In the case of a called program or section. Page | 25 . %BIND references the default state record. Activity 2 – Writing the first AE Program using State Record Create an Application Engine program using State Record and Log Message Action to write message with the program run date. if the called program has its own default state record defined. This can be useful to return output values or status to the calling program. the called program does not require a state record if all the fields it needs for processing exist on the calling program’s state record. To reference variables that exist within a state record. To reference a state record other than the default.Sharing State Record State records can be used by multiple sections and by multiple programs. then PeopleSoft Application Engine uses that default state record to resolve the %BIND(fieldname). you must include the state record of the called program into the calling program’s state record list.

Page | 26 . 3) Create a simple App Engine program APPENG_TUT1_SOA and associate APPENG_TUT_SOA as the default State Record.2) Create a Derived State Record APPENG_TUT_SOA.

“Do Select” action has the following SQL to initialize the state record. ****************** %Select(ASOFDATE) SELECT getdate() ****************** 4) Save and run the program. Note: This program also illustrates passing of parameters to the Message Catalog Page | 27 .

will be permanent changes. SELECT Statements When a SELECT statement is executed through a cursor. a cursor must be opened on the database. there may be many cursors open. the program will move to the next step.1 Do Select In Detail The Do Select Action is a SELECT statement that executes subsequent Actions within the Step in a loop based on whether the SELECT statement in the Do Select Action has returned a row. Within an Application Engine program COMMIT can be issued during the middle of the program’s run. Cursors are frequently opened and closed during the program’s execution. When issued. There are 3 select types: Page | 28 . Once work is COMMITed it cannot be undone. Cursors and COMMIT When a cursor is opened and work is performed. or perhaps other statements like an UPDATE or INSERT. This is equivalent to a FOR loop. The requester could be an online PeopleSoft page. Do Select Types The type of Do Select determines the specific looping rules. the row(s) retrieved will be placed into a memory buffer on the database for that cursor. and the results might be that of a SELECT statement. From there. or cursors that still remain open. Before we take a look into the 3 select types let take a look into the following concepts: What is Cursor? Anytime a SQL statement is sent to the database. Each cursor is responsible for carrying out a specific SQL statement. When there are no more rows meeting the criteria. If there are multiple rows in the memory buffer Application Engine can be made to execute the “Select then Fetch” the rows one at a time from the memory buffer in a loop.2. The cursor is the avenue by which the database will communicate the results of that specific request back to the requester. Each row of data in the database meeting the criteria is loaded into the state record and processed within a loop. Cursors and ROLLBACK A ROLLBACK is simply taking all the data that all the cursors have accomplished for your program. a SQL query tool or an Application Engine program. This means that any work that has been performed on any cursors that have been opened and closed. Once a ROLLBACK is issued a COMMIT that immediately follows would have nothing to COMMIT. and undoing it. it is done so on a conditional basis and has the potential to be undone. a FETCH is issued to retrieve the row(s) from the memory buffer as needed. Looping techniques work with many cursors. If and when a COMMIT statement is issued to the database this conditional work is now permanent and cannot be undone. a ROLLBACK is done back to the last COMMIT issued. While an Application Engine program is running. When the COMMIT is issued it will be issued across all cursors.

Reselect The Reselect type opens the cursor and closes the cursor on each iteration of the loop. Once the subsequent actions. you need to make the SQL (in the current Step or a Called Section) such that it will be changing the status of the rows in the table the Do Select is selecting.). it will be reselecting the same row of data. are completed the program returns to the SQL in the Do Select and opens a cursor again. are completed the program returns to the open cursor from the Do Select. SQL. Page | 29 . The Select and Fetch type will: • If restart is not disabled all COMMITs executed within the Do Select loop (for example: COMMITs on Called Sections) are ignored. This way you will be reducing the result set of the Do Select until it returns nothing or a false. retrieves the next row and continues again with the rest of the actions. The reselect functions as follows: • Opens a cursor to the database.). Selects the first row that meets the SQL condition in the Do Select. As a result. Disabling restart is a simple way of telling the application that you are freeing it up of the responsibilities of knowing where to restart. Once the Do Select does not retrieve any rows (False). Therefore a restart at the exact point (loop) is impossible. SQL. Executes the following Actions in the step (Call Section. • • • • Selects the first row that meets the SQL condition in the Do Select. The reason these COMMITs are ignored is because of limitations of the checkpoint written to the PS_AERUNCONTROL table. etc. Once the subsequent Actions. • Write “COMMIT setting ignored” in the trace file for any commits within a Do Select loop. to prevent being caught in an endless loop. Closes the cursor. Essentially. That responsibility is now yours via a SWITCH field or an ORDER BY clause. Executes the actions in the step (Call Section.• • • Select/Fetch Reselect Restartable Select and Fetch The Select and Fetch type: • • • Opens the cursor to the database. it will skip the subsequent actions in the same step and move onto the next step in the Section. The checkpoint has no way of recording where inside a loop the process left off. thus ending the Do Select loop. etc.

the program will in fact have a way to know where in the loop it left off. Page | 30 . Restartable The Restartable type acts precisely like the Select and Fetch. the information in the AE_RUNCONTROL record and the state record is used to restart the program.COMMITs are NOT ignored and will be committed in a Reselect loop. provided you have NOT disabled restart. Because the rows being selected are being changed by your code. The major difference with Restartable is that it WILL COMMIT inside the loop thus allowing a checkpoint to the PS_AERUNCONTROL table. If the program abends. provided you COMMIT those changes. making a restart possible. The last section and step COMMITed will be listed in a column called AE_RUN_DATA. a checkpoint is also COMMITed to the PS_AERUNCONTROL table. This causes each iteration of your loop to select the next row that meets your condition without the need to change the status of that row as we do with the Re Select option. whenever a COMMIT is issued inside your program. You need to: • Identify the rows to be processed o o • • Process Flag Delete rows Order the data values Place commits in the appropriate sections or steps Remember. It opens the cursor and leaves it open.

Yes (provided you code it that way) Definition Restartable from inside the Do Select loop Are program level commits performed inside the Do Select loop for restartable AE programs? Do you need to reduce the result set of the Do Select loop by deleting rows or including a ‘processed flag’ No Yes Yes No Yes Yes Activity 3 – Writing AE Program to understand Do Select Types Create a Reporting table based on JOB and NAMES to store current employee information (EMPLID. EFFDT. See the trace file to find the effect of using Select/Fetch Note: We are using row by row processing just to illustrate the Do Select type. Use Do Select (Select and Fetch) and perform row by row processing to insert current employee information into the reporting table from JOB and NAMES. EFFSEQ. Build an AE program to do the following: Truncate the Reporting table at the beginning of the program. LOCATION) from JOB. DEPTID. Keep trace on and run the program.Select Type Summary Select/Fetch Opens the cursor once & performs a fetch for each iteration of the loop. No ReSelect Opens a new cursor for each iteration and selects the 1st row that meets the select criteria. In actual development this kind of situations should be handled using Set Processing. Set commit frequency for this step to 10. Page | 31 . NAME. Yes (provided you code it that way) Restartable Opens the cursor once & performs a fetch for each iteration of the loop. EMPL_RCD. JOBCODE.

If your state record is a derived work record.2 Application Engine Restart By default. Defer the commit for a step. So. Begin processing at the next step after the last successful commit. It's up to you to design and set up individual Program Level commits where appropriate. If you are using a State record. you will not be able to rerun the program with the same run control. so you want to build that into your design. Check Points If you have restart enabled. Here are the Program Level commit settings you can select: • Commit after each step in that section. AERUNCONTROL The ability for Application Engine to “remember” what Steps have already completed and which Steps have not is attributed to an important record called AERUNCONTROL—keyed by Process Instance If restart is enabled and the program fails. Application Engine also performs a checkpoint beforehand. Application Engine does not perform a commit until the entire program successful completes. you will not be able to retrieve this information.2. whenever there is a Program Level commit. Here we will examine what happens when a commit is issued and how this affects the ability to resume an Application Engine program. Page | 32 . the end user can restart the program and expect the program to behave in the following manner: • • Ignore the steps that have already completed up to the last successful commit. The AERUNCONTROL table is checked and the program will not run. Commit frequency within a step or n iterations for looping actions. if in fact a failure occurs at any point in the process. Manual commits will not have a checkpoint written for them and are not recommended. • • • Require commits after a step. the information about which row was currently processing will be in the state record if your state record is a physical table.

you need to design for a restart at every level. and step level. We also saw that disable restart can be set in the Configuration Manager. as in the program. Keep in mind that if a work record is used Application Engine will re-initialize any state records that are work records at each COMMIT. no check-pointing will occur. Programming for Restart If you decide to create a program that can be restarted. then you will also want to test the restart capabilities. Program Level • State Record You may need to make at least one of your state records an SQL table. then you can disable restart for that program. Disabling Restart If your program does not perform critical updates and can be rerun with no adverse affects on data integrity.If you design and create your Application Engine program for restarts. Program properties • Page | 33 . The QUIT option in the Application Engine debugger is used for exactly this purpose. section. When Disable Restart is selected.

Call Section and Log Message. If there is no row of data returned the entire Step would terminate. Here we will have a look at the rest of the Do Actions. Do When. • Add an order by clause %SELECT FIELD1 SELECT FIELD1 FROM PS_SOME_RECORD WHERE FIELD1 > %BIND(FIELD1) ORDER BY FIELD1 • Add a switch to the selected table SELECT COLUMN1. make sure that Disable Restart is not selected on the Process Scheduler tab.3 Delete processed rows Using Do Actions The four Do Actions—Do Select. • Configuration Manager In the Configuration Manager. Do When The Do When Action is a SELECT statement that allows subsequent actions to be executed if any rows of data are returned. COLUMN2. If the Do When conditions are not met. A Do When Action is executed just once when a step is executed. A Do When statement runs before any other actions in the Step.PeopleCode. We have already looked at Do Select action. Page | 34 .On the Advanced tab in the Program Properties dialog box.… FROM PS_TABLE1 WHERE PROCESSING_SWITCH = 'N' • 2. Section Level You need to have some conditions that reduce the answer set returned by the DO SELECT. The Do When statement is first in the execution order within a step. If the Do When statement returns any rows. Executes the action once if the condition is TRUE. the program will end. The Do When statement will contain SQL that tests for a condition. the remaining Actions within that Step are not executed. the next Action will be executed. SQL. make sure that Disable Restart is not checked. If there are no more steps to execute. the subsequent actions within the step will be performed. As long as the condition is true and a row of data is returned. Do While and Do Until act as SQL conditions for the execution of the other four actions . This Do When option is similar to a COBOL “IF” statement.

The Do While Action runs each time before the next Action is repeated. In other words. In short. If the Do While returns any rows of data. The Do While is identical to the COBOL “WHILE” function. if the Do While does not return any rows. the Step is complete. If no rows are returned. You use a Do While Action to control the execution of the following Actions. all the Actions in the Step will be repeated. Loops as long as the condition is true. Page | 35 .Step01 Do When No DO WHEN counter = 1000 True? Yes action Grant Award Step02 Do While 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. Application Engine will move on to the next Step or Section. the subsequent actions in the step will be executed. the subsequent Actions within the Step are executed in a loop as long as the SELECT statement returns at least one row for the Do While Action.

if the SELECT for the Do Until does not return any rows. Use a Do Until if you want the “processing actions” to execute at least once. then the Actions in the Step are repeated (except if a Do When appears in the Step). the step terminates. the DO Select stops and the actions in the Step are not repeated. You can also use a Do Until to stop a Do Select prematurely. If the SELECT returns any rows of data. Step01 Action(s) counter = counter + 1 Do Until No True? Yes DO UNTIL counter = 1000 Step02 Page | 36 . Loops as long as condition is FALSE. If any rows of data are returned. as in until a SELECT returns some rows. Normally. a DO Select continues until no rows are returned. For example.Step01 DO WHILE counter <1000 Do While No True? Yes action counter = counter + 1 Step02 Do Until A Do Until Action is a SELECT statement that runs after each action within a Step. and to execute over and over until a certain condition is true.

Conditional Statements In order to test for a condition, you will need to create a SQL statement that returns a True or False. Here is an example of how the SQL statement can be coded: SELECT 'X' FROM PS_INSTALLATION WHERE %Bind(COUNTER) < 1000; When this SQL statement executes, it will return TRUE if the value of the field COUNTER in the State Record is less than 1000 and FALSE if the value is equal to or greater than 1000. Since your condition is being tested by the WHERE clause of your SQL statement, in some cases it does not matter which table you select from. 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. Since we only need one ‘X’ returned if our condition is true, any one row table in your FROM clause will suffice. A very common technique you will see in Application Engine programming is to use the PS_INSTALLATION as your FROM table. (The PS_INSTALLATION table is a one-row table delivered from PeopleSoft.) Test Condition and State Record: All SQL SELECT statements in an Application Engine Action must be preceded by a %SELECT(), causing the value to be written to the State record. We generally use the TEMP_FLD to write the value to, which acts as a container for the ‘X’ retrieved from the database if our condition is true. Once the ‘X’ is written to the field, there is no need for it. A subsequent SELECT ‘X’ statement in your AE program will overwrite it, and generally the character is not used in your processing. %SELECT(TEMP_FLD) SELECT ‘X’ FROM PS_INSTALLATION WHERE %BIND(COUNTER) > 10 Meta-SQL to write ‘X’ to State Record If ‘X’ is returned this equals TRUE Fills the requirement for a FROM table Condition to be tested.

Do Process Program Flow

Page | 37

The following shows the action execution hierarchy for Actions describes the sequence and level of execution for each type of Action:

WHEN a SELECT returns a row.

WHILE a SELECT returns a row.

For every row returned from a SELECT, continure in the following order:

Execute PeopleCode if any. Loop Execute SQL or Execute the Section.

Insert message into the Message Log.

UNTIL a SELECT returns a row.

Page | 38

3.1

PeopleCode and Application Engine

In PeopleSoft 8, the ability to use PeopleCode in an Application Engine program was introduced. With Application Engine PeopleCode Actions, your Application Engine programs can solve a wider range of business problems with an added flexibility. However, when using PeopleCode in Application Engine programs, it’s important not to lose sight of Application Engine’s original (and current) purpose. 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. This is mainly due to the fact that Application Engine is most powerful when it executes SQL-based processing against your database. PeopleCode is an interpreted language, so there is an inherent extra performance overhead when compared to a compiled language. The intent is to use this new capability to provide: • • • • • Testing for Conditions (If-then-else). Computing capability. Building dynamic portions of SQL, while still relying on AE to complete the bulk of the actual program processing. Sharing complex business rules between online and batch processing. For example, tax computations. Accessing new PeopleTools integration technologies in PeopleSoft 8.x: File Objects Component Interfaces Messaging Business Interlinks PeopleCode Editor and Application Engine To create a new PeopleCode Action, use Insert, Action and change the Action Type to PeopleCode. You will need to save your Application Engine program before you can open the PeopleCode editor. To open the PeopleCode Editor either: • • • Double click on the gray area for the PeopleCode action. Select View, PeopleCode. Right mouse and select View PeopleCode from the popup menu.

Page | 39

Also. but in Application Engine. most of them (except Save) are available from a popup menu when you right-click in the editor. Paste. The right drop down box has no effect when the PeopleCode Editor is accessed through Application Engine. Cut. The final portion of the PeopleCode Editor is the main editor window. Replace. Copy. The PeopleCode Editor supports the standard text editing features and functions. Command Save Undo Cut Key CTRL+S CTRL+Z CTRL+X Button Page | 40 . such as Save. All sections and actions appear in this list. To change from one PeopleCode program to another just choose the action you want to look at/edit here. there is only one event available—OnExecute. These can be invoked via the appropriate menu or by using the toolbar icons shown below. This works similarly to Notepad or other common text editors. and the PeopleCode Actions appear in bold type. Find.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. and Undo. It is normally used to select the PeopleCode Event that the code should be attached to.

so they can be used for restarts. They can take on the appropriate data type when a value is assigned to the variable. These variables are available while the Application Engine program is running. As you declare a variable you can also assign an initial value to it. Declaring a variable: LOCAL <datatype> <varName> = <initial_value>. They are saved at commits and checkpoints. Same as Global PeopleCode Variables for Application Engine. Global Application Engine Program Component Application Engine Program Variables are denoted with an “&” prefix. differentiated by the life span of the variable. Variable Type Local Life Span PeopleCode program Notes These variables are only available for the duration of the program in which they are declared. Local variables do not need to be declared. or another window (including other PeopleCode Editor windows). You can drag and drop text or object names from the project workspace.e. Page | 41 . A key feature of the PeopleCode Editor is syntax validation. Doing this will open another window with the desired information.Copy Paste Find Replace Validate Syntax CTRL+C CTRL+V CTRL+F CTRL+H A time saving feature is drag-and-drop editing. where LOCAL can be replaced with GLOBAL or COMPONENT depending on the variable type. PeopleCode Basics There are different types of variables in PeopleCode. Global and Component variables must be declared (and it is a good practice to declare your local variables as well). This occurs automatically on Save. You can access object definitions or PeopleCode functions by right clicking on the object name or function and choosing View Definition or View Function {functionName} from the popup menu. such as &MYROW or &Course. or if you click the Validate Syntax icon— . This will check all your syntax for errors including bad object references (i. non-existent fields) and missing parameters. However.

SQL. There are multiple methods used to reference fields in PeopleCode. Any RECORD. OptEngine. Second.NAME). Message. AESection. Object. For example. */ End-If. there are only two that apply to Application Engine. Of the various methods. */ Else Exit(1). ProcessRequest. Application Engine programs run in batch mode so. The setting of the Exit can cause the next Application Engine step to conditionally be skipped. Row. TransformData. Date. Cookie. One (1) indicates that the instruction to be done On Return will be done.FIELD references that appear in a PeopleCode Action can only refer to fields that exist on an Application Engine State Records.GetField (FIELD. you can use dot notation. The parameter in the Exit function controls the path the Application Engine program will take. SoapDoc. Field. Application Engine and the IF-THEN statement In the Application Engine. and so on are inaccessible even if you define the page records as state records on the Program Properties dialog. Record. Interlink. APIObject Object Types: Example: Local Number &MyVariable = 3. Integer.EMPLOYEE). JavaObject. String. SyncServer. XMLNode. Referencing Record Fields There are significant differences between executing PeopleCode in online and batch modes.The data type can be any of the following: Conventional Types: Boolean. Request. /* or can use Exit 1. controls. use syntax similar to the following: If &Test = 10 Then Exit(0). Array. Any. BIDocs. you can assign the employee’s name to a variable using the following syntax: &NAME = GetRecord (RECORD. the If-Then statement is used to control flow of execution with the Exit statement. /* or can use Exit 0. RowSet. File. For example. An Application Engine program can only access State Records or other Definitions you create in PeopleCode. DateTime. Float. Number. First. you would refer to an employee’s name using EMPLOYEE. XMLDoc.NAME. To do this.<FieldName>. Response. Time. Page buffers. your PeopleCode can’t access pages or controls as it can while running in online mode. Page | 42 . you can refer to the field using the syntax <RecordName>.

the calling Step resumes control of the processing. and continues processing at the next Step in the Section. you will need to define both AE_APPLID and AE_SECTION on your state record. and control returns to the calling Step. BREAK MAIN STEP01 Call Section1 STEP02 Section1 STEP01 PeopleCode Break Exit(1). The On Return options are: Abort Break Skip Step The program issues an error and exits immediately. You enable a Dynamic Call by first having your program store different Section names in the AE_SECTION field and different program names in AE_APPLID field. SQL STEP02 STEP03 SKIP STEP MAIN STEP01 Call Section1 STEP02 Section1 STEP01 PeopleCode Skip Step Exit(1). If this is the last Step in the Section. The program exits the current Step and Section. SQL STEP02 STEP03 Dynamic Calls Rather than calling one specific Section. If you will only be using the section within one Application Engine program. The values you insert into these fields needs to be based on various conditions met within your program.Zero (0) tells the program to ignore the On Return action. This is called a Dynamic Call. You then create a Call Section Action that calls whatever Section name appears in the State record field by selecting the Dynamic checkbox. then only the AE_SECTION field must be on the state record. Sample: Page | 43 . The program exits the current Step. you can take advantage of the AE_APPLID and AE_SECTION fields in the State record to execute different Sections depending on the conditions a program encounters during runtime. If you want to be able to call a section in other Application Engine programs.

Else AE_STATEREC_AET.AE_SECTION= “MESSAGE2”. Handle the case when the user enters same values by giving proper messages.AE_SECTION = "MSG1" Else DYNCALL_SOA_AET.NUM2_SOA Then DYNCALL_SOA_AET.State record . End-If. PeopleCode Hint: If DYNCALL_SOA_AET.NBR = 15 Then AE_STATEREC_AET.AE_SECTION= “MESSAGE1”. Page | 44 .AE_SECTION = "MSG2" End-If.AE_STATEREC_AET PROCESS_INSTANCE NBR AE_SECTION Program = MYDYNM Section MAIN Step STEPM01 Action PCode If AE_STATEREC_AET.NUM1_SOA > DYNCALL_SOA_AET. Call Section MESSAGE1 MESSAGE2 STPEMM1 ATEPMM2 Log Message Log Message "Number equal 15" "Number not equal 15" Dynamic Call Activity 4 – Writing AE Program using PeopleCode Take 2 numbers as input and find out the greatest.

2 Testing and Debugging Application Engine Program During application development or production runs you may have a variety of program or system failures. Page | 45 . you have a variety of debugging tools to yield different levels of detail.3. To be able to dig into that execution. It is one of the first things that should be inspected to determine if your program terminated correctly and if not. to see if any clues as to the problem are recorded. • • • • Process Monitor Application Engine Trace File Application Engine Interactive Debugger PeopleCode Debugger 3.2.1 Process Monitor For programs run through the Process Scheduler. the Process Monitor keeps track of the status of the programs during and after execution. The Details hyperlink provides additional information about the program. The resolution of many of these problems will require you to troubleshoot your Application Engine program execution.

you can identify the cause of your problem. Message Log This Message Log will provide messages supplied by your program. Page | 46 . This can be useful if an incorrect program name was used.Parameter The Parameters hyperlink displays the command line that was used to execute the Application Engine program.

check the message log for messages from the Distribution Agent indicating that there were problems transferring files to the Report Repository. View Log/Trace When you click the View Log/Trace link. Page | 47 . You have the option of setting up your Application Engine trace files to store statement timings traces to a table. the run status of the process request remains Posting and the View/Log link is not visible. This report relates specifically to PeopleSoft Application Engine program performance. o • • The process request ran from a PeopleSoft Process Scheduler Server Agent that was set up using the Server Definition page with a distribution node. you will see the batch timings displayed here. displaying links that enable you to view the message log and trace file in a browser. When this is activated.View Locks If you use any temporary tables in your program. The process must have a run status of Successful. and the report and log files were successfully posted to the Report Repository by the Distribution Agent. they will be listed here during execution. o If the report hasn't been transferred to the Report Repository. 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. Batch Timings The Batch Timings report contains a set of statistics that system administrators can use to tune the system to gain better performance. a new browser window opens. You must have also selected to transfer log files to the Report Repository when you set up the preferences on this page. If the status of the request remains Posting.

Temp. and Restarts. The name of the trace file will depend upon whether or not a process instance number has been specified for your process run. Page | 48 . Same as Step.2 Application Engine Trace File For processes running on a Windows workstation. the Do level and the statement type. Table Writes the details of the temporary tables used to the trace file – we will see this in action in both the temporary tables chapter and the performance tuning chapter later in the class.2. ROLLBACKs. This procedure is only valid when you are running the Application Engine program from the development environment or through a command line on the client.3.AET The trace files are placed in C:\Temp\PS\<database> directory. plus reports formatted SQL including COMMITs. along with a timestamp. Step Reports each step name that is executed.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>. processes SQL Ded. Process Instance Without a Process Instance Name of File AE_<Date/Time_Stamp>_<OS_PID>. you can set your trace options in the Configuration Manager.

The Application Engine debugger is turned on in the Configuration Manager. etc. you’ll enter an interactive state in which you can set break points. When you run your application. First click on the Trace tab and turn off the Statement Timings. Click on the Profile tab.Statement Timings (file) Initiates the AE timings trace. Page | 49 . Statement Timings (table) DB Optimizer (file) Activity 5 – Run AE Program using Trace on Run the delivered AE program PER099 with trace on and see the trace file. • • • Open the Configuration Manager. • Click on the Edit push button. which monitors the execution timing of each statement and is written to the bottom of the AE Trace file. This option writes the Statement Timings traces to a table so you can store historical data in the database and do custom reporting. The DB Optimizer trace reveals the execution/query plan for the SQL that your Application Engine program generates. issue COMMITs. look at the State record. Application Engine Debugger The Application Engine’s internal debugger can be used while running on the client or when running directly on the server—outside of the Process Scheduler.

enter “?” at the prompt. This option performs a rollback on the current unit of work in the debugging run. Debugging Options Option Quit Description Enter Q. Click OK to save the new configuration. At the Application Engine Debugger prompt. To see a list of the available debugging options. Enter the letter that corresponds to the option you want to engage. • • Turn the debugger on and click OK. This option is valid only after one step has completed and another has Exit Page | 50 . Debug Disable Restart Turning this option on will cause Application Engine to run in debug mode every time you invoke Application Engine in 2-tier. L. 2. After setting the Application Engine Debugger you need to 1. and it ends the debugging session. enter a command to enables a debugging option. Have some work committed and some uncommitted. Then. Quit is useful for testing restart. Each command is represented by a single letter. Execute the Application Engine program to debug. terminate the program at that point and roll back the pending work. such as X. or M. You want to make sure the program restarts from the point of the last successful commit. you will find the Application Engine options.On the Process Scheduler page. It effectively terminates your Application Engine program. This option will disable restart for all Application Engine programs run in 2-tier.

Executes the current step to completion and stop at the next step in the current section. By default. Suppose the previous steps did not set a value correctly. Enter L.Option Description not already begun. to use your database query tool to check the data in your database. you go to the next step in the current Commit Break Look Modify Watch Step Over Page | 51 . You can also specify a specific field name on the state record in the Field Name prompt. As with the Look command. The behavior depends on the current level or the program. the program stops when the value of the field changes. You start at the step level. When the program reaches the breakpoint. you engage the Look option. Use this option as an alternative to Quit. and List. To look at all the fields in the state record. make sure that you have entered B first to specify the break option. you can specify options for Set. You must specify the state record at the Record Name prompt. It is not valid once you reach the action level. However. the default state record as specified in your program properties appears with the brackets. It is not valid once you reach the action level. leave the asterisk (*) within the brackets unchanged. but it also commits the current unit the program has already completed. When you specify a field as a watch field. Unset: Enter U to remove breakpoints previously set. When you enter this command. This enables you to give your program some help in the debugging or testing phase. Enter S. Similar to the Break command. You can use this option. Breakpoint options include: Set: Enter S to set a breakpoint location. Enables you to modify the value of a state record value for debugging purposes. and then can step into the action level. If you are at the step level and use step over. use this option. you must specify the appropriate state record (if you are using multiple state records). Enter W. Unset. and you must specify one field. If you just enter L from the main command prompt. but you can specify other sections or steps by overriding the default values that appear in the brackets. Enter B. The breakpoint location defaults to the current location in the program. you may want to see how the rest of the program would perform if the appropriate value existed in the state record. To commit the current unit of work in your program. for example. Enter M. Sets a breakpoint. it temporarily halts execution to enable you to observe the state of the current process. It is valid only after a step has completed and before another has already begun. Enter C. You can modify only one field at time. Enables you to observe the values currently in the state record associated with the program you are debugging. List: Enter L to list breakpoints. Exit ends the program run and the debugging session. This option can be helpful when testing your restart logic.

For instance.Option Step Into Step Out of Description section. Enter R. This command forces the program to stop again after the next commit. skipping over all actions (including any call sections). and you’ve examined its current state. you will need to create a process definition and a component designed to control the runtime parameters. At the step level. If you are at the action level. Resumes execution of your program after it has stopped. Use this option to observe a step or called section in a more granular level. if the current action is a call section. Enter O. At the action level. or when the program runs to completion. With this command. At the action level. If the section is MAIN and is not called by another section or step. returns to the calling section or step. By using this option and checking the state record at each stop. Step Into acts the same as Step Over. After you’ve stepped into a step or called section. Step Out of returns to the calling section or step. because there is no deeper level in which to step. the behavior depends on the level. or if the program is at the end of a section. This is a helpful command when you have breakpoints set. you can easily isolate problem SQL or PeopleCode. This is a good option to use when observing your commit strategy and how it will affect a restart. use the Step Out of option to run the rest of the current step or called section and stop. you can check each SQL statement and stop. Step Out of completes the remaining steps in the current section. Enter I. For other action types. 3. you can use the Go command to resume the execution of the program. the behavior of Step Out of depends on the current level of the program. then Step Out of behaves the same as the Go option. After the program has stopped at a specific location. step over executes the current action and stops at the next action in the current step. Process Type Page | 52 . Enter G.3 Application Engine Process Definition For each Application Engine program that you want to process via the process scheduler. and stops at the next action in that step. Step Out of completes the current step and stops at the next step in the current section. or at the next step in the current section. Go Run commit to Activity 6 – Run AE Program in Debug mode Run the AE program created as part of Activity 3 in debug mode and use the various options. As with the previous step options. you can step into the action level and stop before the first action in the step. it only stops at the next breakpoint or watch field. PeopleSoft provides standard records and pages from which to clone. At the step level. the program won’t stop at a step or action. Step Into takes you to the first step in the called section. As with Step Over.

Navigate to the Process Scheduler Manager and search for the Process Type Definitions that start with A. depending on the target operating system and database platform. parameter list. You will notice that we have both Application Engine and Application Engine Generic Test types. and you can vary these global parameters as needed. This means the information doesn't need to be duplicated for each Process Definition of the same type. working directory. Page | 53 .The primary purpose of the Process Type Definition is to globally define the command line. You will also notice that there are separate definitions for each database platform as well as operating system. Open the Process Type Definition for Operating System used in the training and Database type used in the training. and other general parameters.

Command Line points to the executable program PSAE. The predefined meta-strings must also be enclosed in a set of double percent signs. it is assumed to be a serverbased environment variable. in-line bind variables.EXE. The parameter list follows the same definitions as we saw for the command line. Currently this option is applicable only to Application Engine process types that complete with a run Page | 54 . Parameter -CT -CD -CO -CP -R -I -AI Variables (metastrings) %%DBTYPE%% %%DBNAME%% %%OPRID%% %%OPRPSWD%% %%RUNCNTLID%% %%INSTANCE%% %%PRCSNAME%% Description Database Type Database Name User ID User Password Run Control ID Process Instance Process Definition Process Scheduler uses a number of variables during run time. if Process Scheduler encounters a string enclosed inside a double set of percent signs. Restart Enabled enables a process request to be restarted from Process Monitor. The variables are denoted by the %% and are retrieved from the system at run time. These are in the form of metastrings. it first compares the variable name with an internal list of predefined metastrings. The working directory is only applicable to the Client and Windows NT servers. Enclose all server environment strings within a double pair of percent signs: %%TOOLBIN%% Parameter List contains the string of command line variables passed to the executable. When processing a request. a PeopleSoft API program to run Application Engine programs. or client/server variables. Working Directory points to the directory containing the database drivers. If the variable name is not one of these meta-strings.

Process Definition For every Application Engine program that you want to run.status of Unsuccessful. you select which process types the Process Scheduler Server Agent is allowed to process for load balancing. if you are defining an Application Engine program named MYTEST. This name must match the program name of the process you are defining. (via the Component) Identify WHO has security access to run it. (via the Process Group. When you set up a Process Scheduler Server definition. Process Type When you define a process. (The Process Definition must be the exact same name as the Program. The process definition must have the same name as the Application Engine program. you assign it to a Process Type. Identify the TYPE of Process to be run (via the Process Type) Identify the PROGRAM name that you are running.) Identify WHERE the Program can be run from.) 3. A Process Definition serves four primary purposes: 1. For example. 2. Another restriction regarding the ability to restart a process has to do with a user's security profile. Process Name Description Page | 55 . Displays in Process Scheduler Request page and is aimed at the user. you will need to define a process definition. Restart is only allowed if the user can currently update a request (Cancel or Delete). 4. you must define the process name as MYTEST.

Recurrence Name Component Process Group Page | 56 . Otherwise. so this checkbox will be on.Priority This defines the relative priority to determine which process to initiate first. The “family” of processes to which this process belongs is a logical collection of programs and reports needed for a particular job function. This field is case sensitive. if multiple processes are queued to run on a given Process Scheduler Server Agent. If you choose an existing group. If you create a new Process Group. The component in the online system where the Process Definition will be accessible in the Process Request page. Only active if the run location is set to server. you will have to give access to users through Maintain Security. Only active if the run location is set to server. If you add a recurrence name here. leave it blank and the task will find an available Process Scheduler Server Agent to run on based on the Process Type. Previously defined intervals set up for processes to run. Application Engine is API aware. users that have access to that group will immediately have access to this process. It will override the recurrence provided on the Process Request page or in ScheduleProcess PeopleCode function. this process will use this recurrence every time you run this process. API Aware Process Definition Options Server Name Enter a Process Scheduler Server name if you want to restrict this process to run on a specific Process Scheduler Server Agent.

6. 4. 5. Process Security Once the standard security for accessing the pages has been activated you need to make sure that your user can run the process by making sure that they are attached to a permission list that is linked to the process group you put the process into. you will need to test running the Application Engine program from the new run control page. If you have unique requirements. Build the record: If you created a new run control record. Determine Run Control Record: For your application. you will need to create a new run control page. then you will need to build the record. you may be able to use one of the PeopleSoft delivered run control records. The information needs to be coded into your Application Engine program to access the data from your run control page. Once you have completed the setup. we are logging in as user PS. Page | 57 . 7. the PeopleSoft delivered run control pages. If you have created a new run control record. Place the run control page on a component: Place the run control page that you will be using with your Application Engine program on a component. 3. you may be able to use one of 8. Use registration wizard to add the component to a menu. The permission list that we use for all of the process access is found on the users general tab under the Process box. 2. In this course. register component in portal and set security. Design: The design of your Application Engine program will determine the controls and parameters that will be defined on your run control. The process definition will associate the Application Engine program with the component that was set up in step 6. Create Process Definition: Create a process definition that has the same name as the Application Engine program.Steps to add Application Engine Process 1. PS is a member of several roles and hence several permission list. Determine the Run Control Page: For your application. The process group will be used to enable users to run the program. you will need to create a new run control record.

Page | 58 . Process groups are collections of Process Definitions that you create using PeopleSoft Process Scheduler. Users can run only those processes through Process Scheduler that belong to process groups assigned to their role. After being created in Process Scheduler. you add process groups to permission lists on the Process Group Permission page.Process Group Permission The Process Groups page lists the various process groups associated with a Permission List.

Process Profile Permission PeopleSoft Process Scheduler security involves more than just adding a few process groups to a permission list. The process profile definition (defined in Process Scheduler) determines the default Process Scheduler settings for a user. Page | 59 . You also need to specify to what capacity a role (or set of users) can modify certain Process Scheduler settings.

a page may be "frozen" until the online process returns the necessary results. you only use this technique during testing or if you need to manually restart the program. PeopleTools Process Scheduler Manager is a centralized tool that enables application developers. Usually. you would use the command line. Page | 60 . You invoke programs that run in this mode using Process Scheduler or the Application Engine Process Request Page.4. When the program is called synchronously. Manual. For instance. Using the PeopleSoft Internet Architecture (PIA).exe LOGON RETRIEVE AE PROGRAM DEFINITIONS ISSUE AE PROGRAM SQL System Catalog Tables PeopleTools Tables Application Tables EXECUTE AE CONSTRUCTS PEOPLE CODE PROGRAM CALLS Executing Application Engine Program with Process Scheduler PeopleSoft's Process Scheduler will maintain status of your executing program and execute your application asynchronously from the initiation process. system administrators. To execute an Application Engine program in manual mode. This is the most typical mode of execution. typically get executed from a page with the CallAppEngine PeopleCode function. you can invoke Application Engine programs by using any of the following methods: • Batch. no COMMITs are issued until the program completes. Application Engine programs that execute online. and application users to manage PeopleSoft batch processes. • • Batch Asynchronous Process Scheduler Process Scheduler Request Application Engine Process Request page Online Synchronous CallAppEngine PeopleCode Push button Manual Command line Bat file PS Database PSAE. you can access a list of processes through a Web browser and schedule a process request.1 Application Engine Program Execution Depending on your implementation. Online. Batch mode is also referred to as asynchronous execution meaning that it runs independently in the background. Such online processes are synchronous meaning that subsequent processes wait on the results.

statereclist ]). There can only be as many record objects in statereclist as there are state records for the Application Engine program. CallAppEngine CallAppEngine starts the Application Engine program named applid. PSSAMSRV. etc. where and when reports were printed. Code a ''CallAppEngine"' to your Application Engine program.) Jolt SQ L Database Server HT ML Process Operator Server Process Type PROCESS_ORD2 PTTRN PSNT APPLICATION ENGINE Scheduler Server Status Success PeopleSoft Web Server Process SQL PSPRCSRQST API Code API Code (PSNT) Client Process Server Process Developing for Synchronous Program Execution with a 'Command' Pushbutton 1. MessageBox MessageBox is a PeopleCode function used to display a message box. to your page. The syntax is: CallAppEngine(applid [. Process Monitor enables you to monitor the important details of PeopleSoft batch processes. and what command-line parameters were passed to third-party programs with which Process Scheduler Manager interacts. The syntax is: Page | 61 . In the Push Button Properties select Pushbutton Type as Command and select the Record Field that has the PeopleCode. Where statereclist is list of record objects in the form: &staterecord1 [. The following example helps to illustrate the physical relationship between the basic components of the Process Scheduler in the PeopleSoft Internet Architecture. Create a Record with a field into which you will code 'FieldChange' PeopleCode. Workstation Web Server Application Server PeopleSoft Application Server (PSAPPSRV. Add a Push Button 3. This is a way of starting your Application Engine programs synchronously from a page. Additional record objects will be ignored. &staterecord2] . 2. .You can schedule processes to run locally on a client workstation or remotely on a database server without having to exit the PeopleSoft system. . And once a scheduled process begins. such as where certain programs ran.

MessageBox(style. This also allows separation of development of the Application Engine program from its associated pages. message_num. When a program abends. end users (or system administrators) will perform a Restart from the Process Monitor. Microsoft. Page | 62 . Oracle. Many developers include the command line in a batch file to launch a program they are developing or testing. This way. If needed.5. you can locate all of the specific program/process information from the Process Monitor on the Process Request Detail dialog. • Development/Testing.. See the complete list in section 4. a system administrator might restart the program using the command line. message_set. etc. Executing Application Engine Program with a windows command script In some cases. You can set up the command line to debug. paramlist]) where paramlist is an arbitrary-length list of parameters of undetermined (Any) data type to be substituted in the resulting text string.. param2]. this method is typically used in the following situations: • Restarting. Description Database platform (e. in the form: param1 [. they can quickly execute the batch file as needed. Debugging.g. To debug a program with a Run Location of Server. you may want to invoke an Application Engine program through the command line. you can log into the server (using Telnet. which offers an alternate method of invoking the Application Engine debugger without turning it on for all programs executed through the client. for example) and invoke the program from the command line. title.exe resides listed below are the minimum parameters that are required. • In addition to the path where PSAE. DB2.) Database name Logon ID Password Run Control Application Engine program Parameter -CT <dbtype> -CD <database name> -CO <oprid> -CP <oprpswd> -R <run control id> -AI <application id> There are additional parameters that can be added for tracing and debugging. default_txt [. Normally. For instance.

asynchronously. For batch process there can be potential performance improvements by splitting the data to be processed into groups and simultaneously running multiple instances of your program to deal with different groups of data. Uses the Batch/Dedicated Temporary Table pool. Can be designed for parallel execution for performance. Each invocation of your program would have to allocate an unused temporary table. PeopleSoft 8 introduces a Temporary Table record type definition. For Application Engine programs. This could create unpredictable results since the different instances of the code would be issuing Deletes. You are able to define a record and set its Type to Temporary Table. it is very likely that multiple instances of the same program can be running in parallel. and/or Updates unsynchronized with each other. and at random times. Potential for simultaneous execution. mark it as ‘in use’. they introduce a significant risk of data contention and deadlocks on common tables and/or temporary tables. Application Engine programs are designed for two types of execution and each has its own pool of Temporary Tables: Online Invoked by CallAppEngine from PeopleCode. so each execution of your Application Engine program will be given access to its own copy of the Temporary Table for its exclusive use.2 Temporary Table Since Application Engine programs run in batch. Additionally." Using Temporary Table for parallel processing The ability for multiple instances of the same program to run simultaneously is called parallel or concurrent processing. When batch programs begin running simultaneously. it does Temporary Table management for your Application Engine programs. synchronously. If you have a program that uses a temporary table and is invoked multiple times. Run quickly.4. With this feature. and within that pool some tables are dedicated to particular programs. meaning they are "shared. Uses the Online Temporary Table pool. Restartable Page | 63 . 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. When the program ends the table will be returned to the pool of Temporary Tables. By doing this the PeopleSoft Build process will build multiple uniquely named copies of your Temporary Table as a pool. that single temporary table could be used concurrently in multiple executions of the code. You could solve the problem by creating multiple temporary tables as a pool of tables. Run for longer amounts of time. and some instances are undedicated. Not Restartable Batch Invoked through the Process Scheduler. and at scheduled times. You can code your program with supplied meta-SQL. use it and release it back to the pool when you are through with it (for each Application Engine program you write). you have a pool of temporary table instances. Inserts.

• The Temporary Table Instance (Total) specified on the PeopleTools Options page. Build. • Plus the sum of all instance count values specified in all of the Application Engine programs that use that temporary table. If you opt 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. This will set the basic Temporary Table Online pool based on the PeopleTools Options specifications. even if the sum exceeds 99 for a particular Temporary Table. Set the Temporary Table Online pool. When all instances of a Temporary Table are in use and the Temp Table runtime options are set to "Continue. Page | 64 . the number of temporary tables that can be used online (CallAppEngine) is established. In the PeopleTools Options page." PeopleTools will insert rows into the base table using PROCESS_INSTANCE as a key. Application Designer builds the Temporary Table instances at the same time it builds the base table for the record definition. Application Designer only creates a maximum of 99 Temporary Table instances. Define your Temporary Tables by defining and saving your Temporary Table records as type Temporary Table. Current Object) and the Record Type is Temporary Table. 2.Steps to Implement Parallel Processing 1. When Application Designer builds a table (as in. Application Engine expects Temporary Table records to contain the PROCESS_INSTANCE field. it determines the total number of instances of the Temporary Table to build based on sum of the following two items. PeopleSoft recommends that you insert the PROCESS_INSTANCE field as a key on any temporary tables you intend to use with Application Engine.

This will build the necessary Batch temporary tables into that record’s Temporary Table pool for use at execution time. 5. Build /Rebuild your Temporary Table record. 3. Page | 65 .There are 2 fields that are used in connection with the temporary table instances. These 2 values should always be the same except for EPM. Assign Temporary Tables to your Application Engine program in its Program Properties. For example. with three Application Engine programs using a variety of Temporary Tables with different Instance Counts. 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. Set Temporary Table Batch Pool by setting the instance count in the program properties. setting the appropriate number of Instance Counts and Runtime option. 4. Temp Table Instances (Total) and Temp Table Instances (Online).

you need to use: %Table(record) You can reference any table with %Table. the Select would be resolved with the following: Select PROCESS_INSTANCE. If so. when Application Engine resolves any %Table. and each program instance inserts the rows from the source table into its assigned temporary table instance using %Table. so that Application Engine can resolve table references to the assigned Temporary Table instance dynamically at runtime. then Application Engine uses the base table instance (PS_recname) by default.TEMP_COL1. Once each program instance gets matched with an available Temporary Table instance. To reference a temp table (Online or Batch). Run control parameters passed to each instance of the MYAPPL program enable it to identify which input rows "belong" to it. for the first instance started. Multiple Program Instances Running against Multiple Temporary Table Instances The Application Engine runtime program invokes logic to pick one of the available instances. Regardless of whether %Table is in PeopleCode SQL or in an Application Engine SQL Action the program uses the same physical SQL table. then Application Engine substitutes the chosen table name. the %Table meta-SQL construct resolves to use the corresponding Temporary Table instance. but only those records defined as Temporary Tables get replaced by Application Engine with a numbered instance of a Temporary Table from the Temporary Table pool.AE1 Program Properties Temp Tables Instance Count 4 TX TY TZ TX10 The sum of the Instance Counts TX9 TX8 TX7 TX6 TX5 TX4 TX3 TX2 (Total) AE2 Program Properties Instance Count 3 TX TY PS Options 3 3 AE3 Program Properties TX1 TX Online (Online) Instance Count 0 TX 6. For batch/dedicated Temporary Tables. For example. Code %Table meta-SQL as references to Temporary Tables in your Application Engine program. If there are no more batch/dedicated instances available.TEMP_COL2 from PS_MYAPPLTMP01 Page | 66 . it checks an internal array to see if a Temporary Table instance has already been chosen for the current record.

PS_MYAPPLTMP1 MYAPPL1 First 500. commit. 4. Set-Based programs tend to scale in a geometric manner. This includes those instances in which row-by-row processing seemed like the only alternative. the PROCESS_INSTANCE is required as a high-level key. or sets. the real secret to gaining outstanding performance with Application Engine is to employ a technique called Set Processing. In an overwhelming majority of cases. The Temporary Tables are truncated automatically when they are assigned to your program. Advantages of Set Processing In most situations encountered with PeopleSoft applications. In such a case. determines if it meets a given criteria. you only select those rows that meet the filtering criteria and then run the rule once against all the affected rows. and so on. You can perform additional deletes of Temporary Table results during the run. perhaps 95%. Note: The only SELECT statements used in Set Processing appear in sub-queries of an INSERT or UPDATE statement. apply rule x to row.000 Rows of Affected Data Clear Temporary Tables (%TruncateTable) You do not need to delete data from a Temporary Table manually. With Row by Row Processing you follow a repetitive loop that selects a row. Set Processing performs significantly better than its row-by-row counterpart for "reasonable" batch processing volumes.3 Set Processing Although Application Engine achieves high performance while processing row-by-row programs. • Improved Performance.000 Rows of Affected Data PS_MYAPPLTMP2 MYAPPL2 Second 500. Since the data never leaves the database engine (whether or not it remains in the same table). but you will need to include your own SQL Action that does a %TruncateTable. With Set Processing. The bulk of the performance gain lies in the fact that the processing occurs in the database engine as opposed to in the Application Engine Program. Row- Page | 67 . Set Processing can be implemented to improve performance. Set Processing uses SQL to process groups. of rows at one time rather than processing each row individually. The rule that you are applying will use an UPDATE or INSERT/SELECT SQL statement. select next row. update row. if so. you effectively eliminate the network round trip and database API overhead required to pull the data into the application program and then insert the results back into the database. then Application Engine performs a delete by process instance instead of performing a truncate. If the shared base table has been allocated because no batch/dedicated instances were available. 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.

especially in regard to date. 4. fixing. SQL offers more immediate results. This enables you to write and tune SQL statements before you try to incorporate them into an Application Engine program. Database platforms can have different syntax rules. Set Processing is important with Application Engine because Application Engine has built in checkpoint/restart capabilities. For example. the Application Engine overhead becomes less of a factor in the overall program. and then recompile and re-link the program. Easy Maintenance. modify each line of code. to join two tables based on their common keys. Suppose your application logic is in set-based SQL rather than COBOL. • • Activity 7 – Write AE Program using set processing Re develop the AE program written as part of activity 3 using set processing. you take advantage of the SQL processing engine on the database rather than placing the processing burden and overhead on the application executable. In addition. it’s just a matter of modifying the SQL or inserting the new “chunk”. As a result. if any. designed to replace relational database management system (RDBMS)-specific SQL syntax with a common syntax.AE_APPLID AND ABC. changes. set-based programs will reap even more performance gains. If you need to make a fix or add an enhancement to SQL. and so on. you can work around syntax differences using PeopleSoft meta-SQL. as the RDBMS systems get more sophisticated.by-row processing scales in a more linear manner. When you encounter higher volumes. With set-based processing. you first need to identify all the lines of code affected. PeopleSoft meta-SQL enables you to dynamically generate portions of SQL code. Maintenance activities include tuning.4 Meta-SQL You can write SQL within PeopleSoft Application Engine. the data still travels through a variety of API layers. Since Application Engine records the status of a program run. And. Leveraging the RDBMS. there is an avoidable degree of overhead associated with each Application Engine SQL statement that gets executed. PSAESTEPDEFN XYZ ) At runtime. Even if the batch server and database engine are on the same physical machine. and other numeric calculations. • Minimized (PeopleTools) SQL Overhead. which PeopleSoft Application Engine supports. row-by-row processing can sometimes become overwhelmed. you would tend to use fewer Application Engine SQL Statements that each processed more data than the statements executed in row-by-row processing. In short.AE_APPLID = XYZ. With COBOL. Meta-SQL is a set of predefined terms (meta-strings).AE_SECTION = XYZ. the function would be expanded into the following: ABC. If you use Set Processing.AE_SECTION Page | 68 . PSAESECTDEFN ABC. Using a row-by-row approach and pulling data into the program for each transaction degrades performance regardless of where the program runs. time. adding enhancements. use the following meta-string: %Join(COMMON_KEYS. or you can copy SQL statements into Application Engine from any SQL utility with few. Generally.

]fieldname[.STATIC ]) %ExecuteEdits The %ExecuteEdits construct is Application Engine-only meta-SQL. PeopleCode Reference. the entire function will be replaced with a character string. delimited by Page | 69 . Meta-SQL. At runtime. field2.NOQUOTES][. The %Bind function can be used anywhere in a SQL statement. %List The %List function expands into a list of field names. . join_recname [ correlation_id1]. with the exception of LONG_CHAR or IMAGE fields.DBTYPE AND ABC. to_recname [ correlation_id2] [. The INSERT column list is composed of all the fields in the specified insert_recname. field1.NOWRAP][. For a full list and description refer to PeopleSoft PeopleBooks PeopleCode.DBTYPE = XYZ. .]) %InsertSelect The %InsertSelect function will generate an INSERT statement with a SELECT for you. field2].. or PeopleCode—not even Application Engine PeopleCode. You can’t use it in COBOL. You must specify all the select records before you specify any over ride fields. %Bind. This function allows Application Engine to support data dictionary edits in batch. select_recname [ correlation_id][. Syntax: %ExecuteEdits(<type>. It does not generate the FROM statement.) %Join Use the %Join function to dynamically build a WHERE clause joining one table to another. is used to retrieve a field value from a State Record. ]insert_recname. override_field_list]) where override_field_list is an arbitrary-length list of fields to be substituted in the resulting text string. SQR. recordname [alias][. in the form: field1 [. Syntax %Join({COMMON_KEYS | COMMON_FIELDS}. Syntax %InsertSelect([DISTINCT. Syntax: %BIND([recordname. . .AND ABC. . override_field = value]..EFFDT The following table lists the Meta-SQL available to use in your Application Engine applications.EFFDT = XYZ. Meta-SQL %Bind Description The Application Engine function. select_recname_n [ correlation_id_n]] [.

fieldN] %SelectInit This meta-SQL construct. and you use the %BIND construct to retrieve or reference the variables. The basic syntax for %TruncateTable is %TruncateTable(table name) Page | 70 . then %Table resolves to that instance of the temporary table %SQL %Table %TruncateTable The %TruncateTable meta-SQL construct is functionally identical to a DELETE SQL statement with no WHERE clause. %SelectInit reinitializes the buffers. is identical to %SELECT barring the following exception. Application Engine is replaces it with the specified SQL object. In the case of a %SELECT and no rows are returned. you need one in the Flow Control Actions as well as one in the SQL Actions that contain a SELECT. The %Table function returns the SQL table name for the record specified with recname. statefield2]…[. You use the %SELECT construct to pass variables to the State Record. the State Record fields retain their previous values. you use %SELECT to pass values to the State Record buffers. The syntax for %SELECT is: %SELECT(statefield1[. This allows commonly used SQL text to be shared among Application Engine and PeopleCode programs alike. but it is faster and requires less resources on databases that support bulk deletes. In other words. If the SELECT returns no rows. statefieldN]) SELECT field1[. recordname [ correlation_id]) %Select A %SELECT is required at the beginning of any and all SELECT statements. The %SELECT function identifies the State Record fields to hold the values returned by the corresponding SELECT statement.Meta-SQL Description commas. When you use %SQL in a statement. %SelectInit. For example. If you’re familiar with COBOL this construct is an enhanced version of the COBOL meta-SQL construct with the same name. field2]…[. Which fields are included in the expanded list depends on the parameters passed to the function. Syntax: %List({FIELD_LIST | ORDER_BY | SELECT_LIST | NONULL_FIELDS | SELECT_LIST_NOLONGS | FIELD_LIST_NOLONGS}. The basic syntax is as follows: %Table(recname) If the record is a temporary table and the current process has a temporary table instance number specified.

The parameter dtt is either a Datetime bind variable or a string literal in the form: MM/DD/YY[YY] hh:mm:ss. Expands to platform-specific SQL for a DateTime value being sent to the database server.ssssss [{AM|PM}] %DateTimeOut(datetime_col) Where datetime_col is a Datetime column. Expands to platform-specific SQL for the current date in the SELECT clause of an SQL query. expands into platform-specific SQL syntax for the date. Where dt is a date column. or when the current date is passed in an INSERT statement. causes dt to be converted from its platform-specific format to PeopleSoft format when the value is received from the database server. causes datetime_col to be converted from its platformspecific format to PeopleSoft format when the value is received from the database server. causes time_col to be converted from its platform-specific format to PeopleSoft format when the value is received from %CurrentDateOut %DateIn(dt) %DateOut(dt) %DateTimeIn(dtt) %TimeIn(tm) Page | 71 . Expands to platform-specific SQL for a DateTime value being sent to the database server. We intend that you use this construct after your program has inserted large amounts of data into a temporary table that will be deleted before the end of the program run. The parameter tm is either a Time bind variable or a string literal in the form: hh:mm:ss.Meta-SQL %UpdateStats Description Application Engine replaces this meta-SQL construct with a platform dependent SQL statement that updates the system catalog tables used by the database optimizer in choosing optimal query plans. This saves you from having to use "dummy" seed data for the temporary table and having to update statistics manually.ssssss [{AM|PM}] %TimeOut(tm) Where time_col is a time column. %DateIn should be used whenever a date literal or Date bind variable is used in a comparison in the WHERE clause of a SELECT or UPDATE statement. Where dt is either a Date value or a date literal in YYYY-MM-DD format. The basic syntax for %UpdateStats is %UpdateStats(table name) Meta SQL Date and Time Functions Meta-SQL %CurrentDateIn Description Expands to a platform-specific SQL substring representing the current date in the WHERE clause of a SQL SELECT or UPDATE statement.

This is useful in those cases where you need to use a comma.the database server. when using %RunControl. It does not reflect the actual number of rows that meet the WHERE criteria. you need to code a %AsOfDate %Comma %LeftParen %RightParen %Space %SQLRows Page | 72 . This construct can be used in any Application Engine SQL statement. For example. Returns a quoted string containing the currently executing Application Engine Step name. as a parameter. Returns a left parenthesis. Returns a quoted string containing the “AsOfDate” used for the current process. the value can only be 0 or 1: row not found or rows found. Usage is similar to %Comma. and Do Until. Application Engine System (Meta) Variables Variable %AeProgram %AeSection %AeStep %JobInstance %ProcessInstance %ReturnCode %RunControl Description Returns a quoted string containing the currently executing Application Engine program name. In order to find the number of rows that meet the WHERE criteria. It is not affected by the program flow control Actions: Do When. to the %SQL meta-SQL function. respectively. regardless of whether there's a row in the AEREQUEST table. Regardless of where it’s used. Returns the numeric (unquoted) return code of the last SQL operation performed. Returns a right parenthesis. Usage is similar to %Comma. Returns a quoted string containing the current Run Control identifier. Do While. the semantic remains the same: "How many rows were affected by the last SQL action?" For SELECT statements. Returns the numeric (unquoted) Process Instance. Returns a comma. Usage is similar to %Comma. The Run Control ID is available to your program. Returns the numeric (unquoted) Process Scheduler Job Instance. but the underlying value is only affected by SQL Actions. but commas are not allowed due to the parsing rules. Returns a quoted string containing the currently executing Application Engine Section name. Do Select. you might use this if you wanted to pass a comma. Returns a single space.

type) or %CLEARCURSOR(ALL) When you use the %CLEARCURSOR function keep the following items in mind: • • • %Execute It must be located at the beginning of the statement. | /}… commandN{. Typically. For this function to work. [ALIAS. it is not valid for SQLExecs or view text. It can be the only function or command contained in the statement. and we intend that you use it when performing sequence-numbering processing. | /} By default. Application Engine expects a semi-colon to be used to delimit multiple commands within an %EXECUTE function statement. The Action must be SQL. You can instruct Application Engine to use a forward slash (/) delimiter instead by placing a forward slash inside the function parentheses.Application Engine Macros Application Engine Macro %ClearCursor Description Use the %CLEARCURSOR function to recompile a re-used statement and reset any STATIC %BINDs. By “number” field. you’d use it in place of a %Bind.]<CURRENCY_FIELD>) %RoundCurrency Page | 73 . The syntax is as follows: %EXECUTE([/]) command1{. step. and then increment (%Next) or decrement (%Previous) the value after the statement is executed successfully. The syntax for %RoundCurrency is: %RoundCurrency( <EXPRESSION>. The %ROUNDCURRENCY function rounds an amount field to the currency precision specified by the field’s Currency Control Field property—as defined in Application Designer’s Record Field Properties dialog. This meta-SQL is an enhanced version of the Application Engine &ROUND construct that appeared in previous releases. ]section. As with all Application Engine macros described in the current section. The proper syntax is as follows: %CLEARCURSOR([ program. you must have the Multi-Currency option selected in the PeopleTools Options page. The %EXECUTE function allows you to execute RDBMS-specific commands from within your Application Program. this construct is only valid in Application Engine SQL. These constructs use the current value of the number field as a Bind variable. we are referring to the numeric field on the State Record that you have initially set to a particular value (as in ‘1’ to start). %Next and %Previous This construct is valid in any Application Engine SQL Action. | /} command2{.

The default is 0. enter the appropriate server name. Parameter -CT <dbtype> -CD <server> -CD <database name> -CO <oprid> -CP <oprpswd> -R <run control id> -AI <application id> -I <process_instance> -DEBUG <Y/N> -DR <Y/N> Page | 74 . this option is valid but not required. INFORMIX. Required. This affects Sybase. or enter N to enable Restart. Corresponds to the type of database to which you are connecting. Enter the Process Instance for the program run.4. This parameter controls the Debug utility.5 Command Line Parameters Description and Values Required. (DR represents Disable Restart). and DB2. Required. and Microsoft SQL Server. for Microsoft SQL Server. Enter Y to indicate that you want the program to run in debugging mode. Enter Y to disable Restart. Required for Restart. Required for Sybase. However. Required. Enter the name of the database to which the program will connect. This parameter controls Restart. or enter N to indicate that you do not. Informix. SYBASE. Valid values are MICROSFT. Informix. which means Application Engine uses the next available process instance. DB2UNIX. Specify the Application Engine program to run. Enter the userid that is running the program. Required. Enter the password associated with the userid. Required. Enter the Run Control ID for this run of the program. For those platforms that require a server name as a part of the signon. ORACLE.

Application Engine reads the contents of the file and interprets the contents as if it were parameters entered on the command line. after Application Engine interprets the contents of the <parmfile>.txt Note: For security reasons. To enable tracing from the command line. Using this parameter. For example: Psae $temp/myparmfile. This option is intended mainly for the Windows NT and UNIX process Scheduler environment. Instance=0) DB optimizer trace to file DB optimizer trace to tables Page | 75 . you can disable the %UpdateStats meta-SQL construct. enter this parameter and a specific Trace value. it immediately deletes the <parmfile> -DBFLAGS -TOOLSTRACESQL <value> -TOOLSTRACEPC <value> Psae <Parmfile> AE Trace Options 1 2 4 128 256 1024 2048 4096 Trace STEP execution sequence to AET file Trace Application SQL statements to AET file Trace Dedicated Temp Table management to AET file Timings Report to AET file Method/BuiltIn detail instead of summary in report Timings Report to tables (ignored if Prcs. Use this parameter to enable the PeopleCode Trace If you submit a file to Application Engine as the first parameter in the command line. To disable %UpdateStats enter: -DBFLAGS 1 Use this parameter to enable SQL Trace.Parameter -TRACE <value> Description and Values This parameter turns on the Application Engine trace.

SQL Trace Options 1 2 4 8 16 32 64 128 256 512 4096 8192 SQL statements SQL statement variables SQL connect. not data) All other API calls except ssb Set Select Buffers (identifies the attributes of columns to be selected). disconnect. commit and rollback Row Fetch (indicates that it occurred. Database API specific calls COBOL statement timings Sybase Bind information Sybase Fetch information Manager information Message Agent information PeopleCode Trace Options 1 2 4 8 16 64 128 256 512 1024 2048 Trace instructions List the program Show assignments to variables Show fetched values Show stack Trace start of programs Trace external function calls Trace internal function calls Show parameter values Show function return value Trace each statement in program Page | 76 .

Sign up to vote on this title
UsefulNot useful