Академический Документы
Профессиональный Документы
Культура Документы
What is PeopleCode?
Structured programming language provided by PeopleSoft Associated with application designer definition and events Syntax resembles that of any other structured programming languages Has in-built functions and supports objects and classes
Why PeopleCode?
Carry out the business rules of the organization Simplifying Data Processing Data Validation
PeopleCode Events
Record Field Component Record Field Component Record Component Page Menu FieldChange FieldDefault FieldEdit FieldFormula PrePopup RowDelete RowInit RowInsert RowSelect SaveEdit 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
FieldEdit
Used to validate the contents of a field, supplementing the standard system edits Displays message if data does not pass validation Message can be both Error or Warning Fires on the specific field and row that just changed Can be associated with record fields and component record fields
FieldChange
Used to recalculate page field values Change the appearance of page controls Perform other processing that results from a field change other than data validation Fires on the specific field and row that just changed Can be associated with record fields and component record fields
FieldDefault
Enables to programmatically set fields to default values when they are initially displayed Can be associated with record fields and component record fields An Error or Warning issued will cause a runtime error and force cancellation of the component
FieldFormula
If a field data is changed, the row is not marked as changed in this event Often used in FUNCLIB_ (function library) record definitions to store shared functions Only associated with record fields Can degrade performance of the application
SavePreChange
Fires after SaveEdit completes without errors Provides one final opportunity to manipulate data before the system updates the database Not field-specific: it triggers PeopleCode on all fields and on all rows of data in the component buffer. Can be associated with record fields, components, and component records
SaveEdit
Fires whenever the end-user attempts to save the component Can be used to validate the consistency of data in component fields Usually used when validation involves more than one component field Not field-specific: it triggers associated PeopleCode on every row of data in the component buffers, except rows flagged as deleted can be associated with record fields and components
SavePostChange
Fires after Component Processor updates the database Error or Warning statement cannot be used in this event System issues a SQL Commit after SavePostChange PeopleCode completes successfully Can be associated with record fields, components, and component records
SearchInit
Generated just before a search dialog, add dialog, or data entry dialog box is displayed Control processing before the end-user enters values for search keys in the dialog box Will not fire if run from a Component Interface Can be associated with record fields and component search records
SearchSave
Executed for all search key fields on a search dialog, add dialog, or data entry dialog box after the end-user initiates search Is used to control processing after search key values are entered, but before the search based on these keys is executed Also used to force the user to enter a value in at least one field Does not fire when values are selected from the search list can be associated with record fields and component search records
PrePopUp
Fires just before the display of a pop-up menu Can be used to control the appearance of the Pop-up menu Can be associated with record fields and component record fields
RowDelete
Fires whenever end-user attempts to delete a row of data from a page scroll. Triggers PeopleCode on any field on the row of data that is being flagged as deleted Does not trigger programs on Derived/Work records Can be associated with record fields and component records
RowInit
Fires the first time the Component Processor encounters a row of data Used for setting the initial state of component controls Triggers PeopleCode on all fields and on all rows in the component buffer Error and Warning cannot be used in this event
RowInit Exceptions
Component Processor doesn't run RowInit PeopleCode for some record fields If record can be initialized entirely from the keys for the component, RowInit does not run Following must be true for RowInit to not run
The record is at level 0 Every record field that is present in the data buffers is also present in the keys for the component Every record field that is present in the data buffers is display-only RowInsert
Generated when end-user adds a row of data RowInit always fires after RowInsert, so same code should not be present in the two. Triggers PeopleCode on any field on the inserted row of data Warning and Error cannot be used in this event Can be associated with record fields and component records
RowSelect
Fires at the beginning of the Component Build process in any of the Update action modes (Update, Update/Display All, Correction) Used to filter out rows of data as they are being read into the component buffer Rarely used as it's inefficient to filter out rows of data after they've already been selected Can be associated with record fields and component records
Workflow
Executes immediately after SavePreChange and before the database update that precedes SavePostChange Main purpose is to segregate PeopleCode related to workflow from the rest of the applications PeopleCode Only PeopleCode related to workflow should be in workflow programs Not field-specific: it triggers PeopleCode on all fields and on all rows of data in the component buffer
PreBuild
Fires before the rest of the component build events Also used to validate data entered in the search dialog Only associated with components
PostBuild
Fires after all the other component build events have fired Usually used to hide or unhide pages Can also be used to set component variables Associated only with components
Activate
Fires each time the page is activated Each page has its own Activate event Main purpose of the Activate event is to segregate the PeopleCode that is related to a specific page from the rest of the applications PeopleCode Can use this event for security validation Can only be associated with pages Is valid only for pages that are defined as Standard or Secondary
ItemSelected
Fires whenever the end-user selects a menu item from a pop-up menu Executes in the context of the page field from where the pop-up menu is attached Only associated with pop-up menu items Does not fire if run from a Component Interface
Component Processor
The Component Processor is the PeopleTools runtime engine that controls processing of the application from the time the end-user requests a component from an application menu through the time that the database is updated and processing of the component is complete.
Component Processor Flow
Reset state and the search record After the Search Fields Action Events Row Action Events Save Action Events Pop-up Menu
Search Processing
SearchInit
Search Dialog Display
List Select
User Action
Search Button
Search Save
No Values or Rows found Unique value Returned
Default Processing
Field Level Default Processing
Any field blank, another field changed Else
Result
Field Formula
PostBuild
Activate
PeopleCode Variables
System variables
System variables provide access to system information. System variables have a prefix of the '%' character, rather than the '&' character. Use these variables wherever you can use a constant, passing them as parameters to functions or assigning their values to fields or to temporary variables.
User-defined variables
These variable names are preceded by an "&" character wherever they appear in a program. Variable names can be 1 to 1000 characters, consisting of letters A-Z and a-z, digits 0-9, and characters #, @, $, and _.
Scope of Variables:
Global Valid for the entire session. Component Valid while any page in the component in which it's defined stays active. Local Valid for the life of the PeopleCode program or function in which it's defined.
PeopleCode Functions
Built-in The standard set of PeopleCode functions described in PeopleCode Built-in 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 generally contained in record definitions serving as function libraries.
A method can only be executed from an object, using dot notation. You have to instantiate the object first.
Example 1
The following PeopleCode can be used in SaveEdit for validation of employee id Before saving If Record1.Empid = 0 Then Error Employee ID cannot be 0; End-If;
Example 2
The following PeopleCode can be used in FieldEdit for assigning dearness allowance based on the basic salary Evaluate Record1.Basic When < 10000 Record1.DA = 2000; Break; When > 10000 Record1.DA = 4000; End-Evaluate;
Reducing Trips to the Server Using Deferred Mode Using the Refresh Button Using Warning Messages Optimizing SQL Moving PeopleCode to a Component or Page Definition Writing More Efficient Code Watch references Break Statement in Evaluate Avoid Implicit conversion Using of SQL object. Preventing SQL Injection
THANK YOU