PeopleCode
PeopleCode is a proprietary object-oriented programming language used to express business logic for PeopleSoft applications. Syntactically, PeopleCode is similar to other programming languages, and can be found in both loosely-typed and strongly-typed forms. PeopleCode and its run-time environment is part of the larger PeopleTools framework. PeopleCode has evolved over time and its implementation through the PeopleSoft applications lack consistency. PeopleCode offers some interoperability with the Java programming language. Definition name references, for example, enable you to refer to PeopleTools definitions, such as record definitions or pages, without using hard-coded string literals. Other language features, such as PeopleCode data types and metastrings, reflect the close interaction of PeopleTools and Structured Query Language. Dot notation, classes and methods in PeopleCode are similar to other object oriented languages, like Java. Object syntax was an important feature of PeopleTools 8.
Language features
Supported Functions
PeopleCode supports the following types of functions:- Built-in: The standard set of PeopleCode functions. These can be called without being declared.
- Internal: Functions that are defined within the PeopleCode program in which they are called.
- External PeopleCode: PeopleCode functions defined outside the calling program. These are generally contained in record definitions that serve as function libraries.
- External non-PeopleCode: Functions stored in external libraries.
- A built-in function is on a line by itself, and does not have any dependencies.
- A function can be used before instantiating the object.
- A method can only be executed by an object.
- The object must be instantiated first.
Describing Application Class Structure
- Import any classes that will be used by a class, including the superclass this class extends
Import PackageName:Superclassname;
- A class is defined using the Class construct.
Class Classname
Constant declaration
End-class;
- The first set of declarations are the properties and methods that are part of the public, external interface.
Property datatype PropertyName ;
Method MethodName
- The private instance variables, constants, and the methods are declared following the keyword
Private
. - The keyword
end-class
follows the declarations of properties, methods, instances, and constants. - After the
end-class
keyword and beforeget
andset
definitions or method definitions, declare any variable and functions that will be used by methods. - Get and set methods corresponds to properties declared with the get and set keywords.
- Use a
get
method definition to execute PeopleCode that will return a value. - Use a
set
method definition to execute PeopleCode that will change a value.
set PropertyName
end-set;
- Method definitions are similar to function definitions.
method Methodname
statements;
end-method;
- A special case of a method definition is the
constructor
. - A constructor has the same name as the class and will always run when the class is instantiated.
- A class that does not extend some other class does not need any constructor.
- A class that does extend another class must have a constructor, and in the constructor, it must initialize its superclass.
Executing SQL in PeopleCode
- Where a
SQLExec
only delivers a single row, using theSQL
class you can retrieve and process multiple rows. - Instantiate a SQL object with the
CreateSQL
built-in function. - * Use
CreateSQL
to pass a text string to your SQL object. - * Use
GetSQL
to get the SQL from a SQL definition.
&SQL = CreateSQL;
The values for the bind variables can be omitted and supplied later. For Insert, Update, or Delete commands these values would be supplied using
Execute
method.
&SQL = CreateSQL;
&SQL.Execute;
- For a SQL object containing a Select statement, the
Fetch
method is used to retrieve the next row from the cursor.