Professional Documents
Culture Documents
PeopleCode Overview
PeopleCode Overview
Introduction
What is PeopleCode?
2
Accessing PeopleCode
Prior to PeopleTools 8
• Record Field
• Menu Item
PeopleTools 8
• Record Field
• Page
• Component
• Menu Item (Pop-Up only)
• Component Interface
• Message and Message Channel
• Application Engine
3
Editing PeopleCode
• PeopleCode supports the standard text editing features and
functions such as Save, Undo, Cut, Paste, Find and
Replace.
• No Need to Format PeopleCode – Just be concerned about
the correct Syntax
• Does not format anything within the Quotes
• Fieldnames are converted to Uppercase
• Variable match their First Occurrence
• PeopleCode is Case-Insensitive, except for quoted literals
4
Referencing Fields
Referring to a field by … Assumes that …
5
PeopleCode Statements
• Statement can be a
– Declaration
– Assignment
– Program Construct (Such as a Warning Statement or a
conditional loop)
– Subroutine calls
– And so on…
6
PeopleCode Statements
Comments
Remark Comments;
Or
REM Comments;
Or
/* Comments */
Or
/* Comments <* Inside nest *> Comments */
Assignments
7
PeopleCode Statements
IF statement
If condition then
<PeopleCode Statements>;
Else
<PeopleCode Statements>;
End-if;
– Relational Operators
• = Equal To
• != , <> Not Equal To
• > , >= Greater than , Greater than or Equal to
• < , <= Less than , Less Than or Equal to
– Relational Operators
• NOT
• AND
• OR
8
PeopleCode Statements
ERROR statement
Error (“<message>”);
WARNING statement
Warning (“<message>”);
EVALUATE statement
Evaluate <field or &variable>
When = <Value1>
<PeopleCode statements>;
--------------------------------
When-Other
<PeopleCode statements>;
End-Evaluate
BREAK statement
Break;
9
PeopleCode Statements
For Loop
For <&variable> = <Start-Value> to <End-Value> [step <stepvalue>]
statement;
statement;
End-For;
While Loop
While <condition>
statement;
statement;
End-While;
Repeat-Until Loop
Repeat
statement;
statement;
Until <condition>;
10
Component Processor
• Controls how PeopleSoft manages applications from Initial
data retrieval through updating the database
• Throughout the process, Component Processor applies
PeopleCode at different time
• PeopleCode events fire at particular times and in particular
sequence during flow of execution
11
Component Processor
General Areas where the Component Processor Performs PeopleCode
– During the Search Process
– Before the displaying the Page
– After a field Changes
– After inserting and deleting a row
– After page is saved
– After processing pop-menus
Search Events
• SearchInit fires before the search dialog box appears to initialize fields or apply defaults to search
• After entering appropriate search values and Search push button is clicked, SearchSave PeopleCode will perform. It is
used to either force a user to enter a value into the dialog, restrict the ranges of codes that can be added, or edit the
valued entered
• Both the Search PeopleCode event will perform if the PeopleCode is attached to the search records to fields that
appear in the dialog (Search Keys and Alternate Search Keys)
12
Component Processor
Field Action Events
• FieldEdit and FieldChange are activated when the value of a field is changed
• FieldEdit validates the new value. FieldChange does the processing based on the new (and valid) value of the field
13
Component Processor
Pop-Up Menu Events
• PrePopup event fires before the pop-up menu is displayed. This allows a PeopleCode program to conditionally alter
the appearance of one or more menu items. For instance, a menu can be disabled (grayed out) or hidden temporarily.
• If the user selects a menu item from the Pop-up list that has a PeopleCode program attached to it, then the
ItemSelected event will fire.
Add Action
• Add Processing is handled quite a bit differently by the Component Processor. For rows added with a new search
(high-level) key, a flow of RowInit, SearchInit, FieldEdit, FieldChange, SaveEdit, and then finally SearchSave is
processed prior to User receiving the GUI.
Deferred Processing
• In PIA architecture all the component buffers are on the Application Server and all the PeopleCode is executed on the
Application Server. This can result in a performance impact when there is a lot of field action processing – that is
FieldEdit and FieldChange peoplecode, along with standard system field edits.
Mitigating the Performance Impact
• No automatic trip back to server. In other words, if a field is changed and there is no FieldEdit or FieldChange
PeopleCode on the field, record defaults and FieldDefault PeopleCode will not be run until some other action causes
the trip to the server
• Developers are encouraged to put FieldEdit validations in SaveEdit to save trips to server
• Developers have the option of enabling the deferred processing, which will will automatically defer standard fields
edits, FieldEdit and FieldChange events.
14
PeopleCode Events
SearchInit (SrI) PeopleCode
• Performs before the search record dialog box displays.
• Controls processing before a user enters values in the search key and alternate search keys
• Only performs only if the search record with search keys and alternate search key is associated with the peoplecode
PSUSERSELF_SRCH.OPRID = %OperatorId;
SetSearchDialogBehaviour(0);
15
PeopleCode Events
PreBuild PeopleCode
• Component PeopleCode event
• Fires before the rest of the component build events
• Often used to hide or unhide pages
• Also used to set global or component scope variables that can be used later by PeopleCode located in other events
If None(STUDENT_TBL.STUDENT_ID) Then
STUDENT_TBL.STUDENT_ID = “NEW”;
End-If;
16
PeopleCode Events
RowInit (Rin) PeopleCode
• Performs the first time the component processor encounters a row of data. This occurs for every new row of data
brought into the component after the buffer allocation process.
• It also occurs when a users performs a RowInsert, but just on the one new row of data.
If None(PS_STUDENT_TBL.STUDENT_ID) Then
Gray(PS_STUDENT_TBL.STUDENT_ID);
End-If;
PostBuild PeopleCode
• Component PeopleCode event
• Used to Calculate values and set display characteristics of an object
Activate PeopleCode
• Page PeopleCode event
• Fires each time a page is activated
• Page Processing, such as enabling a field or hiding a scroll
SetGridLables(%Panel, Record.AMM_CHNL_SECVW);
17
PeopleCode Events
FieldEdit (FEd) PeopleCode
• Performed after a field has changed and a new value fo the field satisfies the standard system edits
• Used to validate the contents of the field
• Assignments statements should not be performed in FieldEdit
RowInsert PeopleCode
• Performed when a new row is added
• Used to Override effective-dated processing, or to auto number new rows of data
18
PeopleCode Events
RowDelete (RDe) PeopleCode
• Performed when a new row is deleted
• Used to caculate running totals or prevent a row from being deleted
• After the RowDelete finishes, the Component processor performs FieldDefault and FieldFormula peopleCode.
RowInsert PeopleCode
• Performed when a new row is added
• Used to Override effective-dated processing, or to auto number new rows of data
19
PeopleCode Events
SaveEdit (SEd) PeopleCode
• Performed when tries to save the component
• Used to validate data before it is updated to the database
• SaveEdit makes sure that all the changes have been made before the validation takes place
20
PeopleCode Variables
• User-defined variables are required for temporarily holding
the data in PeopleCode
• All variable names must begin with & and can be
maximum in 18 characters in length, including the
ampersand.
• Fields from Derived/Work Records add more flexibility to
the system as they can be placed on the pages
21
PeopleCode Variables
Variable Type Duration (Scope) Purpose Disadvantage
22
PeopleCode Variables
• LOCAL <type> &VarName;
<type> = Number String Boolean Date Time Datetime Object Any Float Integer
• System Variables
• %Date
• %Time
• %UserId
• %Mode
• %Page
23
Object Oriented Programming
• PeopleSoft delivers classes of objects that one can manipulate with PeopleCode
• METHOD is a procedure or routine, associated with one or more classes, that acts
on an object.
24
Object Oriented Programming
INSTANTIATING OBJECTS
• Usually Instantiated (created from their class) using built in functions or methods of other
objects
• Some objects are instantiated by the data already present in the buffer
• Some objects are instantiated from an already created definition like a Component Interface
• Eg: following returns a record object for a record already in the page buffer
Local Record &REC1, &REC2; /* Declare */
&REC1 = GetRecord(); /* Instantiate */
&REC2 = CreateRecord(RECORD.COURSE_TBL); /* Instantiate */
25
Object Oriented Programming
OBJECT PROPERTIES
• To set or get characteristics of an object, or to determine the state of an object, the properties
of the object need to be accessed using the DOT NOTATION syntax
• Object.Property = Value;
Eg: (i) &Field.Visible = False;
(ii) &x = &Field.Value;
(iii) If &Rowset.ActiveRowCount <> &I
Some of the properties of Field Class are as follows,
• Visible
• Value
• Name
• Label
• IsYesNo
• IsKey
• Enabled
• EditError
26
Object Oriented Programming
OBJECT METHODS
• In order to execute a method, the reference to an object is followed by the DOT NOTATION
(period) and then the method name. Methods are easily identified by parentheses appearing
after the method name.
• Object.Method();
Eg: (i) If &REC1.GetField(&R).Name = “NEW” then
(ii) If &REC1.CompareFields(&REC2) then
(iii) If &ROW = &ROWSET.GetCurrRow();
27
Object Oriented Programming
PASSING OBJECTS
• All PeopleCode objects can be passed as function parameters, thus enabling the application
developer to pass complete data structures between peoplecode functions
&ROWSET = GetLevel0();
Process_Rowset(&ROWSET);
28
PeopleCode Functions
CATEGORIES OF FUNCTIONS
• Internal-PeopleCode:
A PeopleCode routine that is stored in the same program where it is used. Defined by a Function
statement.
• External-PeopleCode
A PeopleCode routine that is stored in a different program from where it is used. Defined by a
declare statement with the keyword PeopleCode
• External-Non-PeopleCode
A common C++ (or other language routine that is loaded from DLL. Defined by a Declare
statement with the keyword library.
FUNCTION STATEMENT
29
PeopleCode Functions
DECLARING A FUNCTION
CALLING A FUNCTION
PeopleCode Functions are called using the name of the function and passing the correct number
of parameters in paratheses. The number of parameters need to match the parameters used by
the function
RETURNS STATEMENT
30
PeopleCode Functions
BUILT-IN FUNCTION
• Page Buffer Functions: Modify fields, values & variables within the buffers
• Scroll Buffer Functions: Manipulate scroll area records for various purposes
• Logical Functions: Check if values exist for a field
• Date & Time Funcs: Used to easily calculate & manipulate dates
• String Functions: With with character strings
• Double-Byte Char Funcs: Supports the languages that utilise double-byte char’s
• Number functions: Work with numeric values
• DOS functions: Control DOS processes
• API functions: Include WinExec WorkFlow, RemoteCall etc…
31
PeopleCode Functions
MESSAGE CATALOG FUNCTION
• MsgGet
MsgGet (<MessageSet>, <MessageNum>,”DefaultMsgTxt”[,<Bind1>,…])
• MsgGetText
MsgGetText(<MessageSet>, <MessageNum>,”DefaultMsgTxt”[,<Bind1>,…])
32
PeopleCode Functions
Gray/Ungray and Hide/Unhide FUNCTION
• Procedural Method
Gray(<recordname.fieldname>);
UnGray(<recordname.fieldname>);
&Field.IsChanged
&Record.IsNew
&Row.IsDeleted
33
PeopleCode Functions
Other Important Functions FUNCTION
• PriorValue
• RTrim, Ltrim, Substring
• OriginalValue
• SetCursorPos Method
&Qty = GetField(PSU_PO_DTL.QTY);
If All(&Qty.OriginalValue) then
&Orig_Qty = &Qty.OriginalValue;
if &Qty.value > &Orig_Qty then
Error MsgGet(20000,30,”Message Not Found”);
End-If;
End-If;
34
Accessing Buffer
• ActiveRowCount
<RowSetName>.ActiveRowCount
• TotalRowCount
<RowSetName>.TotalRowCount
• Value,FetchValue and UpdateValue
<RowNumber>.<RecordName.Fieldname>.value /* Object Based */
FetchValue(<RecordName.Fieldname>,<RowNumber>) /* Procedural */
UpdateValue(<RecordName.Fieldname>,<RowNumber>) /* Procedural */
35
Accessing Buffer
&RowSet = GetLevel0();
&RowSet = GetRowSet(Scroll.RecordName);
&RowSet = &Row.GetRowSet(Scroll.RecordName);
&Row = &RowSet.GetRow(n);
&Record = &Row.GetRecord(RECORD.RecordName);
&Field = &Record.GetField(FIELD.Fieldname);
36
Traversing Buffer
TRAVERSING = ROWSET > ROW > RECORD > FIELD
&RS0 = GetLevel0();
&RS1 = &Row0.GetRowSet(Scroll.Level1-Record);
&Rec1 = &Row1.GetRecord(Record.Recordname);
OR
&Rec1 = &Row1.Recordname;
37
38
39
40
41
42
43
44
45
46
47
48
49
PeopleCode Variables
50