State Record In Application Engine Peoplesoft

Application Engines. PSAEAPPLDEFN: Table that stores Application Engine program definitions. PSAEAPPLSTATE: Stores application engine STATE records and a flag to indicate if the record is the default STATE record. PSAESECTDEFN: Application engine section information and also stores last user id to update a specific section. Application Engine new features in PeopleTools 8.57 4 Frameworks to get the most out of your PeopleSoft applications New features in Process Scheduler for PeopleTools 8.57. PeopleSoft Application Engine Rel 8.50 Topic 8: Using State Records Objectives Level Describe the function of state records Learner Create a state record Practitioner Modify Application Engine programs to use state records Practitioner Use meta-SQL in Application Engine. I could not find this else where and hence, I decided to build one myself – a complete list of PeopleSoft tables. Often a times when working on something like a PeopleSoft issue or a PeopleSoft upgrade, you feel the need to have a handly list of PeopleSoft tables. A state record is a PeopleSoft record that must be created and maintained by the Application Engine developer. Defines the fields a program uses to pass values from one action to another. Think of the fields of the Application Engine state record as the working storage for your Application Engine program.

1.It is a PeopleTool and It is used to develop batch programs oronline programs that perform the backed processing against the data.
2.It consists of the 2 distinct components .They are
Designer->Consists of the batch programs.
Run time Environment->To run and monitor the programs.
3.A program is a set of SQL statements.
4.It does not generate SQL or PeopleCode, but it executes SQL or PeopleCode asa part of program.
5.It is designed for batch processing where data must be processed without userinteraction.
6.AE resides on database server.
1.PS AE consists a set of processes to execute a given task and made up ofseveral elements.They are
i) Sections
It is a set of ordered steps that gets executed as a part of the program.Theexecution of the program starts with the section defined as MAIN.
ii) Steps
Steps are the smallest unit of the program that can be commited within aprogram.It is used to execute the a peopleCode
command or log a message with the step.When the section gets called, its stepsexecute sequentiately.
iii) Actions
Multiple actions can be within a step.There are 5 multiple actions they are
Do actions contain a SQL statements taht is designed to return the results onwhich subsequent actions depend.
It is equvalent to a COBOL perfrom statement.There are 4 types of Do actios theyare:
1)Do While 2)DO When 3)Do Select 4)Do Until.
It contain a single SQL statements.There are 4 types of SQL statements.They are
1)Update 2)Delete 3)Insert 4)Select

It provides an excellent way to build dynamic SQL, perform simple if/elseedits,set defaults and other operations that
don't require a trip to the database
Log Message:
Call Section:
It is used to call and insert an action in the progaram or outside program.
iv) State Records
It is a PeopleSoft Record that must be created and maintained by theApplication Engine developer.
This record defines the fields a program uses to pass values from one action toanother.
It can be either a Physical record or a work record, any no of sate records canbe assosiated with a program.
Physical state records must be keyed by process instance.
There are 5 types of Application Engine Programs.They are.
1.Standard->Normal entery point program.
2.Upgrade Only->used in PS Upgrade utilites.
3.Import Only->used by PS import utilites.
4.Daemon Only->A type of program which is used a daemon Process.
5.Transform Only->used to support Extensible stylesheet languageTransformations(XSLT).
1.PS AE provides a daemon process called PSDAEMON, that runs continously whenPS Process Scheduler is running and it is intended for running jobs.
2.It consists of a predefined set of conditions as events.When PSDAEMONschedules a process to handle an event when the conditions are true.
3.It allows only PS AE tracing at the step and SQL levels
1.Meta-SQL is a set of predefined terms designed to replace RDBMS syntax.
2.PS meta-SQL enables us to dynamically generate portions of SQL code.(EX;--2join 2 tables based on their common keys)
3.%select->It is ued to insert values of varibles in to sate record.
4.%bind->It is used to get values.

By using the SQLEXEC() function we can do the data manipulation (Insert,Updateand Delete).
SQLEXEC('select * from PS_JOB whereX.EMPID.vlaue=:1',abc,&emplid1')
The main draw back using this SQLEXEC() function is 'It will return onlyone value at a time'.
Note:-for more in detail draw backs about SQLEXEC,please go through the otherpost Reasons why PeopleSoft does not recomd SQLEXEC()'
Sate Records:
It is a working storage.
It is a physical record or derived work record
It passes values from section to section ,Action to Action and step to step.
We can use 'N' no of state records in a program.
It consists of Runcontrol ID and Process Instance ID.
It it is a physical record then process Instance ID must be keyed.
It maintains temporary data in AE programs for online processing.
State Record Properties
It is used to select any sate record from the list
Temp Tables
1.Select the temp tables tab.
2.It is used to get a temporary record.
3.When we enter any of the wild card character or the table full name and Clickon get list.Then it displays all the records containing temporary tables.
4.Select the necessary temporary table and click o add in to the list.
5.We can remove a particular temporary table by selecting it and click onremove.
6.Instance count is used to enter the no.of physical tables to be created foreach dedicated table for this program during the SQL Build procedure inPeopleSoft Application Designer.If we want to any program to run for 3 timesthen we should specify in the instance count.
7.If we select base version then it uses the temporary tables.
8.If we select Abort then the program exists with an error message.
Advanced Tab
1.Disable Restart
2.Application Library
3.Batch only
4.Messsage Set
5.Program Type (STD,Upgrade,Import,Daemon,Transform)

Restating an AE program

The Key feature of AE is Restart.
Sate record should be a physical record.When the system is processing a hugeamount of data (batch processing) and if there
occurs any failure through the environment then the restartable logic comes into picture.The cursor directly comes in to the checkpoint where the commit isset upand restarts the program from that point.
We can restart the program from the process request page.
AERUNCONTROL record saves all the information that is required for a program torestart.
File Layout's
1.It is used for file processing using INBOUND and OUTBOUND process
2.A File layout is acollection of records.
3.Works with hierarchical and non-hierarchical data
4.stored with _FLT
5.It enables us to do the following
-->Export and Import the data.
-->It uses Batch Process to perform large amount of data import and export.
-->There are 3 types of file formats.They are CSV,XML,FIXED.
6.It also facilitates to provide the transaction between PS systems and 3rdparty systems

Inbound Program

Reading from a FALT file and writing in to database
-->Open the flat file in READ mode
-->Read each and every line in a flat file and put them in a string
-->Split the data with separators and put it in an array
-->Insert the values in to the record by matching the field values in torecord.
Local record &rec
If & then
while &file.readline(&str);
&arr = split(&str,',');
&rec.EMP_ID.value = &arr[1];
&rec.EMP_NAME.value = &arr[2];
&rec.EMP_AGE.value = &arr[3];
Outbound Program
Writing from a Database to flatfile
-->Open the flat file in WRITE mode.
-->Use the %SELECT to select all the record field values.
-->Put the field values in a dummy record.
-->By using the dummy record field value write the files to FLAT file usngWRITELINE.
For i=1 to5;
&myfile.writeline('HI welcome to PS world');
A sample code to read a file using file layouts and insert data read into arecord

Local File &MYFILE;
Local Record &REC;
Local array of string &ARRAY;
Local string &FILE_DIRECTORY, &FileName;
&FileName = 'MY_FILE_NAME.txt';
/*open file for reading*/
&MYFILE = GetFile(&FILE_DIRECTORY &FileName, 'R',%FilePath_Absolute);
/*create record object*/
&REC = CreateRecord(Record.MY_RECORD);
&ARRAY = CreateArrayRept(', 0);
/*check if file is open*/
If &MYFILE.IsOpen Then
/*The SetFileLayout method is a file layout method. It associates a specificfile layout definition with the file object executing this method, providingeasy access to rowset data.(PeopleBooks)*/
If &MYFILE.SetFileLayout(FileLayout.FILE_LAYOUT_NAME) Then
/*read line into &STRING*/
While &MYFILE.ReadLine(&STRING);
&ARRAY = Split(&STRING, ',');
For &I = 1 To &REC.FieldCount
&REC.GetField(&I).Value = RTrim(LTrim(&ARRAY [&I]));
/* do additional processing here for converting values */
/*count rows inserted into record*/
&COUNT = &COUNT + 1;
/* do error processing - filelayout not correct */
/* do error processing - file not open */
We can run the AE in 3 way's
1.Application Designer -->RUN
2.Command Line -->PSAE.EXE
3.Process Scheduler.
Order of events in Application Engine
1.Do When
2.Do While
3.Do Select
4.People Code
6.Call Section
7.Log Message
8.Do Until


We have a process that generates an Export file. The following are some of the simple requirements for this process request.
  • There is a need to allow the customer to request this file at any time and to provide the File Name of the file.
  • If the file exists the process will fail with a status of 'No Success' so we will provide a Delete Flag for the requester to have the existing one deleted if found.
  • A header in the export file needs a Sequence Number from the requester


You can think of the state record as the record of assigned variables that exists for an single instance of an application engine execution process. Each execution will have its own record and can be unique to that process run. A state record is passed variables from the process request record commonly called the Run Control. There can also be fields on a state record to indicate process completion status or restart positions or any other useful information you'd like to store between executions or restarts. To be able to restart using previous state records you need to commit your state record to the database in a physical table. In many cases this is not required so a Derived record is used and will only exist in memory during that execution. In this example I'm going to demonstrate a very simply run control and state record where we can pass in variables like the desired file name for output.


Run Control

We are going to need two records the first is the Run Control which will be a physical table to store each user's values for this Application Engine run requests. It is an SQL table that must have two keys the RUN_CNTL_ID and OPRID. These fields are required because this table is a child of PRCSRUNCNTL which to my knowledge serves little purpose because the only other columns on the parent table are language codes. After this you can add any fields that you need to pass into your application Engine. In this example we are passing in FILENAME, SEQNUM and DELETE_FLAG

State Record

For the second record the state record we are NOT going to use a SQL table because we don't need to commit and retain process information after completion of this Application Engine process. So your record can be set to Derived which means it will only exist in memory during the execution process. This record must have a single key column PROCESS_INSTANCE. Add additional fields that your Run Control is passing to the execution process or Application Engine status flags you wish to set in your PeopleCode.
* Note: AE_APPSTATUS is just one example if a field which gives developers a way to flag the return status of this process. It's a way to flag the run as Success, No Success or Warnings using your own peoplecode.

Run Control Page

This page is where the customer requests the run of this Application Engine Process.
In this example I'm going to pass into my Application Engine process 3 variables. File Name, Sequence Number and a Delete Flag value. At any time in my application Engine I will have the ability to query a copy of these values stored on my state record during that instance of processing. The page is built by copying an existing Run Control page and this will ensure the correct Run Control sub pages are in place. These sub pages are what display the ID, Language, Report Manager, Process Monitor and Run button on your new page.State Record In Application Engine Peoplesoft
We are only making changes to the title and our custom Run Control fields in Yellow and we leave the subpage and Derived titles as is.


Peoplesoft app engineThe search page assigned to this Run Control component is the parent table PRCSRUNCNTL this means that a single Run Control ID can be used across all your different Run Control pages.

The table structure shows how the parent table links to each individual run control record and that run control record is copied into your Process Instance State Record during your run.Select

Application Engine

Peoplesoft App Engine Do Select

Now you are ready to put this to use in your Application Engine. First you need to open the properties of your App Engine and add your State Record.

To populate the values of your state record at runtime you need to have an SQL step at the very top of you Application Engine. This first SQL action will query your Run Control table with the requester's ID and Run Control ID and copy the fields with the same names to your state record. The follow step can be your first Application Engine PeopleCode process. This is where you can access your state record and to use the values passed in.

Oracle Peoplesoft Applications

Peoplesoft App Engine

Now that the State record is has your values they can be access in any of the PeopleCode used within the current Application Engine process. The following code will just display it in the log file but you can use the values in queries, properties, settings or generating a file with a specific name.

Peoplesoft Application Engine Trace