People Code1
-
Upload
testernoor -
Category
Documents
-
view
224 -
download
0
Transcript of People Code1
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 1/41
4/14/2012
PeopleCode
• PeopleCode - Proprietary scripting language
used in the development of PeopleSoft
applications.
• Closely integrated with objects that we
create and modify in Application Designer.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 2/41
4/14/2012
Areas Covered
• People Code Language
• People Code – Events
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 3/41
4/14/2012
PeopleCode Language
• Data Types
• Comments and Statements
• Functions
• Expressions
• Operators
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 4/41
4/14/2012
Data Types
· ANY
· NUMBER
· STRING
· BOOLEAN
· DATE
· DATETIME· TIME
· OBJECT (Ex: Field, Record, Page etc…)
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 5/41
4/14/2012
Comments
• REM This is an example of commenting single line
PeopleCode;
• /* ----- Logic for Compensation Change ----- */
• /* Recalculate compensation change for next row. Next
row is based on prior value of EFFDT. */
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 7/41
4/14/2012
Statements
• Separators
• Assignment Statements
• Language Constructs
• Functions
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 8/41
4/14/2012
Separators
• Statements are terminated with a
semicolon(;).
• Extra spaces and line breaks are ignored
(Removed by PeopleCode Editor while
saving code)
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 9/41
4/14/2012
Variable Declaration stmts.
Variable declaration statements: Global, Component, LocalEx: Global Number &Curr_Num;
Component Record &Dept_Rec;
Local String &First_Name_Str;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 10/41
4/14/2012
Variables and Assignment
Statements• field_or_var = expression;
(‘=‘ can be used both for assignment and
comparison)
• Variable names are preceded by an "&" character
• System variables are preceded by a percent (%)Eg. %DateTime, %DbName, %OperatorId,
%PanelGroup
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 11/41
4/14/2012
Language Constructs
PeopleCode language constructs include:
· Branching structures: If and Evaluate.
· Loops and conditional loops: For, Repeat, and While.· Break and Exit statements for escaping loops and
terminating program execution.
·
(Contd..)
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 12/41
4/14/2012
Language Constructs II
If condition Then
[statement_list_1]
[Else
[statement_list_2]]
End-if;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 13/41
4/14/2012
Language Constructs III
Evaluate left_term
When [relop_1] right_term_1
[statement_list]
.
.
When [relop_n] right_term_n
[statement_list]
[When-other
[statement_list]]End-evaluate;
To end the Evaluate after the execution of a When clause, youcan add a Break statement at the end of the clause:
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 14/41
4/14/2012
Language Constructs III
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."
end-evaluate;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 15/41
4/14/2012
Language Constructs IV
For count = expression1 to expression2
[Step i];
statement_list
End-for;Eg :&MAX = 10;
for &COUNT = 1 to &MAX;
WinMessage("Executing list, count = " | &COUNT);
end-for;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 16/41
4/14/2012
Language Constructs V
Repeat
statement_list
Until logical_expression;Ex: Repeat
x = y;
y = y + 1;
Until y > 10;The Repeat statement executes the statements instatement_list once, then evaluates logical_expression .If logical_expression is False the sequence of statementsis repeated until logical_expression is True.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 17/41
4/14/2012
Language Constructs VI
While logical_expression
statement_list
End-while;Ex: While y < 10
x = y;
y = y + 1;
End-While;The While statement evaluates logical_expression before
executing the statements in statement_list . It continuesto repeat the sequence of statements untillogical_expression evaluates to False.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 18/41
4/14/2012
Functions
• PeopleCode supports the following types of functions:
• Built-inSupplied along with PeopleSoft
• InternalDeclared in PeopleCode with keyword ―Function‖
• External PeopleCodePeopleCode functions defined outside the calling program – in record
definitions.
• External Non-PeopleCodeFunctions stored in external (C-callable) libraries.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 19/41
4/14/2012
FunctionsDefining the function
• Function run_status_upd(&PROCESS_INSTANCE, &RUN_STATUS)returns boolean;
&UPDATEOK = SQLExec("update PS_PRCS_RQST set run_status = :1 whereprocess_instance = :2", &RUN_STATUS, &PROCESS_INSTANCE);
If &UPDATEOK Then
Return True;
Else
Return False;
End-if;
End-function; .Function Declaration
declare function run_status_upd peoplecode FUNCLIB_MYUTILS.ZIP_EDITSFieldFormula;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 20/41
4/14/2012
Functions• PeopleCode Function Syntax
Declare Function function_name PeopleCode record_name.field_nameevent_type
declare function verifyzip PeopleCodeFUNCLIB_MYUTILS.ZIP_EDITS FieldFormula;
External Function Syntax
Declare Function function_name Library lib_name
[ALIAS module_name ]
[param_list][RETURNS ext_return_type [As pc_type]]
declare function pctest library "psuser.dll" (integer value as number) returnsinteger as number;
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 21/41
4/14/2012
PeopleCode Events and Objects
• Every PeopleCode program is associated with an object
and with an event. When an event fires on an object, it
triggers any PeopleCode program associated with that
object and that event.
• Each class of objects in Application Designer can have
an event set. An object can have zero or one PeopleCode
programs for each event in its event set.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 22/41
4/14/2012
PeopleCode Events and Objects
PeopleCode is associated with many types of definitions,
such:
RecordsPages
Components
Messages
Menus
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 23/41
4/14/2012
PeopleCode EventsRecord Field Component Record Field Component Record Component Page Menu
FieldChange
FieldDefault
FieldEdit
FieldFormula
PrePopup
RowDelete
RowInit
RowInsert
RowSelectSaveEdit
SavePostChg
SavePreChg
SearchInit
SearchSave
Workflow
FieldChange
FieldDefault
FieldEdit
PrePopup
RowDelete
RowInit
RowInsert
RowSelect
SaveEdit
SavePostChg
SavePreChg
SearchInit
SearchSave
PostBuild
PreBuild
SavePostChg
SavePreChg
Workflow
Activate ItemSelected
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 24/41
4/14/2012
FieldDefault Event
• Allows to programmatically set default values
• Fired on all page fields as part of many different processes; but
triggers only when the following conditions are all true:
– The page field is still blank after applying any default specified in therecord field properties. (This will be true if there is no default specified, if
a null value is specified, or if a 0 is specified for a numeric field.)
– The panel field has a FieldDefault PeopleCode program.
• In practice, FieldDefault PeopleCode normally defaults fields when
new data is being added to the page group; that is, in Add mode andwhen a new row is inserted into a scroll.
• Must attach FieldDefault PeopleCode to the specific field that is being
defaulted.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 25/41
4/14/2012
FieldEdit Event
• Used to validate the contents of a field, - supplements
standard system edits.
• Error, Warning and Message can be used
• If validation needs to check the contents of more than one
field — that is, if the validation is checking for consistency
across page fields — then SaveEdit PeopleCode need to be
used instead of FieldEdit.
• The FieldEdit event fires on the specific field and row that
just changed.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 26/41
4/14/2012
FieldChange Event
• Used to recalculate page field values.
• Fires on the specific field and row that just
changed.
• Do not use Error or Warning statements in
FieldChange PeopleCode
• Often paired with RowInit PeopleCode.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 27/41
4/14/2012
FieldFormula Event
• A vestige of early versions of PeopleTools
• Not used in recent applications
• Triggers PeopleCode on every field on
every row in the page buffer
• De-grades Application performance
• Replaced by RowInit and FieldChange
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 28/41
4/14/2012
RowInit Event
• Fires the first time the Application Processor encounters a
row of data.
• Happens during page group build processing and row
insert processing.
• RowInit is not field-specific: it triggers PeopleCode on all
fields and on all rows in the panel buffer.
• Do not use Error or Warning statements
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 29/41
4/14/2012
RowSelect Event
• Fires at the beginning of the Page Group Build
process in any of the Update action modes
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 30/41
4/14/2012
RowInsert Event
• Application Processor generates a RowInsert event,
whenever a row of data is added
• RowInit event always fires after the RowInsert event
• Do not repeat code both in RowInit and RowInsert
• Do not use a Warning or Error in RowInsert
• Row insertion can not be prevented conditionally – can be
prevented unconditionally by checking the no row insertcheck box in scroll bar’s panel field properties
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 31/41
4/14/2012
RowDelete Event
• Fires whenever a row is deleted
• Can be used to prevent deletion of a row
• Can be used for other contingent processing
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 32/41
4/14/2012
PrePopup Event
• Fires just before the display of a popup
menu defined by a developer attached to a
page field.• Does not fire for System popup Menu or
popup menu attached to panel background
• Used to control the appearance of the Popupmenu.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 33/41
4/14/2012
SaveEdit Event
• Fires whenever the user attempts to save the component.
• Used to validate the consistency of data in component
• triggers associated PeopleCode on every row of data in the
component buffers.
• SetCursorPos can be used to position cursor in the page
field that needs to be corrected.
• Assignment statement cannot be used.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 34/41
4/14/2012
SavePreChg Event
• Fires after SaveEdit completes withouterrors
• One last chance to manipulate data beforethe system updates the database
– Eg. Sequential numbers
• Not field-specific: it triggers PeopleCode onall fields and on all rows of data in the panelbuffer
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 35/41
4/14/2012
Workflow Event
• Executes immediately after SavePreChgand before the database update
• Purpose is to segregate PeopleCode relatedto Workflow from the rest of application'sPeopleCode.
• Not field-specific: it triggers PeopleCode onall fields and on all rows of data in the panelbuffer
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 36/41
4/14/2012
SavePostChg Event
• Fired after database update
• Used to update tables not defined in
components using SQLExec
– Eg. Log tables
• Do not use Error or Warning
• Fails if Workflow fails
• Never use commit or rollback
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 37/41
4/14/2012
SearchInit Event
• Generated just before a search dialog, adddialog, or data entry dialog is displayed
• Triggers associated PeopleCode in thesearch key fields of the search record
• Used to control the behavior of searchdialog box
• Used to initialize or default search key or altsearch key
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 38/41
4/14/2012
SearchSave Event
• Executed for all search key fields on a searchdialog, add dialog, or data entry dialog after theuser OKs the dialog
• Allows to control processing after search keyvalues are entered, but before the search based onthese keys is executed
• Error and Warning can be used to send back search dialog if validations fail
– Eg. Address validations - Flat No. and Door No.
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 39/41
4/14/2012
Menu PeopleCode
• Menus are of two types
– popup and
– standard,
both are standalone objects in the project
hierarchy.
• Menu PeopleCode programs are associatedwith menu items,
8/4/2019 People Code1
http://slidepdf.com/reader/full/people-code1 40/41
4/14/2012
ItemSelected Event
• Menu event set consists of a single event,
ItemSelected Event
• Fires whenever an operator chooses a menuitem from a popup menu;
• Is only associated with pop-up menus.