0% found this document useful (0 votes)
177 views

People Code

The document provides an overview of PeopleCode, including the PeopleCode editor, language, programs, events, and debugger. It discusses the PeopleCode editor interface and how to select events. It also describes the PeopleCode language syntax and elements like data types, comments, statements, functions, expressions, and variables. Finally, it covers how PeopleCode programs are associated with different events for records, components, pages, and menu items.

Uploaded by

youssef MCH
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
177 views

People Code

The document provides an overview of PeopleCode, including the PeopleCode editor, language, programs, events, and debugger. It discusses the PeopleCode editor interface and how to select events. It also describes the PeopleCode language syntax and elements like data types, comments, statements, functions, expressions, and variables. Finally, it covers how PeopleCode programs are associated with different events for records, components, pages, and menu items.

Uploaded by

youssef MCH
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 115

Capgemini India – PeopleSoft Practice

Capgemini India – PeopleSoft PeopleCode


Presentation

March 2007
Agenda
 PeopleCode Editor
 PeopleCode Language
 PeopleCode Programs and Events
 PeopleCode Component Processor
 Component Buffer
 Using Errors and Warnings
 System Variables
 Meta SQL
 PeopleCode Debugger
Capgemini India – PeopleSoft Practice

PeopleCode Editor
PeopleCode Editor…

 PeopleSoft Application Designer supplies an independent


editor window for each parent definition, such as a record
definition, menu or message, for which you invoke the editor.
PeopleCode Editor

 Use the PeopleCode Editor’s drop-down event list to select


an event from the event set of the currently selected
definition. Use this event list to navigate between
PeopleCode programs that are associated with that definition.
For every definition-event combination with associated
PeopleCode, the event name is displayed in bold, and it
appears at the top of the event list.
Capgemini India – PeopleSoft Practice

PeopleCode Language
PeopleCode Language…

 In its fundamentals, PeopleCode syntax resembles other


programming languages.

 It includes
• Data types.
• Comments
• Statements.
• Functions.
• Expressions.
• Operators.
PeopleCode Language – Data Types

 The data types are divided into two categories

• Conventional data types.


• Object data types.
PeopleCode Language – Conventional Data types

 Any - When variables and function return values are


declared as Any, the data type is indeterminate, enabling
PeopleTools to determine the appropriate type of value
based on context. Undeclared local variables are Any by
default.

 Boolean
 Date
 DateTime
 Float
 Integer
 Number
 Object
 String
 Time
PeopleCode Language – Object Data types

 PeopleCode includes these data buffer access types:

• Field
• Record
• Row
• Rowset

 PeopleCode includes these display data types:’

• Grid
• GridColumn
• Page
PeopleCode Language – Object Data types

 PeopleCode includes these miscellaneous data types:

• AESection
• Array
• File
• Message
• SQL
PeopleCode Language – Comments

The following are the ways to insert comments into PeopleCode:

 You can surround comments with /* at the beginning and */ at the end.

 You can also use a REM (remark) statement for commenting.

Put a semicolon at the end of a REM comment. If you do not, everything up


to the end of the next statement is treated as part of the comment.

 You can surround commented text with <* at the start and *> at the end.

Generally use this when you're testing code and want to


comment out a section that already contains comments.

<* this program is no longer valid;


/* Next row is based on new value of EFFDT. */
calc_next_compchg(EFFDT, EFFSEQ, 0);
/* Next row is based on new value of EFFDT. */
*>
calc_next_compchg(EFFDT, EFFSEQ, 0);
PeopleCode Language – Statements

 A statement can be a declaration, an assignment, a program


construct (such as a Break statement or a conditional loop),
or a subroutine call.
 This section includes:
• Separators.
• Assignment statements.
• Language Constructs.
• Branching statements. (If and Evaluate)
• Conditional loops. (For, Repeat, and While)

variableName = expression;
PeopleCode Language – Statements

 If, Then, and Else statements


If condition Then
[statement_list_1]
[Else
[statement_list_2]]
End-if;

 Evaluate Statement

evaluate &USE_FREQUENCY
when = "never"
PROD_USE_FREQ = 0;
Break;
when = "sometimes"
PROD_USE_FREQ = 1;
Break;
when = "frequently"
PROD_USE_FREQ = 2;
Break;
when-other
Error "Unexpected value assigned to &USE_FREQUENCY."
end-evaluate;
PeopleCode Language – Statements

 Repeat Statement

 When Statement
PeopleCode Language – Functions

 Supported functions.

 Function definitions.

 Function declarations.

 Function calls.

 Function return values.

 Function naming conflicts.


PeopleCode Language – 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 (using the Function statement)


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 (C-callable)


libraries.
PeopleCode Language – Functions definitions

 PeopleCode functions can be defined in any PeopleCode


program. Function definitions must be placed at the top of the
program, along with any variable and external function
declarations.

 By convention, PeopleCode programs are stored in records


whose names begin in FUNCLIB_, and they are always
attached to the FieldFormula event (This would be studied
later in the session).
PeopleCode Language – Functions Definitions

Example:

If DeleteRow(RECORD.BUS_EXPENSE_PER, &L1_ROW,
RECORD.BUS_EXPENSE_DTL, &L2_ROW) then
WinMessage("Row deleted.");
else
WinMessage("Sorry -- couldn’t delete that row.");
end-if;
PeopleCode Language – Functions declarations

 An external call to a function from a PeopleCode program, it


must declare be declared at the top of the program.

 For e.g
Declare Function UpdatePSLOCK PeopleCode FUNCLIB_NODES.MSGNODENAME
FieldFormula;
PeopleCode Language – Functions calls and Return values

 Functions are called with this syntax:


function_name([param_list])

The parameter list (param_list),is a list of expressions,


separated by commas, that the function expects you to supply.
Items in the parameter list can be optional or required.

 Functions can return values of any supported data type;


some functions do not return any value.
PeopleCode Language – Functions naming conflicts

 If a function is defined with the same name as a built-in


function, the function that one defines takes precedence over
the built-in function.

 During compilation, a warning message appears in the


Validate tab, indicating that a user-defined function has the
same name as an existing built-in function.
PeopleCode Language – Expressions

 Constants
• Numeric Constants
• String Constants
• Boolean Constants
• Null Constants
• User-Defined Constants

 Variables
• User Defined variables
• System Variables

Local String &MyString = "New";


Local Date &MyDate = %Date;
You can declare more than one variable on a single line but you can only
initialize one variable on a line. The following code creates a syntax error
when you try to save the program:

Local Number &N1, &N2 = 5;


PeopleCode Language – Variables Declaration and Scope

The difference between the variable declarations concerns their life


spans:

 Global
The variable is valid for the entire session.
 Component
The variable is valid while any page in the component in which the variable
is defined stays active.
 Local
The variable is valid for the duration of the PeopleCode program or function
in which the variable is defined.

You can declare variables using the Global, Local, or Component statements, or
you can use local variables without declaring them.

Examples:
Local Number &AGE;
Global String &OPER_NICKNAME;
Component Rowset &MY_ROWSET;
Capgemini India – PeopleSoft Practice

PeopleCode Programs and Events


PeopleCode Programs and Events

 Understanding how Peoplecode programs are associated


with events.

• Access PeopleCode in PeopleSoft Application Designer.


• Access record field PeopleCode.
• Access component record field PeopleCode.
• Access component record PeopleCode.
• Access component PeopleCode.
• Access page PeopleCode.
• Access menu item PeopleCode.
• Copy PeopleCode with a parent definition.
• Upgrade PeopleCode programs.
Access PeopleCode in PS Application Designer

 PeopleCode can be accessed with PS App Designer


definitions in several ways.
• With record fields and pop-up menu items, the Project view displays
PeopleCode programs within the project hierarchy using a lightning
bolt symbol.
• Double-click a record field or pop-up menu item program in the Project
view to start the PeopleCode Editor and load that program for editing.
PeopleCode Events
Access record field PeopleCode…

 A record is a table-level definition. There are different types of


record definitions, such as Structured Query Language (SQL)
table, dynamic view, derived/work, and so on.

 Record fields are child definitions of records. Record field


PeopleCode programs are child definitions of record fields. A
record field can have zero or one PeopleCode programs for
each event in the record field event set.
Access record field PeopleCode

 The following are the events that are associated with a record
field: 
• FieldChange Event
• FieldDefault Event
• FieldEdit Event
• FieldFormula Event
• RowInit Event
• RowSelect Event
• RowDelete Event
• PrePopup Event
• SaveEdit Event
• SavePreChange Event
• Workflow Event
• SavePostChange Event
• SearchInit Event
• SearchSave event
Access component record field PeopleCode

 Component record field PeopleCode is associated with a


record field, but only with respect to a particular component
and one of its events. This PeopleCode is only accessible
through the component structure view, not from a record
definition.

 The following events are associated with a component record


field:
• FieldChange Event
• FieldDefault Event
• FieldEdit Event
• PrePopup Event
Access component record PeopleCode

 Component record PeopleCode is associated with a record


field, but only with respect to a particular component and one
of its events. This PeopleCode is only accessible through the
component structure view, not from a record definition.

 The following events are associated with a component


record:
• SearchInit Event
• SearchSave Event
• RowDelete Event
• RowInit Event
• RowSelect Event
• SaveEdit Event
• SavePostChange Event
• SavePreChange Event
Access component PeopleCode

 To access PeopleCode associated with a component record,


open the component’s structure view, select a record, right-
click the record name, and select View PeopleCode.

 Component PeopleCode is associated with a component


definition and an event.

 The following events can be associated with a component:

• PostBuild Event
• PreBuild Event
• SavePostChange Event
• SavePreChange Event
• Workflow Event
Access page PeopleCode

 Page PeopleCode is associated with a page definition. The


page event set consists of a single event, the Activate event,
which fires every time the page is activated. This event is
valid only for pages that are defined as standard or
secondary, and is not supported for subpages.
Access menu item PeopleCode

 PeopleTools menus are either one of two types


• pop-up and
• standard,
both of which are standalone definitions in the project
hierarchy. However, you can only associate PeopleCode with
menu items in pop-up menus.

 The menu item event set consists of a single event, the


ItemSelected Event. This event fires whenever an user
selects a menu item from a pop-up menu.
PeopleCode Events - Activate

The Activate event is initiated each time that a page is


activated, including when a page is first displayed by a user,
or if a user presses Tab between different pages in a
component. Each page has its own Activate event.
PeopleCode Events - FieldChange

Use FieldChange PeopleCode to recalculate page field


values, change the appearance of page controls, or perform
other processing that results from a field change other than
data validation. To validate the contents of the field, use the
FieldEdit event.

FieldChange PeopleCode is often paired with RowInit


PeopleCode.
PeopleCode Events - FieldDefault

The FieldDefault PeopleCode event enables you to


programmatically set fields to default values when they are
initially displayed. This event is initiated on all page fields as
part of many different processes;

However, it triggers PeopleCode programs only when the


following conditions are all true:
 The page field is still blank after applying any default value
specified in the record field properties.
 This is true if there is no default specified, if a null value is
specified, or if a 0 is specified for a numeric field.
 The field has a FieldDefault PeopleCode program.
PeopleCode Events - FieldEdit

Use FieldEdit PeopleCode to validate the contents of a field,


supplementing standard system edits. If the data does not
pass the validation, the PeopleCode program should display
a message using the Error statement, which redisplays the
page, displaying an error message and turning the field red.
PeopleCode Events - FieldFormula

The FieldFormula event is not currently used. Because


FieldFormula PeopleCode initiates in many different contexts
and triggers PeopleCode on every field on every row in the
component buffer, it can seriously degrade application
performance. Use RowInit and FieldChange events rather
than FieldFormula.
PeopleCode Events - PostBuild

 The PostBuild event is initiated after all the other component


build events have been initiated. This event is often used to
hide or unhide pages. It’s also used to set component
variables.
 PostBuild PeopleCode is only associated with components.
PeopleCode Events - PreBuild

The PreBuild event is initiated before the rest of the


component build events. This event is often used to hide or
unhide pages. It’s also used to set component variables.
PeopleCode Events - RowInit

 The RowInit event is initiated the first time that the


Component Processor encounters a row of data. IUse it to
set the initial state of component controls. This occurs during
component build processing and row insert processing. It
also occurs after a Select or SelectAll Rowset method, or a
ScrollSelect or related function, is executed. RowInit is not
field-specific: it triggers PeopleCode on all fields and on all
rows in the component buffer.

 RowInit is not field-specific: it triggers PeopleCode on all


fields and on all rows in the component buffer.
PeopleCode Events - RowInsert

 When a user adds a row of data, the Component Processor


generates a RowInsert event. You should use RowInsert
PeopleCode for processing specific to the insertion of new
rows. Do not put PeopleCode in RowInsert that already exists
in RowInit, because a RowInit event always initiates after the
RowInsert event, which will cause your code to be run twice.

 The RowInsert event triggers PeopleCode on any field on the


inserted row of data.
PeopleCode Events - RowDelete

 The RowDelete event is initiated whenever a user attempts to


delete a row of data from a page scroll area.
 Use RowDelete PeopleCode to prevent the deletion of a row
(using an Error or Warning statement) or to perform any other
processing contingent on row deletion.

For example, you could have a page field called Total on


scroll area level zero whose value is the sum of all the
Extension page fields on scroll area level one. If the user
deleted a row on scroll area level one, you could use
RowDelete PeopleCode to recalculate the value of the Total
field.
 The RowDelete event triggers PeopleCode on any field on
the row of data that is being flagged as deleted.
PeopleCode Events - RowSelect

 The RowSelect event is initiated at the beginning of the


component build process in any of the update action modes
(Update, Update/Display All, Correction). RowSelect
PeopleCode is used to filter out rows of data as they are
being read into the component buffer. This event also occurs
after a ScrollSelect or related function is executed.
PeopleCode Events - SaveEdit

 The SaveEdit event is initiated whenever a user attempts to


save the component. You can use SaveEdit PeopleCode to
validate the consistency of data in component fields.
Whenever a validation involves more than one component
field, you should use SaveEdit PeopleCode. If a validation
involves only one page field, use FieldEdit PeopleCode.
 SaveEdit is not field-specific: it triggers associated
PeopleCode on every row of data in the component buffers,
except rows flagged as deleted.
 An Error statement in SaveEdit PeopleCode displays a
message and redisplays the component without saving data.
A Warning statement enables the user to click OK and save
the data, or to click Cancel and return to the component
without saving.
PeopleCode Events - SavePreChange

 The SavePreChange event is initiated after SaveEdit


completes without errors. SavePreChange PeopleCode
provides one final opportunity to manipulate data before the
system updates the database; for instance, you could use
SavePreChange PeopleCode to set sequential high-level
keys. If SavePreChange runs successfully, a Workflow event
is generated, and then the Component Processor issues
appropriate Insert, Update, or Delete SQL statements.
 SavePreChange PeopleCode is not field-specific: it triggers
PeopleCode on all fields and on all rows of data in the
component buffer.
 SavePreChange PeopleCode can be associated with record
fields, components, and component records.
PeopleCode Events - Workflow

 Workflow PeopleCode executes immediately after the


SavePreChange event and before the database update that
precedes the SavePostChange event. The Workflow event
segregates PeopleCode related to workflow from the rest of
the application’s PeopleCode. Only PeopleCode related to
workflow (such as TriggerBusinessEvent) should be in
workflow programs. Your program should deal with the
Workflow event only after any SavePreChange processing is
complete.
 Workflow PeopleCode is not field-specific: it triggers
PeopleCode on all fields and on all rows of data in the
component buffer.
 WorkFlow PeopleCode can be associated with record fields
and components.
PeopleCode Events - SavePostChange

 After the Component Processor updates the database, it


initiates the SavePostChange event. You can use
SavePostChange PeopleCode to update tables not in your
component using the SQLExec built-in function.
 An error or warning in SavePostChange PeopleCode causes
a runtime error. Avoid errors and warnings in this event.
 The system issues a SQL Commit statement after
SavePostChange PeopleCode completes successfully.
 If you are executing Workflow PeopleCode, keep in mind that
if the Workflow PeopleCode fails, SavePostChange
PeopleCode is not executed. If your component has both
Workflow and SavePostChange PeopleCode, consider
moving the SavePostChange PeopleCode to
SavePreChange or Workflow.
PeopleCode Events - SearchInit

 The SearchInit event is generated just before a search, add,


or data-entry dialog box is displayed. SearchInit triggers
associated PeopleCode in the search key fields of the search
record. This enables you to control processing before a user
enters values for search keys in the dialog box. In some
cases, you may want to set the value of the search dialog
fields programmatically. For example, the following program
in SearchInit PeopleCode on the component search key
record field EMPLID sets the search key page field to the
user’s employee ID, makes the page field unavailable for
entry, and enables the user to modify the user’s own data in
the component:
EMPLID = %EmployeeId;
Gray (EMPLID);
PeopleCode Events - SearchSave

 SearchSave PeopleCode is executed for all search key fields


on a search, add, or data-entry dialog box after a user clicks
Search. This enables you to control processing after search
key values are entered, but before the search based on these
keys is executed. A typical use of this feature is to provide
cross-field edits for selecting a minimum set of key
information. This event is also used to force a user to enter a
value in at least one field, even if it’s a partial value, to help
narrow a search for tables with many rows
 You can use Error and Warning statements in SearchSave
PeopleCode to send the user back to the search page if the
user entry does not pass validations implemented in the
PeopleCode.
PeopleCode Events - PrePopup

 The PrePopup event is initiated just before the display of a


pop-up menu.
 You can use PrePopup PeopleCode to control the
appearance of the pop-up menu.
PeopleCode Events - ItemSelected

The ItemSelected event is initiated whenever a user selects a


menu item from a pop-up menu. In pop-up menus,
ItemSelected PeopleCode executes in the context of the
page field from where the pop-up menu is attached, which
means that you can freely reference and change page fields,
just as you could from a button.
Capgemini India – PeopleSoft Practice

PeopleCode Component Processor


PeopleCode Component Processor

 The Component Processor is the PeopleTools runtime


engine that controls processing of an application from the
time that a user requests a component from an application
menu until the database is updated and
processing of the component is complete.

Following points are covered in this section:


• Events Outside the Component Processor Flow
• How PeopleCode Programs Are Triggered
• Component Processor Behavior
• Processing Sequences
• PeopleSoft Internet Architecture Processing Considerations
• Deferred Processing Mode
• PeopleCode Execution in Multiple Scroll Pages
Events Outside the Component Processor Flow

 Application Message events


 PeopleCode in an Application Engine action
 User-defined methods of Component Interface
 PeopleCode in the Application Class
How PeopleCode Programs Are Triggered

 PeopleCode can be associated with a PeopleCode record


field, a component record, and many other items.
 PeopleCode events fire at particular times, in particular
sequences, during the course of the Component
Processor's flow of execution. When an event fires, it
triggers PeopleCode programs on specific objects.
 E.g.: Tabbing out from a field
» FieldEdit PeopleCode of record field is executed
first
» FieldEdit PeopleCode of the component record is
executed next
How PeopleCode Programs Are Triggered

 Execution order of Events


The PeopleCode program associated with the record field event is
initiated first, and then the PeopleCode program associated with the
like-named component event is initiated.

 The following events occur after a user changes a field:


Record.recordA.fielda.FieldEdit ->
Component.recordA.fielda.FieldEdit ->
Record.recordB.fieldb.FieldEdit ->
Component.recordB.fieldb.FieldEdit ->
Record.recordA.fielda.FieldChange ->
Component.recordA.fielda.FieldChange ->
Record.recordB.fieldb.FieldChange ->
Component.recordB.fieldb.FieldChange ->
Peoplecode Component Processor
Component Processor Behavior

 From Page Start to Page Display


 End-user actions in the component
Component Processor Behavior

Component Processor Behavior from Page Start to Page Display


 Before a user selects a component, the system is in reset state, in
which no component is displayed. The Component Processor’s flow of
execution begins when a user selects a component from a PeopleSoft
menu. The Component Processor then:
 Performs search processing, in which it obtains and saves search key
values for the component.
 Retrieves from the database server any data needed to build the
component.
 Builds the component, creating buffers for the component data.
 Performs any additional processing for the component or the page.
 Displays the component and waits for user action.
Component Processor Behavior

From Page Start to Page Display:


Component Processor Behavior

End-user actions in the component


 After the component is built and displayed, the Component
Processor can respond to a number of possible end-user
actions
 Row Insert Processing, Row Delete Processing, Field
Modification, Prompts, Pop-up Menu Display, ItemSelected
Processing, PushButtons, Save Processing, Exit
Component
Processing sequences

 Default processing.
 Search processing in update mode.
 Search processing in add mode.
 Component build processing in update mode.
 Row select processing.
 Component build processing in add mode.
 Field modification.
 Row insert processing.
 Row delete processing.
 Buttons.
 Prompts.
 Pop-up menu display.
 Selected item processing.
 Save processing.
Processing sequences

 Field Level Default Processing


Processing sequences

 Default Processing on Component level


Processing sequences

 Search Processing in Update mode


Processing sequences
 Search Processing in Add mode
Processing sequences

 Component Build Processing in Update Modes


Processing sequences

 Row Select Processing


Processing sequences

 Component Build Processing in Add Modes


Processing sequences

 Field Modification
Processing sequences

 Row Insert Processing


Processing sequences

 Row Delete Processing


Processing sequences

 Buttons
When a user presses a button, this initiates the same
processing as changing a field. Typically, PeopleCode
programs started by button are placed in the FieldChange
event.
 Prompts
No PeopleCode event is initiated as a result of prompts,
returning to the search page or displaying a calendar. This
process is controlled automatically by the system.
Note. When the value of a field is changed using a prompt,
the standard field modification processing occurs.
Processing sequences

 Pop-Up Menu Display


Processing sequences

 Selected Item Processing


Processing sequences

 Save Processing
PeopleSoft Internet Architecture Processing Considerations

 If an end-user changes a field, but there is nothing to cause


a trip to the server on that field, default processing and
FieldFormula PeopleCode don't run.
 In applications that run on the PeopleSoft portal, external,
dynamic hyperlink information must be placed in RowInit
PeopleCode. (If it's placed in FieldChange PeopleCode, it
won't work.)
Deferred Processing Mode

 Field modification processing is deferred.


 Drop-down list box values are static.
 No field modification processing is done during prompt
button processing.
 Field modification processing executes in field layout order.
 PeopleCode dependencies between fields on the page will
not work as expected.
 Some pushbuttons do not cause field modification
processing to execute. E.g.. Specifically, External Link, List
(Search), and Process pushbuttons .
 You can use a PeopleCode Command pushbutton to cause
field modification processing to execute.
 A scroll pushbutton (hyperlink) causes field modification
processing to execute.
PeopleCode Execution in Multiple Scroll Pages

 The Component Processor uses a "depth-first" algorithm to


process rows in multiple-scroll pages.
 Level One: The Component Processor processes record
definitions at scroll level zero, then all rows of data at scroll
level one. Data is retrieved for all rows with a single
SELECT statement, and then merged with buffer structures.
 Scroll Level Two: It processes a single row of data at scroll
level one, then processes all its subordinate rows of data at
scroll level two. After processing all subordinate data at
scroll level two, it processes the next row for scroll level
one, and all the subordinate data for that row.
 Scroll Level Three: The Component Processor uses the
same method for processing subordinate data at scroll level
three.
Capgemini India – PeopleSoft Practice

Component Buffer
Component Buffer

 PeopleCode frequently must refer to data in the Component Buffer—the area in


memory that stores data for the currently active component.
 There are two methods of specifying a piece of data in the Component Buffer
from within PeopleCode:
• contextual references, which refer to data relative to the location of
the currently executing PeopleCode program.
• references using scroll path syntax, which provide a complete—or
absolute—path through the Component Buffer to the referenced
component.
Component Buffer
Type and Location Presence in Component Buffer
of Record
Primary record on On scroll levels greater than zero all record fields from the primary scroll record are
scroll levels greater in the Component Buffer. This means that on levels greater than zero PeopleCode
than zero can refer to any record field on the primary scroll record, even if it is not associated
with a page control.

Primary record on If scroll level 0 of a page contains only controls associated with primary scroll
scroll level 0 record fields that are search keys or alternate search keys, then only the search
key and alternate search key fields will be in the Component Buffer: not the entire
record. The values for the fields come from the keylist, and the record won't run
RowInit PeopleCode. If level 0 contains at least one record field from the primary
scroll record that is not a search key or alternate search key, then all the record
fields from the primary scroll record will be available in the buffer. (For this reason
you may sometimes need to add one such record field at level 0 of the page to
make sure that all the record fields of the level-zero primary record can be
referenced from PeopleCode.)

Related display The buffer contains the related display record field, plus any record fields from the
record fields related display record that are referenced by PeopleCode programs. This means
that you can reference any record field in a related display record.

Derived/work record Only derived/work record fields associated with page controls are in the
fields Component Buffer. Other record fields from the derived/work record cannot be
referenced from PeopleCode.
Translate Table Only Translate Table fields associated with page controls are available in the
record fields Component Buffer. Other fields from the Translate Table cannot be referenced
from PeopleCode.
Component Buffer

Rowsets and Scroll Areas


 Rowset is a hierarchical data object that can represent an
entire scroll area and all of its subordinate scroll areas.
 A rowset can contain the entire contents of a component
buffer, or the contents of any lower-level scroll area plus all
of its subordinate buffer data. The hierarchical structure of
component levels—scroll area, row, record, field—is
provided by the new object data types, Rowset, Row,
Record, and Field.
 You can access any rowset, row, record, or field within the
buffer using the dot notation inherent in PeopleTools 8
object-oriented programming. This enables you to reference
fields within a record object, records within a row object,
and rows within a rowset object as properties of the parent
objects.
Component Buffer

Contextual Reference
 The current context comprises a subset of the buffer fields in
the component buffer, determined by the row of data where
a PeopleCode program is executing. The current context
includes:
All buffer fields in the row of data where the PeopleCode
program is executing.
All buffer fields in rows that are hierarchically superior to
the row where the PeopleCode program is executing.
 A contextual row reference uses a RECORD.recordname
component name reference to specify the scroll level of the
intended row, resulting in a reference to the current row at
the specified scroll level.
Component Buffer

 A contextual buffer field reference is a type of PeopleCode


expression that refers to a buffer field by specifying a record
field. The row of the buffer field is determined by the current
context of the PeopleCode program where the reference is
made. You can use a contextual buffer field reference to
retrieve or update the value in the buffer field, to pass the
buffer field value to a function, or to reference an instance of
a page control associated with the buffer field.
E.g. SOME_RECORD.SOME_FIELD = &VAL;
Component Buffer

 Understanding Scroll Path


Scroll Path Syntax with RECORD.recordname
[RECORD.level1_recname, level1_row,
[RECORD.level2_recname, level2_row, ]]
RECORD.target_recname

Scroll Path Syntax with SCROLL.scrollname


[SCROLL.level1_scrollname, level1_row,
[SCROLL.level2_scrollname, level2_row, ]],
SCROLL.target_scrollname

Scroll paths using SCROLL.scrollname are functionally identical to


those using RECORD.recordname, except that SCROLL.scrollname
expressions are more strict: they can refer only to a scroll level’s
primary record; whereas RECORD.recordname expressions can refer
to any record in the scroll level which in some rare cases can result in
ambiguous references.
Capgemini India – PeopleSoft Practice

Data Buffer
Data Buffer

 Definition:
Data buffer classes are used access the Component buffers
which are loaded when you open a component, or from
general data buffers, loaded by an Application Message, an
Application Engine program, a Business Component, and so
on.
Data Buffer Classes

The four data buffer classes relate to each other in a hierarchical manner:
 A field object, which is instantiated from the Field class, is a single
instance of data within a record and is based on a field definition.
 A record object, which is instantiated from the Record class, is a
single instance of a data within a row and is based on a record
definition. A record object consists of one to n fields.
 A row object, which is instantiated from the Row class, is a single
row of data that consists of one to n records of data. A single row in
a component scroll is a row. A row may have one to n child rowsets.
For example, a row in a level 2 scroll may have n level 3 child
rowsets.
 A rowset object is a data structure used to describe hierarchical
data. It is made up of a collection of rows. A component scroll is a
rowset. You can also have a level 0 rowset.
Data Buffer Class Objects

Object Type Code (Eg, for Component buffer access)


Rowset &LEVEL0 = GetLevel0();

Row &LEVEL0_ROW = &LEVEL0(1);

Rowset &LEVEL1 = &LEVEL0_ROW.GetRowset(SCROLL.EMPL_CHECKLIST);

For &I = 1 to &LEVEL1.ActiveRowCount

Row &LEVEL1_ROW = &LEVEL1(&I);

Rowset &LEVEL2 = &LEVEL1_ROW.GetRowset(SCROLL.EMPL_CHKLST_ITM);

For &J = 1 to &LEVEL2.ActiveRowCount

Row &LEVEL2_ROW = &LEVEL2(&J);

Record &RECORD = &LEVEL2_ROW.EMPL_CHKLST_ITM;

Field &FIELD = &RECORD.BRIEFING_STATUS;


/* Do processing */
End-For;
End-For;
Data Buffer

Directly accessing a field


Data Buffer

Accessing Secondary Component Buffer Data


When a secondary page is run, the data for its buffers is
copied from the parent component to a buffer structure for
the secondary page. This means there are two copies of
this data. The data buffer classes give access to both of
these copies of the data. Direct field references
(recname.fieldname) will always use the current context to
determine which value to access. So, in general, when
using a secondary page, make sure that all your references
are based on the secondary page.
Capgemini India – PeopleSoft Practice

Using Errors and Warnings


Using Errors and Warning

 Warning function in PeopleCode is to display a message


alerting the end-user about a potentially incorrect data entry
or change

 Error function in PeopleCode is used to stop processing and


display an error message.

• Errors and Warnings in FieldEdit


• Errors and Warnings in SaveEdit
• Errors and Warnings in RowSelect
• Errors and Warnings in RowDelete
• Errors and Warnings in Other Events
Errors and Warning in FieldEdit

 An error in FieldEdit prevents the system from accepting the


new value of a field. The Component Processor highlights the
offending field. The user must either change the field back to
its original value or to something else which does not trigger
the error. A warning enables the Component Processor to
accept the new data. The Component Processor does not
highlight any field that has warnings.
Errors and Warning in SaveEdit

 An error in SaveEdit prevents the system from saving any row of data.
The Component Processor does not update the database for any field if
one field has an error. Although the Component Processor displays an
error message, it does not turn any field red. Unlike FieldEdit errors,
SaveEdit errors can happen anywhere on the page or component, for any
row of data. The data causing the error may appear on a different page
within the same group, or a row of data not currently displayed. If this is
the case, the field in error is brought into view by the system.

 A warning in SaveEdit also is applied to all data in the page or


component, but the Component Processor will accept the data, if told to
by the user. In a FieldEdit warning, the Component Processor displays a
message box with the text and two pushbuttons—OK and the standard
Explain. In a SaveEdit warning, though, the message box contains an
additional pushbutton, Cancel. OK accepts the data, overriding the
warning and continuing the save process. Cancel ends the save process.
Errors and Warning in RowSelect

 Errors and warnings should no longer be used in RowSelect processing:


instead, use DiscardRow and StopFetching.

 RowSelect PeopleCode filters out rows of data after the system applies
search record criteria. It also can stop the Component Processor from
reading additional rows of data.

 A warning causes the Component Processor to reject the current row, but
the Component Processor does continue reading more data. An error
prevents any more data coming into the page or component. The
Component Processor accepts the row that causes the error, but doesn't
read any more data. If you want to reject the current row and stop loading
additional rows, you must issue a warning and an error.

 You must specify text for an error or warning, but the Component
Processor does not display messages from RowSelect. You can still use
the message text as a way of documenting the program.
Errors and Warning in RowDelete

 When you delete a row of data (F8), the system prompts you
to confirm. If you do confirm, RowDelete PeopleCode takes
place, that is, any record field RowDelete PeopleCode fires,
and any component record RowDelete PeopleCode. Errors
and warnings in RowDelete display a message box.

 A warning from RowDelete presents two choices—accept the


RowDelete (the OK pushbutton), or cancel the RowDelete
(the Cancel pushbutton). Perhaps after they read the warning
message, the user will appreciate the RowDelete. An error
from RowDelete PeopleCode prevents the Component
Processor from removing that row of data from the page.
Errors and Warning in Other Events

 You should not put errors or warning in PeopleCode attached


to any of the remaining events (FieldDefault, FieldFormula,
RowInit, FieldChange, RowInsert, SavePreChange,
WorkFlow, and SavePostChange). However, the Component
Processor may issue its own errors and warnings when
performing PeopleCode. When this happens, it means the
Component Processor tried to do something and failed, and it
cannot recover from the error.

 These Event types activate processing that an user has no


direct control over. So, if the Component Processor comes
across an error condition, the user cannot fix it. The
Component Processor cancels the transaction to avoid
unpredictable results.
Capgemini India – PeopleSoft Practice

System Variables
System Variables

 PeopleTools provides a number of system variables that


provide access to system information

 System variables are prefixed with the '%' character

 One can use these system variables, passing them as


parameters to functions or assigning their values to fields or
to temporary variables or using it as a constant.
System Variables

 There are many different System variables provided by PeopleTools. Listed below are
few frequently used ones
• %AsOfDate
• %Component
• %CompIntfcName
• %Currency
• %FilePath
• %Page
• %PasswordExpired
• %PermissionLists
• %Portal
• %Roles
• %RowSecurityPermissionList
• %ServerTimeZone
• %Session
• %Time
• %UserId
Capgemini India – PeopleSoft Practice

PeopleCode Debugger
PeopleCode Debugger

 PeopleCode Debugger

• an integrated part of PeopleSoft Application Designer.

• has a visual indicator of breakpoints, an arrow indicating the current line and the ability to step
through code.

• can inspect the value of a variable by 'hovering' your cursor over it and reading the pop-up
bubble help.

• provides variable inspection windows for Globals, Locals, Function Parameters, and
Component scoped variables.

• enables PeopleCode objects to be "expanded", so you can inspect their component parts.

• Access: Select Debug – PeopleCode Debugger Mode


PeopleCode Debugger Features

 PeopleCode Debugger features are listed below

• Visible current line of execution.

• Visible breakpoints.

• Hover inspect.

• Single debugger.

• Variable panes.
Visible current line of execution

 The current line indicator (green arrow displayed in left-hand


gutter) is shown in the following illustration
Visible breakpoints

 Visual indicators that signify breakpoint locations. In the


following example, the current line indicator (green arrow) is
shown at the first line, and the breakpoint (red dot displayed
in left-hand gutter) is on line 8
Hover inspect

 If the program is already running, you can see the actual


values for the variables by holding the cursor over them. The
current value is displayed in a pop-up window, as shown in
the following example
Single Debugger

 Each PeopleSoft session running on a machine can have its


own debugging session.

 However, there can only be one instance of the PeopleCode


debugger per session. If more than one instance of
PeopleSoft Application Designer is running for a session, only
one may be the active debugger at a given time.

 If the session is in debug mode, any component that is


started and that belongs to that session automatically goes
into debug mode.
Single Debugger

 After you exit debug mode by selecting Debug, Exit Debug


Mode or by exiting PeopleSoft Application Designer, all
components in that session go out of debug mode.

 If you exit a component, debugging continues with any


remaining open and running components.
Variable panes

 There are four types of variables panes:


• Local
• Global
• Component
• Parameter

 The Local, Global, and Component variable panes show


local, global, and component variables, respectively.
 The Parameter variable pane shows the value of parameters
passed in function declarations.
Capgemini India – PeopleSoft Practice

Thank You

You might also like