Category: App Engine

Log Messages in Application Engine

Here is some SQL that lists the Log Message actions in Application Programs:

SELECT A.AE_APPLID, A.AE_SECTION, A.AE_STEP,
M.AE_MESSAGE_PARMS, S.MESSAGE_SET_NBR, S.MESSAGE_NBR FROM
PSAESTMTDEFN A, PSAESTEPMSGDEFN M, PSAESTEPDEFN S
WHERE A.AE_APPLID = M.AE_APPLID
AND A.AE_APPLID = S.AE_APPLID
AND A.AE_SECTION = M.AE_SECTION
AND A.AE_SECTION = S.AE_SECTION
AND A.MARKET = M.MARKET
AND A.MARKET = S.MARKET
AND A.DBTYPE = M.DBTYPE
AND A.DBTYPE = S.DBTYPE
AND A.EFFDT = M.EFFDT
AND A.EFFDT = S.EFFDT
AND A.AE_STEP = M.AE_STEP
AND A.AE_STEP = S.AE_STEP
AND A.AE_STMT_TYPE = 'M'

PeopleTools Reference: Meta-SQL %Table

%Table

Replaces with the actual table name of the given record.

Generally, this just means adding a “PS_” to the front of the record name. But, PeopleTools actually checks the alternate table name from the Record Type tab to see if a value is there first.

Two Uses:

  • Access a table with a reference or record object rather than embedding a table name in the SQL; PeopleTools will not index the table/record in a string literal.
  • Reference the Temporary table in an App Engine; %Table is the only way to reference the table because the table name is assign dynamically at run time.

Examples:

SELECT * FROM %Table(JOB) WHERE EMPLID = :1

SqlExec(“SELECT NAME FROM %Table(:1) WHERE EMPLID = :2”, Record.NAMES, &emplid, &name);

&sql = CreateSql(“SELECT * FROM %Table(:1) WHERE EMPLID = :2”, &MyRecord, &emplid);

INSERT INTO %Table(MYTEMP_TAO)
SELECT * FROM PS_MYDATATABLE

PeopleTools Tip — App Engine Restart If you get …

PeopleTools Tip — App Engine Restart

If you get an error message like this, you either need to restart the specific instance that abended, or remove the restart row from the table.

PeopleTools 8.46 – Application Engine Server

Copyright (c) 1988-2006 PeopleSoft, Inc.

All Rights Reserved

PSAESRV started service request at 14.19.05 2006-09-19

All Processing Suspended: Restart OPRID=PS, RUNID=AppEngName, PI=499 (108,503)

PSAESRV completed service request at 14.19.05 2006-09-19

Disable Restart:
You can disable the restart on the properties of the application engine, but that will not help when the Application Engine has already abended. Remember, the disable restart prevents the app engine from writing to the restart table when the program abends; it does not prevent it from checking the table to see if another instance is waiting to restart.

In other words, once an application has abended, disable restart will not allow you to rerun the program without restarting.

AERUNCONTROL Record:
The restart status is stored in the record AERUNCONTROL. If you receive the message requiring you to restart instead of rerun, then there is a row in this table for the program you are running and the run control that you are using.

Fields:
PROCESS_INSTANCE — instance that abended
OPRID — your user name
RUN_CNTL_ID — run control used when it abended
AE_APPLID — Application Engine program name

Fixing the Error:
To fix the error, you either have to delete the row from the table or restart the original process instance that abended.

SELECT * FROM PS_AERUNCONTROL WHERE AE_APPLID = ‘<App Engine Name>

Update:
Ray pointed out that PeopleSoft has provided an online way to fix the problem. You can do it from the page: PeopleTools > Application Engine > Manage Abends

Deleting the Row:

If you are the only one with an abended program, you can just truncate the whole table:

TRUNCATE TABLE PS_AERUNCONTROL

Or, if you want to just affect your program, you can do something more like this:

DELETE FROM PS_AERUNCONTROL WHERE OPIRD = ‘<username>‘ AND RUN_CNTL_ID = ‘<run control>

Tip — PeopleTools: Application Engine Logging Ap…

Tip — PeopleTools: Application Engine Logging

Application Engines have the ability to write to the “Redirected Terminal Output”. But, everything that is written into it must be written with a MessageBox command. That results in a blank line between messages and the infamous message set ids at the end.

If you want any formatting at all you should open a file and use the File object to create the file.

First, declare the variable in every PeopleCode program in your App Engine:

Component File &logFile;

Declare the variable as a component or global variable so that it stays around for the life of the App Engine program. Otherwise, you will have to keep reopening the file to write to it in each PeopleCode step.

Second, create an Init step in the Main section that will open the file:

&logFile = GetFile(GetEnv(“PSPRCSLOGDIR”) “\logFile.txt”, “W”, %FilePath_Absolute);

PSPRCSLOGDIR is the environment variable that is set to the path where the files should go. Every file that is put in this path will be copied to the web server so that the user can see it.

You can use %Filepath_Relative in many cases, but sometimes the relative path does not point to the proper folder, particullarly on older PeopleSoft systems. I have had more success with PSPRCSLOGDIR.

Third, close the file in a step at the end of the Main section:

&logFile.close();

Finally, write what you want to the file with:

&logFile.writeline(“This is a log statement!”);

You have complete control of this file and can make it say what you want it to.