Object-Oriented: Instantiating

Before you can use any object you must instantiate it first. This means that you must create the memory for object. See the Wikipedia for more information.

The instantiation applies to both regular PeopleTools objects and custom Application Packages. Here is an exploration or documentation of how you would do it.

Regular PeopleTools Objects

While you can create your own objects with Application Packages, let’s focus on the API objects from PeopleSoft first.

3 ways

  1. “Get” Built-in function
  2. “Create” Built-in function
  3. “Get” method to get an object from another object


The Get function is unique for each type of object, but the concept is basically the same. Bascially, the object already exists somewhere in memory, you just want your variable to point to that object. For example, when you page loads, it creates rowsets, rows, records, and fields. If you want a record object that was loaded by the component processor, you would use the GetRecord function.

Here are some other functions that fall in the same category:

  • GetRecord()
  • GetRowSet()
  • GetRow()
  • GetField()
  • GetLevel0()
  • GetSQL()


The Create function, like the Get function, is unique for each type of object as well. It is designed to instantiate standalone objects that do not already exist.

For example, if you want a record that is in the component buffer (it is on a page), you would use the GetRecord() method. But, if you want to create a standalone record that you might use to update the database (with the update() or insert() methods), you would use the CreateRecord() method.

Here are some functions that fall in this category:

  • CreateRecord()
  • CreateRowSet()

Get Method of other objects

Like the first Get functions we talked about, the get methods access objects that already exist in memory somewhere. More specifically, they exist “inside” another object that we already have access to. The Get method retrieves that object.

For example, a RowSet contains a group of rows. Assuming an &rs variable is a RowSet, we can use the &rs.GetRow() method to access one of the rows in that RowSet.

Here are some other examples:

  • RowSet — GetRow() method
  • Row — GetRecord() method
  • Record — GetField() method

Application Packages

Applications Classes are custom objects defined in PeopleCode. They are defined as part of the Application Packages definition, which means that you can view or create them with the File, Open or File, New operations.  Let’s leave them at that for this article.


Before you can use or instantiate an Application Class, you must “import” it.  This simply means that you have to tell PeopleTools where the actual class is defined.  This includes the Application Package and the structure inside the package.  The different levels of the structure are separated with colons (:).  For example, an import might look like this:

Import MY_CLASSES:WorkforceAdmin:Employee;

This import gives our program access to the “Employee” class.  PeopleTools would find the class in the “MY_CLASSES” Application Package definition, and once open, the class is under the WorkforceAdmin level.


Custom classes do not exist anywhere like built-in classes do.  They are not used in the buffer or any other place where you could use a “Get” method to access it.  So, at some point all Application Classes must be instantiated with the “Create” keyword.  For example, our previous example would look like this:

&employee = Create MY_CLASSES:WorkforceAdmin:Employee();

The PeopleCode editor will allow you to type only the class name assuming you have imported the class.  When you save the program, the editor will supply the complete path to the class.  So, you could type this:

&employee = Create Employee();

Some classes have a constructor method, which is just a method that PeopleCode automatically calls when it creates the class.  This method is defined in the class with the same name as the class and no return value.

Sometimes the constructors have parameters.  If it does, you will have to supply the parameter in your create statement.  Say, for example, that our Employee class requires an employee id.  The code might look like this:

&employee = Create Employee(“111000”);

In Conclusion

When ever you use an object variable always remember to instantiate it before you begin to use the methods and properties of that object.  Make it a mental habit to decide first where and how you will instantiate your objects.

Hopefully, this helps someone.  Please let me know if this is helpful, and if more information on object-oriented programming would help any other PeopleSoft developers.

4 thoughts on “Object-Oriented: Instantiating

  1. Object oriented coding is something worth doing but trouble is that browsing the code in Application Designer is painful – you can not jump from method call do definiton from object to class definition – simply it does not work.

    This is why I’m begging for eclipse plugin for doing peoplecode. Lack of code complition is second big gap in AD, then lack of integration with peoplebooks… I like PeopleCode because it is simple and easy. You can write java classes and call them from peoplecode directly and operate on them in the very same way You can use PeopleCode objects, but this crappy Application Designer…. nightmare.

  2. The article was a good overview; thanks for putting it together. I for one would like to see more info. on OO programming w/ PeopleSoft. Specifically around creating custom classes and examples for situations where these would be useful.

Leave a Comment

Your email address will not be published.

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