|PeopleCode, Behind the Scenes
Did you ever wonder why PeopleCode automatically formats itself?
Ever wish you could compare PeopleCode programs using your favorite
text file compare program instead of Application Designer?
Did you ever go looking for the place where PeopleCode is stored?
Today we'll take a
quick look at what and where PeopleCode really is.
Just as with any other PeopleSoft object, a PeopleCode program
is stored in the database. Table PSPCMPROG (PeopleCode module (?)
program) contains the actual code. Do a SELECT on this table
and you will see that each program has a key that designates
its event (FieldChange, etc.) and the object (record or component,
for example) to which it belongs.
The code itself is stored in a long character field called PROGTXT.
Look at that and you will see "garbage". Is this compiled
code? Not really—it's an intermediate form of the source
code. PeopleCode is an interpreted language and is never actually
compiled. When you change and save a PeopleCode program, it is
immediately scanned and condensed. Variables are identified
and flagged with a special character; extra whitespace is
removed; numeric constants are found and translated to a consistent
internal format; keywords are replaced with special one-byte codes;
and so on. The result is no longer readable to
us, but it is more efficent. Some of this code can be run dozens of
times during one transaction. We don't want to have to wait as
the program is interpreted each time.
(The actual encoding is undocumented, as far as I know.
forums, under PeopleCode,
is a post dealing with this question. It contains a link
to a long detailed article showing how the program could be decoded.)
We can now answer the question about automatic code formatting.
Enter a statement and then either save the program or
click on the syntax check (checkmark) button. At that time, the program is
reformatted with appropriate indenting, the extra whitespace
is removed, and standard capitalization of keywords is applied.
This is not just a handy service provided by App Designer.
Since the code has been compressed into a more efficient form,
it's about the only way the code could be displayed. For example, if
a keyword is replaced with a single one-byte code, then the way
we entered it initially (all caps, all lower case, or mixed) is lost
and it must be displayed using the standard capitalization.
Occasionally we may want to format the code in a certain way, but
in general, this automatic reformatting is a good thing.
You may occasionally have PeopleCode programs "go bad". An error
message may report that the program is invalid. Even before clearing
your cache, you might want to try this. Open the program in
App Designer, make a small change (such as adding a space at the end of a
line), and save. The program is then re-scanned. That often fixes
One last tip... You might see some custom code and wonder who wrote
it and when. The record or component to which the
code belongs has its own user ID and date, and that is what is displayed
on the properties panel. I don't know of a way to find the user ID
and date for a particular PeopleCode program through App Designer,
but you can see it by doing a SELECT
on PSPCMPROG. The ID and datestamp fields are stored right there with