You are on page 1of 53

Application Engine Development, Execution & Debugging

Peoplesoft Examples - FSCM 9.2+ and PeopleTools 8.53+

Documentation related to Peoplesoft 9.2+ and PeopleTools 8.53+ for training, knowledge sharing and quick reference

Application Engine - Part 1 - Development & Execution


If I have to provide a training on Application Engine to my co-workers who have never
developed any Application Engine in Peoplesoft, I would use this blog.

Here I am going to describe how to develop a simple Application Engine program covering
Sections, Steps, Actions, State records, Meta-SQLs, etc. in their simple forms using a
simple example. We will discuss four ways to execute an Application Engine as well. Once
you have the basic idea, you will be able to grasp the detailed topics in an efficient
manner.

The example has been created and tested on the following software environment.
Peoplesoft Application: FSCM 9.2.005
Peoplesoft Peopletools: 8.53.09
Peoplesoft Virtual Machine Image id: FSCMDB-8309-PI005
Database: Oracle 11.2.0.3

In this example, we will copy two GL journals i.e. create copies of two journals with new
journal ids and dates. The major steps involved will be
1) Start the Application Engine Program.
2) Log a message.
3) Check if there is any journal specified in the in the detail run control record.
4) If there is no more journal to be copied, Go to Step # 9.
5) Read the next row from Run Control detail record for Business Unit, Journal Id, Journal
Date to be copied from and the Journal Id, Journal Date to be copied to.
6) Save the above Business Unit, Journal Id, Journal Date fields from the current run
control row to a temp/working table. (This table is going to be STATE record for the
Application Engine).
7) Copy the journal.
8) Go to Step # 3 for next journal to be copied.
9) This marks the completion of the Application Engine Completion.
Let us create a run control record with the following structure. The first 3 fields
OPRID, RUN_CNTL_ID and REQUEST_NBR are keys. Please go ahead and build the record as well.
Let us start building Application Engine program. In Application Designer select File and
New and select Application Engine. The following new Application Engine will be shown.

In the MAIN section, change description to "Copy Journals".


Save the Application Engine as AJ_COPY_JRNL.
Select Application Engine properties. Update the tabs as follows.
Updated step01 as "GoPrgMsg" and its description as "Log Program Begin Message".
Right Click on step "GoPrgMsg' and select "Insert Action". Right Click on the default
action 'SQL' and select "Log Message".
Right Click on step "GoPrgMsg' and select "Insert Step/Action". Click on the new step
GoPrgMs2 which was created under GoPrgMsg step. Change GoPrgMs2 as "ReadReq1" and its
description as "Read Next Run Control Request".

Under the Step ReadReq1, change the default action from SQL to Do Select and the
description to "Get new Journal to copy". Save the Application Engine.

Right click on the action Do Select and select View SQL option. Paste the following SQL
there.
%SelectInit(OPRID, RUN_CNTL_ID, REQUEST_NBR, BUSINESS_UNIT, JOURNAL_ID, JOURNAL_DATE,
NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_FREQUENCY )
SELECT OPRID , RUN_CNTL_ID , REQUEST_NBR , BUSINESS_UNIT , JOURNAL_ID ,
%DateOut(JOURNAL_DATE) , NEW_JOURNAL_ID , %DateOut(NEW_JOURNAL_DATE) , PROCESS_STATUS
FROM PS_AJ_JRNL_COPY_RC
WHERE OPRID = %Bind(OPRID) AND RUN_CNTL_ID = %Bind(RUN_CNTL_ID)
AND PROCESS_STATUS IN ( 'N' )
ORDER BY REQUEST_NBR

The %SelectInit is a special function for Application Engine. It will update (or insert if
not exists) the STATE record with the values selected from the run control. The STATE
record is used as working storage to save the values to be passed between various
steps/actions of the Application Engine.

Right Click on MAIN section and select Insert Section. A new section is created under MAIN
section. Change section name to COPYJRNL and its description to Copy Journal.

On the Do Select action in step ReadReq1 of MAIN section, Right click and select Insert
Action option.
Under the Step ReadReq1, for the new action just inserted, change the default action from
SQL to Call Section and the description to "Copy Journal". In the drop down for Section
name, select COPYJRNL.
So far the Application Engine program looks like the following.
Go to the section COPYJRNL. Right click and select Insert Step/Action.
Repeat the above 3 times.
In the section COPYJRNL, update the step names and descriptions as follows.
001 - step name = CPJRNLHD, Description = Copy Journal Header
002 - step name = UPDJRNLH, Description = Update Journal Header
003 - step name = CPJRNLLN, Description = Copy Journal Lines
004 - step name = UPDJRNLL, Description = Update Journal Lines
Go to the section COPYJRNL,
step CPJRNLHD, Right click and select Insert Action.
step UPDJRNLH, Right click and select Insert Action.
step CPJRNLLN, Right click and select Insert Action.
step UPDJRNLL, Right click and select Insert Action.
Now the section COPYJRNL should look the following.
Right click on SQL action of the step CPJRNLHD and select View SQL to open the SQL editor
for the action. Paste the following SQL there.
%InsertSelect(JRNL_HEADER, JRNL_HEADER, JOURNAL_ID = %Bind(NEW_JOURNAL_ID), JOURNAL_DATE =
%Bind(NEW_JOURNAL_DATE))
FROM %Table(JRNL_HEADER)
WHERE business_unit = %Bind(BUSINESS_UNIT) and journal_id = %Bind(JOURNAL_ID) and
journal_DATE = %Bind(JOURNAL_DATE);
This will insert the header using all fields from the journal_id specified but the three
fields business_unit, journal_id and journal_DATE will be picked up from the bind
variables we populated earlier.

Right click on SQL action of the step UPDJRNLH and select View SQL to open the SQL editor
for the action. Paste the following SQL there.
UPDATE ps_jrnl_header
SET UNPOST_SEQ = 0, JRNL_HDR_STATUS = 'N', JRNL_CREATE_DTTM = SYSDATE,
(FISCAL_YEAR,ACCOUNTING_PERIOD) = (
SELECT FISCAL_YEAR,ACCOUNTING_PERIOD
FROM ps_cal_detp_tbl
WHERE setid = 'SHARE' AND calendar_id = '01'
AND %Bind(NEW_JOURNAL_DATE) BETWEEN begin_dt AND end_dt)
WHERE business_unit = %Bind(BUSINESS_UNIT)
AND journal_id = %Bind(NEW_JOURNAL_ID)
AND journal_DATE = %Bind(NEW_JOURNAL_DATE);
Selection from PS_CAL_DETP_TBL is made to update the appropriate Fiscal_Year and
Accounting_Period for the Journal_date.

Right click on SQL action of the step CPJRNLLN and select View SQL to open the SQL editor
for the action. Paste the following SQL there.
%InsertSelect(JRNL_LN, JRNL_LN, JOURNAL_ID = %Bind(NEW_JOURNAL_ID), JOURNAL_DATE =
%Bind(NEW_JOURNAL_DATE))
FROM %Table(JRNL_LN)
WHERE business_unit = %Bind(BUSINESS_UNIT)
AND journal_id = %Bind(JOURNAL_ID)
AND journal_DATE = %Bind(JOURNAL_DATE);

Right click on SQL action of the step UPDJRNLL and select View SQL to open the SQL editor
for the action. Paste the following SQL there.
UPDATE ps_jrnl_ln
SET UNPOST_SEQ = 0
WHERE business_unit = %Bind(BUSINESS_UNIT)
AND journal_id = %Bind(NEW_JOURNAL_ID)
AND journal_DATE = %Bind(NEW_JOURNAL_DATE);

As of now, the Application Engine is complete and ready. If you are up to this stage,
you know the basic Application Engine development. Let us discuss Application
Engine execution. There are four ways to execute an Application Engine.
1) Executing through Process Scheduler.
2) Executing from Application Designer.
3) Executing from Command Prompt.
4) Calling from Peoplecode.

Let us discuss the Application Engine Execution in each of the four ways.

Executing through Process Scheduler


Perform the necessary tasks of creating a run control page, component and registering the
component.
I have added the objects with the following navigation.

Add two records to the run control as shown above.


The run control table should have the following data.select * from PS_AJ_JRNL_COPY_RC
where OPRID = 'VP1';

Go back to Run control page. Click on RUN.


Click on OK. Click on Process Monitor.

When the process completes successfully, let us run following SQL to see if journals are
copied.
select * from ps_jrnl_header where business_unit = 'FED01'
and journal_id in ('GTAS000018','GTAS000019','TSTS000018','TSTS000019');

Let us verify that the new journals are viewable online. Navigate as shown below. Enter
Business unit as FED01 and Journal Id begins with TST. Blank out all other criteria.
Select the journal id TST000018. The Journal opens up.

If you want to rerun the Application Engine, please make sure to either update the
journal_id and journal_date combination in the run control or delete the newly created
journal using the following SQLs.
delete from ps_jrnl_header where business_unit = 'FED01'
and journal_id in ('TSTS000018','TSTS000019');
delete from ps_jrnl_ln where business_unit = 'FED01'
and journal_id in ('TSTS000018','TSTS000019');
Executing from Application Designer
Let us delete the journals that we had just created using our Application Engine running
in Process Scheduler. Open the Application Engine in Application Designer. Click on Edit.
Select Run Program. Specify the Run Control Name as shown.

The Application Engine will run on the client, a window will appear showing Application
Engine execution.
The window will close automatically when Application Engine completes.

The log is there at c:\temp\AJ_COPY_JRNL.log which will look like

If you try to open the Journal online, you will see the journals are copied.

Executing from Command Prompt


Let us delete the journals that we had just created using our Application Engine running
in Application Designer.
Open the a command prompt. Type the following command to execute the Program.
psae -CT ORACLE -CS EP92DM05 -CD EP92DM05 -CO "VP1" -CP "VP1" -R TEST1 -AI AJ_COPY_JRNL -I
0 -FP"c:\temp\AE_AJ_COPY_JRNL" -OF14

You may save the above command in a batch file too.


The general syntax is
psae -CT dbtype -CS server -CD database_name -CO oprid -CP oprpswd
-R run_control_id -AI program_id -I process_instance -DEBUG (Y|N)?
-DR (Y|N) -TRACE tracevalue -DBFLAGS flagsvalue -TOOLSTRACESQL value?
-TOOLSTRACEPC value -OT outtype -OF outformat -FP filepath

If you try to open the Journal online, you will see the journals are copied.

Calling from Peoplecode


Let us delete the journals that we had just created using our Application Engine running
in Command Prompt.
The general syntax for alling Application Engine from Peoplecode is

CallAppEngine(applid [, statereclist ]);

So in our case it will be

CallAppEngine(AJ_COPY_JRNL , GL_JRCPSJE_AET);

That is it in this article. Now it is a good time to read about advanced topics in
Application Engine like Application Engine types, Multiple State records, Temporary table
instances, COMMIT handling, etc.
There is delivered Application Engine GL_JRNL_COPY. You may compare that one with the one
simple one you just developed and start enhancing yours by incorporating more complex
things like ADB_DATE, LEDGER_GROUP, LEDGER, REVERSAL, Document Sequencing, etc.

Play around with Application Engine, one feature at a time.

Application Engine - Part 2 - Debugging


In this article we will discuss Debugging Application Engine with an example. This part of
the Application Engine article is in continuation for Part-I in the series of Application
Engine articles posted on my blog.

The example has been created and tested on the following software environment.
Peoplesoft Application: FSCM 9.2.005
Peoplesoft Peopletools: 8.53.09
Peoplesoft Virtual Machine Image id: FSCMDB-8309-PI005
Database: Oracle 11.2.0.3

In this example, we will use the Application Engine AJ_AE_SAMPLE that we developed in
Part-I. There are two iterations as there are 2 journals to be copied. The major steps
involved will be
1) Make configuration setup for Application Engine Debugging.
2) Start Application Engine in Debug mode.
3) STEP INTO until we reach a specified action.
4) View the value in a column of STATE record at that stage.
5) Modify the value of a column in the STATE record.
6) If it is not the last iteration of the loop, go to step 3.
7) STEP OVER until Application Engine completes.

To run an Application Engine program in debug mode, Start PeopleSoft Configuration


Manager, Select Profile, Default, Edit and select the Process Scheduler tab.

In the Application Engine group, enable debug by selecting the Debug check box.
This is the method that applies to all methods of invocation.

Another method is to specify DEBUG Y option if you are executing the Application Engine
in Command Line.

If you already have the Debug check box selected in PeopleSoft Configuration Manager, then
you do
not need to include the DEBUG parameter in your command line. But if you do, that command
line option takes precedence over Configuration Manager settings.

To start Application Engine in Debug mode, Open Application Engine AJ_AE_SAMPLE in


Application Designer (AJ_COPY_JRNL was developed in Part 1).
Click on Edit, Run Program. Please make sure that both Run Minimized and Output Log to
File are unchecked, as shown below.
Click on Ok. The following Window opens.

Type I and press Enter to Step Into. Continue typing I and pressing Enter until you see
the step AJ_COPY_JRNL.COPYJRNL.CPJRNLHD to Step Into.
Type L to observe the value of a column in the state record associated with the
Application Engine program. By default, the default state record GL_JRCPSJE_AET appears
with the brackets. Press Enter to select the default state record. Type NEW_JOURNAL_ID for
the FIELD_NAME prompt and press Enter. The current content of NEW_JOURNAL_ID is shown
which is TSTS000018.

We want to change the new journal Id from TSTS000018 to DBGS000018. So type M at the
prompt. It will display the current value and prompt you to specify the new value.

We will type the new journal Id as DBGS000018 and press Enter.

Type I and press Enter to Step Into. Continue typing I and pressing Enter until you see
the step AJ_COPY_JRNL.COPYJRNL.CPJRNLHD again to Step Into.
We want to change the new journal Id from TSTS000019 to DBGS000019. So type M at the
prompt. It will display the current value and prompt you to specify the new value.

We will type the new journal Id as DBGS000019 and press Enter.

Type S and press Enter to Step Over. Continue typing S and pressing Enter until the
Application Engine completes to success.
When the application Engine is done, we expect to have two journals created as copies of
GTAS000018 and GTAS000019. Let us execute the following SQLs to see that the two new
journals 'DBGS000018' and 'DBGS000019' are created and that looks like copies of
GTAS000018 and GTAS000019.
select * from ps_jrnl_header where business_unit = 'FED01'
and journal_id in ('GTAS000018','GTAS000019','DBGS000018','DBGS000019');
select * from ps_jrnl_ln where business_unit = 'FED01'
and journal_id in ('GTAS000018','GTAS000019''DBGS000018','DBGS000019');

So we just debugged an Application Engine. Now you should be ready to try more options in
the debug mode like
Q=Quit
C=Commit
B=Break
W=Watch
O=Step-Out
G=Go
R=Run-to-next-Commit
Exit=Exit

Debug Commands:
(Q)uit Rollback work and end program
E(X)it Commit work and end program (valid between steps)
(C)ommit Commit work (valid between steps)
(B)reak Set or remove a break point
(L)ook Examine state record fields
(M)odify Change a state record field
(W)atch Set or remove a watch field
(S)tep over Execute current step or action and stop
Step (I)nto Go inside current step or called section and stop
Step (O)ut of Execute rest of step or called section and stop
(G)o Resume execution
(R)un to commit Resume execution and stop after next commit

If your Application Engine had Peoplecode as well, you might want to enable the PeopleCode
debugger for Application Engine. To enable the PeopleCode debugger
select Debug, Peoplecode Debugger Mode
select Debug, Break at Start

The Application Engine program will break before executing any Peoplecode programs which
are part of the Application Engine.

Enjoy Debugging Application Engines.

Application Engine - Part 3 - Tracing and TraceMagic


In this article we will discuss tracing Application Engine with an example. We will also
see a utility called TraceMagic to interpret the trace results in a neat manner.

This part of the Application Engine article is in continuation for Part-I in the series of
Application Engine articles posted on my blog.

The example has been created and tested on the following software environment.
Peoplesoft Application: FSCM 9.2.005
Peoplesoft Peopletools: 8.53.09
Peoplesoft Virtual Machine Image id: FSCMDB-8309-PI005
Database: Oracle 11.2.0.3

In this example, we will use the Application Engine AJ_AE_SAMPLE that we developed in
Part-I. The major steps involved will be
1) Make configuration setup for Application Engine Tracing.
2) Start Application Engine on Windows workstation.
3) Open trace file in text editor.
4) Open trace file using TraceMagic utility.

To run an Application Engine program with Tracing ON, Start PeopleSoft Configuration
Manager, Select Trace tab.
Please check the boxes and specify the trace file. I have specified trace file as
c:\temp\TRACE.TRC as shown below.
Open the Application Engine program AJ_COPY_JRNL in Application Designer (AJ_COPY_JRNL was
developed in Part 1).
Click Edit, Run Request to execute the Application Engine program. Please specify run
control as TEST1 and leave the two check boxes unchecked.

The Application Engine starts executing.


Once the Application Engine program has completed successfully, you may open the trace
file in a text editor. The file will look like this.

TraceMagic utility
There is one utility called TraceMagic which can read the above trace file and present
those trace results in much efficient form. This TraceMagic utility is available from
Oracle support site. Please logon on to Oracle Support site and search for Doc ID
1470578.1 for the latest version and documentation on TraceMagic.
Download the TraceMagic zip file and install on your Windows workstation. Please note that
it requires Microsoft .Net Framework 4 or later.
Start TraceMagic program. Open the trace file c:\temp\TRACE.TRC we just created. Once the
files is read by TraceMagic, the trace results will be presented in three main tabs (1)
Statistics (2) Execution Path (3) SQL Statements. The three main tabs have further sub-
tabs. The following screen shots show the various tabs and sub-tabs showing the trace
results for the Application Engine we executed.
If you are comfortable at this stage with Application Engine tracing, it is time now to
trace when Application Engine runs at Command Line or through Process Scheduler.

When you want to trace Application Engine while executing at Command Line, you need to
specify -TRACE nnnnn option. That nnnnn is determined using the summation of the values
related to what you want to trace, from the following table.

Value Description
0 Disables tracing.
1 Initiates the Application Engine step trace.
2 Initiates the Application Engine SQL trace.
4 Initiates the trace for dedicated temporary table allocation to an Application Engine trace (AET) file. You
can trace how the system allocates, locks, and releases temporary tables during program runs.
128 Initiates the statement timings trace to a file, which is similar to the COBOL timings trace to a file.
256 Initiates the PeopleCode detail to the file for the timings trace.
1024 Initiates the statement timings trace and stores the results in the following tables: PS_BAT_TIMINGS_LOG
and PS_BAT_TIMINGS_DTL.
2048 Requests a database optimizer trace file.
4096 Requests a database optimizer to be inserted in the Explain Plan table of the current database.
8192 Sets a trace for PeopleSoft Integration Broker transform programs.
1638 Initiates a SQL timings trace and stores the results in the following tables: PS_AE_TIMINGS_LG and
4 PS_AE_TIMINGS_DT.

The most common trace option used is -TRACE 131


where 131 = 1 + 2 + 128 is indicating that you want to trace activities related to options with values 1, 2 and 128.

That is it in this article for now.

Enjoy tracing Application Engines and TraceMagic.

Application Engine - Part 4 - Temporary Tables and Parallel Processing

In this article we will discuss Temporary tables, their instances, parallel processing,
COMMIT usage and Restarting Application Engine.
This part of the Application Engine article is in continuation for Part-I in the series of
Application Engine articles posted on the blog. We will be using the Application Engine
AJ_AE_SAMPLE, that we developed in Part-I.
We will create four different run controls to cover scenarios of Re-Startable APPLICATION
ENGINE and non-ReStartable Application Engine with and without COMMIT usage. We will use
an invalid Meta-SQL in one of the step after COMMIT to cause abends for all four run
controls. We will then analyze the abends and resolutions.
This article is going to be long as we will be covering multiple inter-connected topics.
So please follow each step closely as any change could cause different results than
discussed.

The examples have been created and tested on the following software environment.
Peoplesoft Application: FSCM 9.2.005
Peoplesoft Peopletools: 8.53.09
Peoplesoft Virtual Machine Image id: FSCMDB-8309-PI005
Database: Oracle 11.2.0.3

The major steps involved will be


1) Create two records for temporary tables to be used by Application
Engine.
2) Change the Application Engine properties for using 2 instances of
Temporary tables by Application Engine.
3) Modify Application Engine AJ_AE_SAMPLE to utilize temporary tables
instead of copying journals from base tables to base tables.
4) Configure the PSOptions for temporary tables instances.
5) Build/Rebuild temporary tables.
6) RESTART feature and COMMIT usage in Application Engines.
7) Create 4 different run controls to be used for 4 executions of the
Application Engine.
8) Scenario 1: Execute run control TEST1 with COMMIT and
ReStart=Enabled.
9) Scenario 2: Execute run control TEST2 with COMMIT and
ReStart=Disabled.
10) Scenario 3: Execute run control TEST3 with no COMMIT and
ReStart=Enabled.
11) Scenario 4: Execute run control TEST4 with no COMMIT and
ReStart=Disabled.
12) Review the records updated and Allocation of Temporary Tables at runtime.
13) Analyze Scenario 1: abend and resolution.
14) Analyze Scenario 2: abend and resolution.
15) Analyze Scenario 3: abend and resolution.
16) Analyze Scenario 4: abend and resolution.
17) Review the data in Journal tables.

Create two records for temporary tables to be used by Application Engine


Open the Application Designer. Create two records AJ_JRN_HD_TMP and AJ_JRN_LN_TMP as
defined below. They could be copied from JRNL_HEADER and JRNL_LN. Once copied, move
PROCESS_INSTANCE field from column position 34 to 1 in AJ_JRN_HD_TMP and make it part of
the key. Similarly move PROCESS_INSTANCE field from column position 33 to 1 in
AJ_JRN_LN_TMP and make it part of the key.
Set the Record Type as Temporary.
Go to Tools-->> Admin -->> Indexes. Make sure you delete all non-key indexes for
AJ_JRN_HD_TMP record as they are not required. We need to have just one index as shown
below.
Set the Record Type as Temporary.
Go to Tools-->> Admin -->> Indexes. Make sure you delete all non-key indexes for
AJ_JRN_LN_TMP record. We need to have just one key index as shown below.

We will not build the records as we have not configured the number of instances required
yet.

Change the Application Engine properties for using 2 instances of temporary tables by
Application Engine
Open the Application Engine program AJ_COPY_JRNL in Application Designer (AJ_COPY_JRNL was
developed in Part 1).
Select File, Definition Properties and then select the Temp Tables tab.
Assign two records AJ_JRN_HD_TMP and AJ_JRN_LN_TMP and set the instance count dedicated to
this Application Engine as 2.

Modify Application Engine AJ_AE_SAMPLE to utilize temporary tables instead of copying


journals from base tables to base tables
Open the Application Engine program AJ_COPY_JRNL in Application Designer, if not opened
already.
In the MAIN section, insert one step CPHD2BSE after step ReadReq1. Change the description
of step CPHD2BSE to "Copy Jrnls HDRs TMP to Base". Change the description of SQL action
under step CPHD2BSE to "Copy Jrnl Headers".
In the MAIN section, insert one step CPLN2BSE after step CPHD2BSE. Change the description
of step CPLN2BSE to "Copy Jrnls Lines TMP to Base". Change the description of SQL action
under step CPLN2BSE to "Copy Jrnl Lines".
The MAIN section should like this.

The following four SQL are copying the data from base tables to temporary tables. These
are examples of Row-by-Row Processing.
Modify the SQL of Step=CPJRNLHD and Action=SQL To the following.
%InsertSelect(%table(AJ_JRN_HD_TMP), JRNL_HEADER, PROCESS_INSTANCE =
%Bind(PROCESS_INSTANCE), JOURNAL_ID = %Bind(NEW_JOURNAL_ID), JOURNAL_DATE =
%Bind(NEW_JOURNAL_DATE)) FROM PS_JRNL_HEADER WHERE BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND JOURNAL_ID = %Bind(JOURNAL_ID) AND JOURNAL_DATE = %Bind(JOURNAL_DATE);
When we try to resolve the above Met-SQL, it fails. Looks like %InsertSelect is not going
well with %table. So we will use the following SQL instead.
Insert Into %Table
(Aj_Jrn_Hd_Tmp)
(Process_Instance, Business_Unit, Journal_Id, Journal_Date, Unpost_Seq,
Business_Unit_Iu, Adjusting_Entry, Fiscal_Year, Accounting_Period,
Adb_Date, Ledger_Group, Ledger, Auto_Gen_Lines, Reversal_Cd,
Reversal_Date, Reversal_Adj_Per, Reversal_Cd_Adb, Reversal_Date_Adb,
Unpost_Jrnl_Date, Jrnl_Total_Lines, Jrnl_Total_Debits, Jrnl_Tot_Credits,
Jrnl_Net_Units, Source, Trans_Ref_Num, Jrnl_Balance_Stat,
Control_Total_Stat, Jrnl_Edit_Err_Stat, Jrnl_Hdr_Status,
Susp_Recon_Status, Jrnl_Process_Reqst, Jrnl_Sumled_Reqst, Sje_Type,
Schedule, Event_Occurrence, Posted_Date, Source_Instance,
Transaction_Date, Last_Ln_Committed, Oprid, Dttm_Stamp_Sec, Descr,
Currency_Cd, Foreign_Currency, Rt_Type, Cur_Effdt, Rate_Div, Rate_Mult,
System_Source, Doc_Type, Doc_Seq_Nbr, Doc_Seq_Date, Doc_Seq_Status,
Acctg_Def_Name, Budget_Hdr_Status, Kk_Amount_Type, Kk_Tran_Over_Flag,
Kk_Tran_Over_Oprid, Kk_Tran_Over_Dttm, Kk_Skip, Journal_Locked,
Proc_Part_Id, Gl_Adjust_Type, Date_Code_Jrnl, Journal_Date_Orig,
Journal_Class, Kk_Tran_Bypas_Flag, Ee_Hdr_Status, Iu_Sys_Tran_Cd,
Iu_Tran_Cd, Jrnl_Create_Dttm, Alc, Fed_Distrib_Status, Descr254,
Attachment_Exist, Sce_Id, Source_Data)
Select %Bind(Process_Instance),
Business_Unit,
%Bind(New_Journal_Id),
%Bind(New_Journal_Date),
Unpost_Seq,
Business_Unit_Iu,
Adjusting_Entry,
Fiscal_Year,
Accounting_Period,
Adb_Date,
Ledger_Group,
Ledger,
Auto_Gen_Lines,
Reversal_Cd,
Reversal_Date,
Reversal_Adj_Per,
Reversal_Cd_Adb,
Reversal_Date_Adb,
Unpost_Jrnl_Date,
Jrnl_Total_Lines,
Jrnl_Total_Debits,
Jrnl_Tot_Credits,
Jrnl_Net_Units,
Source,
Trans_Ref_Num,
Jrnl_Balance_Stat,
Control_Total_Stat,
Jrnl_Edit_Err_Stat,
Jrnl_Hdr_Status,
Susp_Recon_Status,
Jrnl_Process_Reqst,
Jrnl_Sumled_Reqst,
Sje_Type,
Schedule,
Event_Occurrence,
Posted_Date,
Source_Instance,
Transaction_Date,
Last_Ln_Committed,
Oprid,
Dttm_Stamp_Sec,
Descr,
Currency_Cd,
Foreign_Currency,
Rt_Type,
Cur_Effdt,
Rate_Div,
Rate_Mult,
System_Source,
Doc_Type,
Doc_Seq_Nbr,
Doc_Seq_Date,
Doc_Seq_Status,
Acctg_Def_Name,
Budget_Hdr_Status,
Kk_Amount_Type,
Kk_Tran_Over_Flag,
Kk_Tran_Over_Oprid,
Kk_Tran_Over_Dttm,
Kk_Skip,
Journal_Locked,
Proc_Part_Id,
Gl_Adjust_Type,
Date_Code_Jrnl,
Journal_Date_Orig,
Journal_Class,
Kk_Tran_Bypas_Flag,
Ee_Hdr_Status,
Iu_Sys_Tran_Cd,
Iu_Tran_Cd,
Jrnl_Create_Dttm,
Alc,
Fed_Distrib_Status,
Descr254,
Attachment_Exist,
Sce_Id,
Source_Data
From Ps_Jrnl_Header
Where Business_Unit = %Bind(Business_Unit)
And Journal_Id = %Bind(Journal_Id)
And Journal_Date = %Bind(Journal_Date);

Modify the SQL of Step=CPJRNLLN and Action=SQL To the following.


%InsertSelectWithLongs(%TABLE(AJ_JRN_LN_TMP), JRNL_LN, PROCESS_INSTANCE =
%Bind(PROCESS_INSTANCE), JOURNAL_ID = %Bind(NEW_JOURNAL_ID), JOURNAL_DATE =
%Bind(NEW_JOURNAL_DATE))
FROM PS_JRNL_LN
WHERE BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND JOURNAL_ID = %Bind(JOURNAL_ID)
AND JOURNAL_DATE = %Bind(JOURNAL_DATE);
Here again, when we try to resolve the above Met-SQL, it fails. So we will use the
following SQL instead.
Insert Into %Table
(Aj_Jrn_Ln_Tmp)
(Process_Instance, Business_Unit, Journal_Id, Journal_Date, Unpost_Seq,
Journal_Line, Ledger, Speedchart_Key, Speedtype_Key, Account, Altacct,
Deptid, Operating_Unit, Product, Fund_Code, Class_Fld, Program_Code,
Budget_Ref, Affiliate, Affiliate_Intra1, Affiliate_Intra2, Chartfield1,
Chartfield2, Chartfield3, Book_Code, Gl_Adjust_Type, Budget_Period,
Scenario, Currency_Cd, Business_Unit_Pc, Project_Id, Activity_Id,
Resource_Type, Resource_Category, Resource_Sub_Cat, Analysis_Type,
Statistics_Code, Monetary_Amount, Movement_Flag, Statistic_Amount,
Jrnl_Ln_Ref, Suspended_Line, Line_Descr, Jrnl_Line_Status,
Journal_Line_Date, Foreign_Currency, Rt_Type, Foreign_Amount, Rate_Div,
Rate_Mult, Doc_Type, Doc_Seq_Nbr, Doc_Seq_Date, Doc_Seq_Status,
Jrnl_Line_Source, Budget_Dt, Budget_Line_Status, Settlement_Dt, Date_Code,
Closing_Status, Entry_Event, Ee_Proc_Status, Journal_Line_Gfee,
Iu_Tran_Grp_Nbr, Iu_Anchor_Flg, Pc_Distrib_Status, Sce_Id, Source_Data)
SELECT %Bind(PROCESS_INSTANCE)
, BUSINESS_UNIT
, %Bind(NEW_JOURNAL_ID)
, %Bind(NEW_JOURNAL_DATE)
, UNPOST_SEQ
, JOURNAL_LINE
, LEDGER
, SPEEDCHART_KEY
, SPEEDTYPE_KEY
, ACCOUNT
, ALTACCT
, DEPTID
, OPERATING_UNIT
, PRODUCT
, FUND_CODE
, CLASS_FLD
, PROGRAM_CODE
, BUDGET_REF
, AFFILIATE
, AFFILIATE_INTRA1
, AFFILIATE_INTRA2
, CHARTFIELD1
, CHARTFIELD2
, CHARTFIELD3
, BOOK_CODE
, GL_ADJUST_TYPE
, BUDGET_PERIOD
, SCENARIO
, CURRENCY_CD
, BUSINESS_UNIT_PC
, PROJECT_ID
, ACTIVITY_ID
, RESOURCE_TYPE
, RESOURCE_CATEGORY
, RESOURCE_SUB_CAT
, ANALYSIS_TYPE
, STATISTICS_CODE
, MONETARY_AMOUNT
, MOVEMENT_FLAG
, STATISTIC_AMOUNT
, JRNL_LN_REF
, SUSPENDED_LINE
, LINE_DESCR
, JRNL_LINE_STATUS
, JOURNAL_LINE_DATE
, FOREIGN_CURRENCY
, RT_TYPE
, FOREIGN_AMOUNT
, RATE_DIV
, RATE_MULT
, DOC_TYPE
, DOC_SEQ_NBR
, DOC_SEQ_DATE
, DOC_SEQ_STATUS
, JRNL_LINE_SOURCE
, BUDGET_DT
, BUDGET_LINE_STATUS
, SETTLEMENT_DT
, DATE_CODE
, CLOSING_STATUS
, ENTRY_EVENT
, EE_PROC_STATUS
, JOURNAL_LINE_GFEE
, IU_TRAN_GRP_NBR
, IU_ANCHOR_FLG
, PC_DISTRIB_STATUS
, SCE_ID
, SOURCE_DATA
FROM PS_JRNL_LN
WHERE BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND JOURNAL_ID = %Bind(JOURNAL_ID)
AND JOURNAL_DATE = %Bind(JOURNAL_DATE);

Modify the SQL of Step=UPDJRNLH and Action=SQL To the following.


UPDATE %TABLE(AJ_JRN_HD_TMP)
SET UNPOST_SEQ = 0, JRNL_HDR_STATUS = 'N', JRNL_CREATE_DTTM = SYSDATE,
(FISCAL_YEAR,ACCOUNTING_PERIOD) = (
SELECT FISCAL_YEAR
,ACCOUNTING_PERIOD
FROM ps_cal_detp_tbl
WHERE setid = 'SHARE'
AND calendar_id = '01'
AND %Bind(NEW_JOURNAL_DATE) BETWEEN begin_dt AND end_dt)
WHERE PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE)
AND BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND JOURNAL_ID = %Bind(NEW_JOURNAL_ID)
AND JOURNAL_DATE = %Bind(NEW_JOURNAL_DATE);

Modify the SQL of Step=UPDJRNLL and Action=SQL To the following.


UPDATE %TABLE(AJ_JRN_LN_TMP)
SET UNPOST_SEQ = 0
WHERE PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE)
AND BUSINESS_UNIT = %Bind(BUSINESS_UNIT)
AND JOURNAL_ID = %Bind(NEW_JOURNAL_ID)
AND JOURNAL_DATE = %Bind(NEW_JOURNAL_DATE);

Let us add SQLs for copying data from temporary tables to base tables. Since the two steps
CPHD2BSE and CPLN2BSE are executed when the journal copy iterations in step ReadReq1 are
completed, all the selected journals will be copied from temporary tables to base tables
by one SQL. These are examples of Set Processing.
Add following SQL to Step=CPHD2BSE and Action=SQL for copying journal headers from
temporary table to base table.
%InsertSelect(JRNL_HEADER, %table(AJ_JRN_HD_TMP) T)
FROM %Table(AJ_JRN_HD_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);

Add following SQL to Step=CPLN2BSE and Action=SQL for copying journal lines from temporary
table to base table.
%InsertSelectWithLongs(JRNL_LN, %table(AJ_JRN_LN_TMP) T)
FROM %Table(AJ_JRN_LN_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);

Configure the PSOptions for temporary tables instances


Select PeopleTools, then select Utilities, then select Administration, then select
PeopleTools Options to access the PeopleTools Options page.
Leave the Temp Table Instances (Online) to 3. This relates to the number of temporary
table instances for Application Engine processes started online from the PeopleCode
CallAppEngine function.
Leave the Temp Table Instances (Total) to 3.

As per the peoplesoft peoplebook for Application Engine


.if the value for the Temp
Table Instances (Online) field is less than the value for the Temp Table Instances
(Total) field, the difference between the two numbers provides a pool of tables for
backward compatibility for developers who took advantage of the %Table(record_name,
instance_number) approach for manually managing temporary table locking, (such as
PeopleSoft EPM)..
In our case we do not have backward compatibility issue so we have specified the two
parameters same value.
The number of Global Instances is saved in PSOPTIONS. The following SQL may be used to
inquire without navigating to that page.
SELECT TEMPTBLINSTANCES,TEMPINSTANCEBATCH,TEMPINSTANCEONLINE FROM PSOPTIONS;
To increase the number of Temporary Table Instances for all Application Engine programs
go to Home > PeopleTools > Utilities > Use PeopleTools Options and then increase the value
of Temp Table Instances (Total) and the corresponding value of Temp Table Instances
(Online) will be automatically increased to the same value. For our examples, we are not
going to do that.
Application Designer creates multiple copies of the table and uses the view PSTEMPTBLCNTVW
to calculate the total number of instances of the temporary table required by all
Application Engine programs. The following SQL may be used to inquire PSTEMPTBLCNTVW.
select * from PSTEMPTBLCNTVW where recname like 'AJ_JRN%';

Build/Rebuild temporary tables


The system determines the total available number of temporary table instances for a base
temporary table according to your settings for total and online instances on PeopleTools
Options page and on the value of Instant Count, in Application Engine Program Properties,
Temp Tables tab in Application Designer.
The number of temporary table instances built for a specific temporary table record during
the SQL Build process is the value of the total temporary table instances from the
PeopleTools Options page added to the sum of all the instance count values specified on
the Temp Table tab for the Application Engine programs that use that temporary table.
In our case the PeopleTools Option is set to 3 and Instance Count is 2. So there will be 6
tables in the System Catalog (one base and five instances) like PS_AJ_JRN_HD_TMP,
PS_AJ_JRN_HD_TMP1, PS_AJ_JRN_HD_TMP2, PS_AJ_JRN_HD_TMP3, PS_AJ_JRN_HD_TMP4 and
PS_AJ_JRN_HD_TMP5.
The system creates a maximum of 99 temporary table instances, even if the sum exceeds 99
for a particular temporary table.
Let us build the two temporary tables now and examine how many instances are created. In
Application Designer, open the record AJ_JRN_HD_TMP and build the record. Do the same for
AJ_JRN_LN_TMP.
After building the temporary tables, we can see in the log that the following tables are
created.
PS_AJ_JRN_HD_TMP
PS_AJ_JRN_HD_TMP1
PS_AJ_JRN_HD_TMP2
PS_AJ_JRN_HD_TMP3
PS_AJ_JRN_HD_TMP4
PS_AJ_JRN_HD_TMP5
and
PS_AJ_JRN_LN_TMP
PS_AJ_JRN_LN_TMP1
PS_AJ_JRN_LN_TMP2
PS_AJ_JRN_LN_TMP3
PS_AJ_JRN_LN_TMP4
PS_AJ_JRN_LN_TMP5
As an alternate way to see the tables created, we can execute the following SQL.
select * from all_tables where table_name like 'PS_AJ_JRN_%TMP%' order by table_name;

RESTART feature and COMMIT usage in Application EnginesAn Application Engine has built-in
checkpoint and ReStart capabilities. If a program step terminates abnormally or fails, you
can restart the request from the last successful checkpoint. Application Engine programs,
by default, perform a COMMIT only when an entire program successfully completes. We must
set individual COMMITs where appropriate. The COMMIT level that we select affects how
ReStart works in a program. Each time Application Engine issues a COMMIT with ReStart
enabled, it records the current state (check point) of the program. Using the ReStart
feature enables to perform commits more often in a program and it reduces the number of
rows that are locked by the program.
Since we want to use RESTART option, we will change the state record from Derived/Work
record to a regular table. Open the record GL_JRCPSJE_AET in Application Designer and save
as AJ_JRCPSJE_AET. Change the record Type from Derived/Work to SQL Table and build the
table. GO to Application Engine properties and on the State Records tab, add the record
AJ_JRCPSJE_AET, make it default and delete the GL_JRCPSJE_AET record from that list.
Create 4 different run controls to be used for 4 executions of the Application Engine
The run control TEST1 that we used in Part 1 of Application Engine series, will be reused
here. We will copy the Run control TEST1 to TEST2, TEST3 and TEST4 using the following
SQLs.
insert into PS_AJ_JRNL_COPY_RC
(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST2', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST2000018', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000018';

insert into PS_AJ_JRNL_COPY_RC


(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST2', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST2000019', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000019';

insert into PS_AJ_JRNL_COPY_RC


(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST3', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST3000018', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000018';
insert into PS_AJ_JRNL_COPY_RC
(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST3', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST3000019', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000019';

insert into PS_AJ_JRNL_COPY_RC


(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST4', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST4000018', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000018';

insert into PS_AJ_JRNL_COPY_RC


(OPRID, RUN_CNTL_ID, REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, NEW_JOURNAL_ID, NEW_JOURNAL_DATE, PROCESS_STATUS)
select OPRID, 'TEST4', REQUEST_NBR, PROCESS_FREQUENCY, BUSINESS_UNIT,
JOURNAL_ID, JOURNAL_DATE, 'TST4000019', NEW_JOURNAL_DATE, PROCESS_STATUS
from PS_AJ_JRNL_COPY_RC where OPRID = 'VP1' and RUN_CNTL_ID = 'TEST1' and NEW_JOURNAL_ID
= 'TSTS000019';

We will also delete journals ('TSTS000018','TSTS000019' for BUSINESS_UNIT 'FED01' in case


they exists from previous runs.
delete from PS_JRNL_HEADER where BUSINESS_UNIT = 'FED01' and JOURNAL_ID in
('TSTS000018','TSTS000019');
delete from PS_JRNL_LN where BUSINESS_UNIT = 'FED01' and JOURNAL_ID in
('TSTS000018','TSTS000019');

Since the temporary tables are unlocked and cleared when the Application Engine runs
successfully, we may not be able to view the locking and dedicated temporary tables
assignments with small examples. For this reason we will use our small example and cause
the Application Engine to abend in all four scenarios to demonstrate the dedicated
temporary tables handling and parallel processing.
All the four run controls TEST1, TEST2, TEST3 and TEST4 are setup to copy the journals
from 'GTAS000018' and 'GTAS000019'. But will have left an invalid Meta-SQL to cause abends
for our purpose.
We have enabled trace also.

Scenario 1: Execute with run control TEST1 with COMMIT and


ReStart=Enabled
For this scenario, let us go to the section MAIN, step ReadReq1 and change the COMMIT
After option from 'default' to 'After Step'.

But there is an exception. As per Peoplesoft documentation


The only restriction for batch runs occurs when you have ReStart enabled, and you are
inside a Do Select action that is of the Select/Fetch type (instead of Re-select or
ReStartable). With Select/Fetch, all COMMITs inside the loop are ignored, including the
commit frequency if it is set.
So we will set COMMIT at section level.

We will change COMMIT at step level from Default to Later for step GoPrgMsg
We will keep COMMIT settings at step level step ReadReq1 to After Step.
We will change COMMIT at step level from Default to Later for steps CPHD2BSE and CPLN2BSE
as well.
Go to Application Engine properties, Advanced tab and uncheck 'Disable ReStart' checkbox.
Execute the Application Engine using the run control TEST1. The run control page looks
like

The program abends. The process instance is 18823.


Click on Details link.

Click on View Log/Trace link.

Click on AE_AJ_COPY_JRNL_18823.AET link. The Log file opens in a new window. Scroll down
till you see insert into PS_AJ_JRN_HD_TMP4.

Application Engine dedicated instance number 4 to this run. Since we had COMMIT after
inserting into temp tables, and Application Engine abended, we should have data in TMP4
table.
select PROCESS_INSTANCE , JOURNAL_ID from PS_AJ_JRN_HD_TMP4;
Let us review some other Application Engine tables.
select * from PS_AERUNCONTROL where PROCESS_INSTANCE = 18823;

select * from PS_AETEMPTBLMGR where PROCESS_INSTANCE = 18823;

Let us leave this scenario here for now, we will review these soon.

Scenario 2: Execute with run control TEST2 with COMMIT andReStart=Disabled


Go to Application Engine properties, Advanced tab and check 'Disable ReStart' checkbox.
Execute the Application Engine using the run control TEST2. The run control page looks
like

The program abends. The process instance is 18824.


Application Engine dedicated instance number 5 to this run. Since we had COMMIT after
inserting into temp tables, and Application Engine abended, we should have data in TMP5
table.
select PROCESS_INSTANCE , JOURNAL_ID from PS_AJ_JRN_HD_TMP5;
Let us review some other Application Engine tables.
select * from PS_AERUNCONTROL where PROCESS_INSTANCE = 18824;

select * from PS_AETEMPTBLMGR where PROCESS_INSTANCE = 18824;

Let us leave this scenario here for now, we will review these soon.

Scenario 3: Execute with run control TEST3 with no COMMIT and ReStart=Enabled
Go to Application Engine properties, Advanced tab and check 'Disable ReStart' checkbox.
Let us go to the section MAIN, step ReadReq1 and change the COMMIT After option from
'After Step' to 'default'.
Execute the Application Engine using the run control TEST3. The run control page looks
like

The program abends. The process instance is 18825.


Application Engine dedicated instance number 5 to this run. Why? (Because the TMP5 locked
by previous Application Engine run did not keep it locked as Application Engine was not
ReStartable in previous run). At the time of dedicating TMP5, Application Engine clears
any earlier rows, that is why previous rows are deleted. Since there is no COMMIT, no new
rows are saved either.
select PROCESS_INSTANCE , JOURNAL_ID from PS_AJ_JRN_HD_TMP5;

Let us review some other Application Engine tables.


select * from PS_AERUNCONTROL where PROCESS_INSTANCE = 18825;

There is data as the Application Engine was ReStartable.


select * from PS_AETEMPTBLMGR where PROCESS_INSTANCE = 18825;

There is data as the Application Engine was ReStartable.


Let us leave this scenario here for now, we will review these soon.

Scenario 4: Execute with run control TEST4 with no COMMIT and


ReStart=Disabled
Go to Application Engine properties, Advanced tab and Uncheck 'Disable ReStart' checkbox.
Execute the Application Engine using the run control TEST4. The run control page looks
like
The program abends. The process instance is 18826.
Application Engine used the shared (base or default) temp table for this run.
select PROCESS_INSTANCE , JOURNAL_ID from PS_AJ_JRN_HD_TMP;

There is no data as there was no COMMIT.


Let us review some other Application Engine tables.
select * from PS_AERUNCONTROL where PROCESS_INSTANCE = 18826;

There is no data as the Application Engine was not ReStartable.


select * from PS_AETEMPTBLMGR where PROCESS_INSTANCE = 18826;

There is no data as the Application Engine was not ReStartable.


Let us leave this scenario here for now, we will review these soon.

Review the Records updated and Allocation of Temporary Tables at runtime


select * from PS_AERUNCONTROL where PROCESS_INSTANCE > 18822;

select * from PS_AETEMPTBLMGR where PROCESS_INSTANCE > 18822;


Select PeopleTools, then select Application Engine, then select Review Temp Table Usage
to access the Temp Table Usage by Record page. (Note: The next 2 snapshots were taken
after ReStarting instance 18823 successfully. So the numbers do not include that
execution or abend data. But you do see the navigation and data related to other abends).

Select PeopleTools, then select Application Engine, then select Review Temporary Table
Usage, then select Temp Table Settings by Program to access the Temp Table Settings by
Program page.
Let us make the Application Engine ReStartable and place the COMMIT(s) back.
Let us fix the Meta-SQLs which caused the abends.
The following SQL for Step=CPHD2BSE and Action=SQL caused abends.
%InsertSelect(JRNL_HEADER, %table(AJ_JRN_HD_TMP) T)
FROM %Table(AJ_JRN_HD_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);

We will replace %table(AJ_JRN_HD_TMP) with AJ_JRN_HD_TMP in the first place only. So the
SQL will look like
%InsertSelect(JRNL_HEADER, AJ_JRN_HD_TMP T)
FROM %Table(AJ_JRN_HD_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);

Here the Alias from AJ_JRN_HD_TMP T will help in resolving the SQL correctly.
Similarly the SQL for Step=CPLN2BSE and Action=SQL will be changed from
%InsertSelectWithLongs(JRNL_LN, %table(AJ_JRN_LN_TMP) T)
FROM %Table(AJ_JRN_LN_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);
to
%InsertSelectWithLongs(JRNL_LN, AJ_JRN_LN_TMP T)
FROM %Table(AJ_JRN_LN_TMP) T
WHERE T.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE);

Analyze Scenario 1: abend and resolution


Application Engine dedicated instance number 4 for PS_AJ_JRN_HD_TMP and PS_AJ_JRN_LN_TMP.
Application Engine was ReStartable, we have data in PS_AERUNCONTROL to be used for
ReStarting. We also have temporary records stuck in PS_AETEMPTBLMGR so the Application
Engine will use the right instances of temp tables when rerun.
We had COMMIT after inserting into temp tables therefore we have data in temporary tables.
Let us ReStart Application Engine for process instance 18823. Since we are not going to
start from the begining, we do not have to delete records from PS_AERUNCONTROL and
PS_AJ_JRCPSJE_AET.
We could restart from the command line on the server. But we will restart from Process
Request Page for now.
Go to Process Monitor page. Click on Details link for the process instance 18823. Click on
Restart Request radio button. Click on Ok.
The Application Engine completes to success.
The tables PS_AERUNCONTROL and PS_AETEMPTBLMGR are cleared for the process instance
18823.
The table PS_AJ_JRN_HD_TMP4 is not cleared for process instance 18823 as we did not add
logic to do that. We will delete those using following SQLs for now.
delete from PS_AJ_JRN_HD_TMP4 where PROCESS_INSTANCE = 18823;
delete from PS_AJ_JRN_LN_TMP4 where PROCESS_INSTANCE = 18823;

Analyze Scenario 2: abend and resolution


Application Engine dedicated instance number 5 for PS_AJ_JRN_HD_TMP and PS_AJ_JRN_LN_TMP.
Application Engine was not ReStartable, we do not have data in PS_AERUNCONTROL. So ReStart
is not possible. Similarly no temporary records got stuck in PS_AETEMPTBLMGR.
We had COMMIT after inserting into temp tables therefore we had data in temporary tables.
But because the Application Engine was not ReStartable, the dedicated temp tables were not
kept locked by instance 18824. The next instance 18825 got the same TMP5 tables dedicated
and cleared the data before using them. Otherwise we needed to clean up that data from
temp tables PS_AJ_JRN_HD_TMP and PS_AJ_JRN_LN_TMP.
Let us delete that request for instance 18824 and submit a new one for run control TEST2
from Process Request Page for now.
The Application Engine completes to success.

Analyze Scenario 3: abend and resolution


Application Engine dedicated instance number 5 for PS_AJ_JRN_HD_TMP and PS_AJ_JRN_LN_TMP.
Application Engine was ReStartable, we have data in PS_AERUNCONTROL to be used for
ReStarting. We also have temporary records stuck in PS_AETEMPTBLMGR so the Application
Engine will use the right instances of temp tables when rerun.
We did not have COMMIT after inserting into temp tables therefore we have no data in
temporary tables.
So if we ReStart Application Engine for process instance 18825, we will not get desired
results. We will delete the request for process instance 18825 and resubmit a new request
for run control TEST3. We do not have to delete records from PS_AERUNCONTROL and
PS_AJ_JRCPSJE_AET as deleting request will take care of that.
Let us delete that request for process instance 18825 and submit a new one for run control
TEST3 from Process Request Page for now.
The Application Engine completes to success.

Analyze Scenario 4: abend and resolution


Application Engine shared (base or default) temp tables PS_AJ_JRN_HD_TMP and
PS_AJ_JRN_LN_TMP for this run.
Application Engine was not ReStartable, we do not have data in PS_AERUNCONTROL. So ReStart
is not possible. Similarly no temporary records got stuck in PS_AETEMPTBLMGR.
We did not have COMMIT after inserting into temp tables therefore no need of clearing
temporary tables PS_AJ_JRN_HD_TMP and PS_AJ_JRN_LN_TMP.
Let us delete that request for instance 18826 and submit a new one for run control TEST4
from Process Request Page for now.
The Application Engine completes to success with process instance 18829.
The table PS_AJ_JRN_HD_TMP4 is not cleared for process instance 18829 as we did not add
logic to do that. We will delete those using following SQLs for now.
delete from PS_AJ_JRN_HD_TMP4 where PROCESS_INSTANCE = 18823;
delete from PS_AJ_JRN_LN_TMP4 where PROCESS_INSTANCE = 18823;

Review the data in Journal tables


Let us see just the journal_header table that the new journals are created. We will use
the following SQL.
select * from PS_JRNL_HEADER
where BUSINESS_UNIT = 'FED01' and JOURNAL_ID like 'TST%';
Similarly we can use the following SQL.
select * from PS_JRNL_LN
where BUSINESS_UNIT = 'FED01' and JOURNAL_ID like 'TST%';

That is it in this article for now. It was a long one. Relax for now and revisit if
needed. After that you may read peoplesoft documentation for deeper understanding of
temporary tables and achieve better performance with Application Engine Parallel
Processing.

You might also like