• No results found

People Code

N/A
N/A
Protected

Academic year: 2021

Share "People Code"

Copied!
28
0
0

Loading.... (view fulltext now)

Full text

(1)

Introduction

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

(2)

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

(3)

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

(4)

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

(5)

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

(6)

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

(7)

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

(8)

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

(9)

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

(10)

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 application’s 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

(11)

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

(12)

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 application’s 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

(13)

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

(14)

Search Processing

SearchInit

Search Dialog Display

User Action

Search Save

Search and fill list

Build Prompt List

Buffer Search Key values

List Select

Unique value Returned No Values or Rows found

Partial key value returned Search Button

(15)

Default Processing

Field Level Default Processing

Result

Field Formula

Field Level Default Processing

Else

Result

Any field blank, another field changed

Any field blank, another field changed Else

(16)

Default Processing

RowInit

PostBuild

Activate

Display Page, Wait for the user action

(17)
(18)

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

(19)

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.

(20)

PeopleCode Functions & Methods

PeopleCode also supports methods. The main difference

between a built-in function and a method is:

•A built-in function, in your code, is on a line by itself, and

does not (generally) have any dependencies. You do not

have to instantiate an object before you can use the

function.

•A method can only be executed from an object, using

dot notation. You have to instantiate the object first.

(21)

Data Buffer Access

• 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 two scroll may have n level three 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.

(22)
(23)

Accessing data from Data Buffer

Accessing Level 0

The following code instantiates a rowset object, from the Rowset class, that references the level 0 rowset, containing all the page data. It stores the object in the &LEVEL0 variable.

Example : &LEVEL0 = GetLevel0();

Rowset Object

Example: &ROWSET = GetRowset();

Record Object

Example: &REC = &ROW.GetRecord(RECORD.EMPL_CHECKLIST);

Field Object

(24)

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;

(25)

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

;

(26)

Debugging your Application

• Access the PeopleCode debugger

• Setup debugging Environment

• Set PeopleCode debugger log options

• Compile PeopleCode programs at once

• Use the Find In feature

(27)

How to improve performance (

with reference to PeopleCode

)?

• 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.

(28)

References

Related documents

In this present study, antidepressant activity and antinociceptive effects of escitalopram (ESC, 40 mg/kg) have been studied in forced swim test, tail suspension test, hot plate

Field experiments were conducted at Ebonyi State University Research Farm during 2009 and 2010 farming seasons to evaluate the effect of intercropping maize with

effect of government spending on infrastructure, human resources, and routine expenditures and trade openness on economic growth where the types of government spending are

In this section we introduce primitive recursive set theory with infinity (PRSω), which will be the default base theory for the rest of this thesis (occasionally exten- ded by

Results suggest that the probability of under-educated employment is higher among low skilled recent migrants and that the over-education risk is higher among high skilled

Finally, this study focuses on the influences of various parameters, such as the external stress regime, fluid viscosity and pre-existing fractures, on the

Such agreements are often defined by service level agreements (SLAs), which indicate the quality of service that the provider will guarantee, or peering contracts, which define