Category: PeopleCode

PeopleTools Tip: PeopleCode Dump

Application Designer has an option to search through the text of the code, but it takes way too long to search the whole system on a regular basis. Thankfully, Application Designer also has a way to dump all of the code to a text file.

From Application Designer, choose Edit > Find In…

Next, enter a semicolon(;) for the search text and check the option “Save PeopleCode to File”

Important: This will take a long time and a lot of memory to finish. So, increase your virtual memory and let it run overnight. If you have a team of developers, have one person do the dump and put it on a network location where everyone can view it.

If you don’t enough memory, you may get an error message like this:

If so, go to the control panel and open the System icon.  Go to the Advanced tab and click the Settings button under performance.  Under the “Advanced” tab in the performance options dialog, change the virtual memory.  The steps to increase the memory might be slightly different depending on your flavor of Windows.

PeopleCode Decoder

Ok, I have seen this several places, but I have link it here too:  A java program has been written that will read PeopleCode from a PeopleSoft database.

Download it here

Here are the blogs where I have seen this

PeopleSoft/Oracle Tips (describes how to compile it)

PeopleSoft Pros (I think this is where I first saw it)

PassPortGeek

David L. Price’s Blog

It looks like the program was created with information from PeopleCode Secrets.

I would love to create a project on SourceForge for this code.  There are so many things that you could do with it.  I would love to index the PeopleCode in the system to make searching and refactoring easier.  Oh well, maybe one day.

Response: Array Class Generic Sort

Here is my attempt at providing details in response to an article by ChiliJoe called PeopleCode Array Class’ Generic Sort.

Basically, ChiliJoe is referring to a vague example in PeopleBooks that says, “For example, suppose you want to provide a more generic sort, with comparison function at the end of it.” This is in the section: “When Would You Use Application Classes?“.

The key to this example is that you have to write the sort by extending the array class. Here is an attempt at writing an example:

Read More

Response: Private/Instance Variables

ChiliJoe posted in Access to Instance Variables within the Same Class that an instance can change the value of another instance’s private variable.

At first, this sounds like it doesn’t make sense — an instance shouldn’t be able to access something private to another instance. But, in my opinion, the private is to protect it from code that may not understand or may violate rules the class depends on. From that point of view, it does make sense. Whoever wrote the code for the class knows what the value should be, and therefore, can be trusted to change it. Therefore, it can change any instance’s private variable as long as it is the same class. Whoever wrote the other class may not even be able to look at the code to see if they are going to mess things up, and therefore, cannot access the variable.

I think the PeopleSoft names make it confusing. Instead of calling it private, PeopleCode calls it instance, which would lead you to think that only that instance could access it. Actually, it is private to the class, not the instance.

So, to take the challenge, I translated ChiliJoe’s code to Java just to see if it works the same in Java. It does:

package com.skp.peoplecodejavacompare;

public class Example {
private Example newInstance;
private int num = 0;

public void createNewInstance() {
newInstance = new Example();
}

public int incrementNewInstanceNum() {
newInstance.num++;
return newInstance.num;
}

public int incrementThisInstanceNum() {
num++;
return num;
}

public void incrementPassedNum(Example passed) {
passed.num ++;
}

public int getThisInstanceNum() {
return num;
}

public static void main(String[] args) {
Example test1 = new Example();
test1.createNewInstance();

System.out.println(“incrementNewInstanceNum returns “ + test1.incrementNewInstanceNum());
System.out.println(“getThisInstanceNum returns “ + test1.getThisInstanceNum());
System.out.println(“incrementThisInstanceNum returns “ + test1.incrementThisInstanceNum());
System.out.println(“incrementNewInstanceNum returns “ + test1.incrementNewInstanceNum());

Example test2 = new Example();
System.out.println(“test2.getThisInstanceNum returns “ + test2.getThisInstanceNum());
test1.incrementPassedNum(test2);
System.out.println(“test2.getThisInstanceNum returns “ + test2.getThisInstanceNum());
}
}

Output:

incrementNewInstanceNum returns 1
getThisInstanceNum returns 0
incrementThisInstanceNum returns 1
incrementNewInstanceNum returns 2
test2.getThisInstanceNum returns 0
test2.getThisInstanceNum returns 1