Você está na página 1de 44

Agenda

About PeopleCode Accessing People Code in Application Designer Where can we write PeopleCode Events in PeopleCode

Referencing data in Component Buffer


Data buffer access PeopleCode and Component Processor

PeopleCode Overview
PeopleCode is the proprietary language of PeopleSoft

PeopleCode is an object-oriented language


All PeopleCode programs are associated with a definition as well as an event

The definition can be a Record field, a component record and many other items
There are a number of events associated with each definition

Data Types
Conventional data types.
Any, Boolean, Date, DateTime, Float, Integer, String, Object, Number etc.

Object data types


Field, Record, Row, Row set, Chart, Grid, GridColumn, Page, Array, AESection, File etc.

Comments
Comments are used to explain the purpose of any part of the PeopleCode program You can surround comments with /* at the beginning and */ at the end You can also use a REM (remark) statement for commenting You can surround commented text with <* at the start and *> at the end In application classes you will see the use of /+ +/ style comments ( Do not use these in your PeopleCode )

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

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 Variables
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

Statements
Assignment Statements
variableName = expression;

Language Construct

Branching structures: If and Evaluate. Loops and conditional loops: For, Repeat, and While. Break, Continue, and Exit statements loop control and terminating programs. The Return statement for returning from functions. Variable and function declaration statements: Global, Local, and Component for variables, and Declare Function for functions. The Function statement for defining functions. Class definition statements. Try, Catch, and Throw statements for error handling.

Statements

Branching Statement
If condition Then
[statement_list_1] [Else [statement_list_2]] End-if; Conditional Loops Function

Statements

Conditional Loops
While logical_expression statement_list End-while;

Function
Declare Function UpdatePSLOCK PeopleCode FUNCLIB_NODES.MSGNODENAME FieldFormula;

function_name([param_list])

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. External non-PeopleCode Functions stored in external (C-callable) libraries.

Function - Example

Function Example Cond

Function Example Cond

Function Example Cond

Accessing People Code in Application Designer

Accessing People Code in Application Designer Cond

Where can we write people code


Record PeopleCode
Page PeopleCode Component PeopleCode

Component Record PeopleCode


Component Record Field PeopleCode Menu People Code

Record People Code

Page People Code

Component People Code

Component Record People Code

Component Record Field People Code

Menu PeopleCode

Events in PeopleCode
Record Field
FieldChange FieldDefault FieldEdit FieldFormula PrePopup RowDelete RowInit RowInsert RowSelect SaveEdit SavePostChg SavePreChg SearchInit SearchSave Workflow

Component Record Field


FieldChange FieldDefault FieldEdit PrePopup

Component Record
RowDelete RowInit RowInsert RowSelect SaveEdit SavePostChg SavePreChg SearchInit SearchSave

Component
PostBuild PreBuild SavePostChg SavePreChg Workflow

Page
Activate

Menu
ItemSelecte d

FieldChange Event : To validate the contents of the field, use the FieldEdit event.
FieldDefault Event : This event triggers only when The page field is still blank after applying any default specified in the record field properties. FieldEdit Event : FieldEdit PeopleCode is used to validate the contents of a field. FieldFormula Event : The FieldFormula event is not used in recent applications. Because FieldFormula PeopleCode fires in many different contexts and triggers PeopleCode on every field on every row in the component buffer, it can seriously degrade the performance of your application. PrePopup Event : The PrePopup event fires just before the display of a pop-up menu. You can use PrePopup PeopleCode to control the appearance of the Pop-up menu

RowDelete Event : The RowDelete event fires whenever a end-user attempts to delete a row of data from a page scroll. The RowDelete event triggers PeopleCode on any field on the row of data that is being flagged as deleted.
RowInit Event : The RowInit event fires the first time the Component Processor encounters a row of data. It is used for setting 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. RowInsert Event : When the end-user adds a row of data, the Component Processor generates a RowInsert event. RowSelect Event : The RowSelect event fires 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.

SaveEdit Event : The SaveEdit event fires whenever the end-user attempts to save the component. You can use SaveEdit PeopleCode to validate the consistency of data in component fields.
SavePostChange Event : After the Component Processor updates the database, it fires the SavePostChange event. SavePreChange Event : The SavePreChange event fires after SaveEdit completes without errors. SavePreChange PeopleCode provides one final opportunity to manipulate data before the system updates the database; SearchInit Event : The SearchInit event is generated just before a search dialog, add dialog, or data entry dialog box is displayed. SearchInit triggers associated PeopleCode in the search key fields of the search record. SearchSave Event : SearchSave PeopleCode is executed for all search key fields on a search dialog, add dialog, or data entry dialog box after the end-user clicks Search.

WorkFlow Event : Workflow PeopleCode executes immediately after SavePreChange and before the database update that precedes SavePostChange. The main purpose of the Workflow event is to segregate PeopleCode related to Workflow from the rest of the applications PeopleCode.
PostBuild Event : The PostBuild event fires after all the other component build events have fired. This event is often used to hide or unhide pages. PreBuild Event : The PreBuild event fires before the rest of the component build events. This event is often used to hide or unhide pages. Activate Event : The Activate event is fired each time the page is activated. Each page has its own Activate event.

Events After User Changes Field

Events After User Saves

The following events occur after a user saves:


Record.recordA.fielda.SaveEdit -> Record.recordA.fieldb.SaveEdit -> Component.recordA.SaveEdit Record.recordB.fielda.SaveEdit -> Record.recordB.fieldb.SaveEdit -> Component.recordB.SaveEdit Record.recordA.fielda.SavePreChange -> Record.recordA.fieldb.SavePreChange -> Component.recordA.SavePreChange Record.recordB.fielda.SavePreChange -> Record.recordB.fieldb.SavePreChange ->Component.recordB.SavePreChange Record.recordA.fieldA.WorkFlow -> Record.recordB.fieldB.WorkFlow -> Component.Workflow Record.recordA.fielda.SavePostChange -> Record.recordA.fieldb.SavePostChange -> Component.recordA.SavePostChange Record.recordB.fielda.SavePostChange -> Component.recordB.SavePostChangeComponent.SavePostChange

Component Processor From Page Start To Page Display

Default Processing

Search Processing

Component Build Processing

Row Select Processing

Field Modification

Row Insert Processing

Row Delete Processing

PrePopup event Processing

Save Processing

Objects and Classes in PeopleCode


What is a class?
A class is the formal definition of an object and acts as a template from which an instance of an object is created at runtime. The class defines the properties of the object and the methods used to control the objects behavior. There are predefined classes such as Field, Record, Row set, Array, File, SQL.

What is an Object?
The class is a template, or blueprint, from which you create an object. After an object has been created (instantiated) from a class, you can change its properties. A property is an attribute of an object.
Local field &field1; &field1 = getfield(emplid); &field.visible = false;

Referencing data in Component Buffer

PeopleCode Example
Local Local Local Local Local string &acctcd; string &h_dir_indir; Record &MYRECORD; Row &MYROW; Row set &MYROWSET;

Declare Function JobNavigation PeopleCode FUNCLIB_HR.JOB_DATA FieldFormula;


JobNavigation(%Page); If None(JOB.H_DIR_INDIR) Then &MYROWSET = GetLevel0()(1).GetRowset(Scroll.JOB); &MYROW = &MYROWSET.GetRow(1); &MYRECORD = &MYROW.GetRecord(Record.JOB); &acctcd = &MYRECORD.GetField(Field.ACCT_CD).Value; &setid = &MYRECORD.GetField(Field.SETID_JOBCODE).Value; SQLExec("select a.H_dir_indir from ps_acct_cd_tbl a where a.effdt = (select max(effdt) from ps_acct_cd_tbl b where b.acct_cd = a.acct_cd and b.effdt <= sysdate and a.setid = b.setid) and a.acct_cd= :1 and a.setid = :2", &acctcd, &setid,&h_dir_indir); &MYRECORD.GetField(Field.H_DIR_INDIR).Value = &h_dir_indir; End-if;

Você também pode gostar