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.

2 thoughts on “Tip — PeopleTools: Application Engine Logging Ap…

  1. can u clearly give the procedure how to create a file and load data into tht file from the database?

  2. radha krishnan,

    Here is a quick version. When I get time, I will try to create a new post with more specifics.

    First, create a file layout. This will basically map the fields in the database to the structure in the file.

    Then, create an App Engine that looks something like this:

    Step 1: Open the file with a component or global variable, attach the file layout to the file (SetFileLayout)
    Step 2: Create a Do Select to select the rows, Create a PeopleCode action that runs for each row that will copy the data into the file layout rowset. Then write the row set.
    Step 3: Close the file

    Alternative: instead of using the Do Select, you could combine everything into one step and use a SQL object in PeopleCode to select the data.

    Hope that helps,

    Stephen

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.