PeopleCode


PeopleSoft officially supports a variety of enterprise databases, the most prominent of them are Oracle, DB2 and MSSQL. When PeopleSoft applications are delivered, one could readily assume they are tested intensively against these databases.

When developing PeopleTools customizations with SQL, do you think about whether the code being written will work for other databases as well? As a developer, the importance of this issue may not be apparent in your daily work. However, for your client or organization the long-term cost is vendor lock-in — making it more difficult and costly to switch database vendors when the need arises.

PeopleTools made it easy to code cross-platform SQL in your PeopleSoft applications, so there really is not much excuse for ignoring cross-platform compatibility issues further. There are 2 features in PeopleTools that are geared towards mitigating SQL cross-platform issues:

read more…

When working with HTML areas or an IScript page, it is still often very convenient to store data into arrays. When converting the data into the necessary HTML, the Join() method of the Array class still provides a convenient way to formulate your HTML without doing a loop. The following examples should illustrate.

To generate a series of paragraphs from an array &arPara:


   &html = &arPara.Join("</p><p>", "<p>", "</p>");

To create an unordered (bullet) list from &arList:


   &html = &arList.Join("</li><li>", "<ul><li>", "</li></ul>");

Regular expressions (or regex as it is affectionately called) is a powerful tool for searching (and also, replacing) complex text patterns. A quick tutorial can be found at www.regular-expressions.info.[1] To quote from that site:

If you are a programmer, you can save yourself lots of time and effort. You can often accomplish with a single regular expression in one or a few lines of code what would otherwise take dozens or hundreds.

In addition to that argument, writing your own implementation with dozens of lines of code also makes it prone to defects, and makes it more difficult to maintain. And if the required pattern is changed slightly, the impact on your code could be very huge, or even require a rewrite of your custom implementation. With regex, what is often required is to change a few characters in the pattern.[2]

PeopleCode do not have an implementation of regular expressions, but fortunately, it is easy to utilize Java objects from PeopleCode. Note that regex capabilities was only added to Java since version 1.4.

read more…

Last time I discussed comparing a variable to a list of values using a PeopleCode array. Another nifty use of a PeopleCode array is for joining a list of values with a delimiter.

read more…

I sometimes come across a chunk of PeopleCode that requires a variable be compared to a list of values — like the IN operator in SQL:


If &code = "ABCD" Or &code = "HIJK" Or &code = "OPQR" Then
   ...

If the condition needs to be checked multiple times within the code and the list changes, there will be some effort required to update the code.

A better coding approach is to use an array and its Find method:

read more…

« Previous Page