40
PeopleCode and the Component Processor EIS Developer Forum February 8, 2007

PeopleCode and the Component Processor

  • Upload
    kylia

  • View
    97

  • Download
    6

Embed Size (px)

DESCRIPTION

PeopleCode and the Component Processor. EIS Developer Forum February 8, 2007. PeopleCode and the Component Processor. PeopleCode is an object-oriented language Classes Objects Properties Methods. Classes. - PowerPoint PPT Presentation

Citation preview

Page 1: PeopleCode and the Component Processor

PeopleCode and the Component Processor

EIS Developer ForumFebruary 8, 2007

Page 2: PeopleCode and the Component Processor

PeopleCode and the Component Processor

PeopleCode is an object-oriented language

Classes Objects Properties Methods

Page 3: PeopleCode and the Component Processor

Classes

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 object’s behavior.

Page 4: PeopleCode and the Component Processor

Classes

PeopleSoft delivers predefined classes (such as Array, File, Field, Rowset, SQL, and so on).

You can create your own classes using the Application class.

You can extend the functionality of the existing classes using the Application class.

Page 5: PeopleCode and the Component Processor

Classes – An example

File class - provides methods and properties for reading from and writing to external files

Page 6: PeopleCode and the Component Processor

Objects

An object represents a unique instance of a data structure defined by the template provided by its class.

Each object has its own values for the variables belonging to its class and responds to methods defined by that class.

Page 7: PeopleCode and the Component Processor

Object Instantiation

A class is the blueprint for something, like a bicycle, a car, or a data structure. An object is the actual thing that's built using that class (or blueprint.)

For example, from the blueprint for a bicycle, you can build a specific mountain bike with 23 gears and tight suspension.

From the blueprint of a data structure class, you build a specific instance of that class. For example, an instance of the Record class could be PERSONAL_DATA.

Instantiation is the term for building that copy, or an instance, of a class.

Page 8: PeopleCode and the Component Processor

Object Instantiation – An Example

1. Define a variable Local File &fEMPDIRU_OUT;

2. Instantiate the file object using the defined variable

&fEMPDIRU_OUT = GetFile("/peoplesoft/lsdv/mods/dat/PS_EMPDIRU_OUT.txt", "W", %FilePath_Absolute);

Note: GetFile is a built-in function used to instantiate a new file object from the File class, associate it with an external file, and open the file so you can use File class methods to read from or write to it.

Page 9: PeopleCode and the Component Processor

Properties

A property is an attribute of an object (think “adjective”).

Properties define: Object characteristics, such as name

or value.The state of an object, such as

deleted or changed.

Page 10: PeopleCode and the Component Processor

Properties – An Example

IsOpen is a property of the File class which returns a Boolean value indicating whether the file is open.

If &fEMPDIRU_OUT.IsOpen Then

Some of the other properties include CurrentRecord, IsError, Name.

Page 11: PeopleCode and the Component Processor

Methods

A method is the code associated with a given object (think “verb”).

A method is a procedure or routine, associated with one or more classes, that acts on an object.

Page 12: PeopleCode and the Component Processor

Methods – An Example

WriteLine is a method of the File Class that writes one string of text, string, to the output file associated with the file object executing this method.

&fEMPDIRU_OUT.WriteLine(&sRecOut);

Some of the other methods include Close, Delete, Open, and ReadLine.

Page 13: PeopleCode and the Component Processor

Dot Notation

The means through which you access an object’s properties or execute its methods.

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.

Page 14: PeopleCode and the Component Processor

Dot Notation – An Example

&Rec_Names = &Row_Names.NAMES;

&sMaidenName = &Rec_Names.LAST_NAME.Value;

DERIVED_NAME.UPDATE_NAME_BTN.Enabled = False;

Page 15: PeopleCode and the Component Processor

Referencing Data in the Component Buffer

What is the Component Buffer?

The area in memory that stores data for the currently active component.

Consists of rows of buffer fields that hold data for the records associated with page controls, including primary scroll records, related display records, derived/work records, and Translate table records.

Page 16: PeopleCode and the Component Processor

Ways to reference data

In a contextual reference, PeopleCode refers to a row or buffer field determined by the context in which a PeopleCode program is currently executing (think “relative”).

A scroll path specifies a scroll level in the currently active page (think “absolute).

Page 17: PeopleCode and the Component Processor

Contextual Reference

Refers to a row or buffer field determined by the context in which a PeopleCode program is currently executing.

The current context includes All buffer fields in the row of data where the

PeopleCode is executing All buffer fields in rows that are hierarchically

superior to the row where the PeopleCode is executing

Page 18: PeopleCode and the Component Processor

Contextual Reference

Level zero row is always in context

Parent of row where executing takes place is in context

Row where PeopleCode is

currently executing

All rows on lower scroll area out of context {

If GetRowSet().ParentRowset.ParentRow.IsDeleted Then …

Page 19: PeopleCode and the Component Processor

Scroll Paths

A scroll path specifies a scroll level in the currently active page.

If the level you want to reference is level one, you must supply only the RECORD.target_recname parameter.

If the target scroll level is greater than level one, you must provide scroll name and row level parameters for all hierarchically superior scroll levels, beginning at level one.

Page 20: PeopleCode and the Component Processor

Scroll Paths

Target Level1

2

3

Scroll Path SyntaxRECORD.target_recname

RECORD.level1_recname, level1_row,

RECORD.target_recname

RECORD.level1_recname, level1_row,

RECORD.level2_recname, level2_row,

RECORD.target_recname

Page 21: PeopleCode and the Component Processor

Data Buffer Classes

Repeat after me…Rowset

•Row•Record

•Field

Page 22: PeopleCode and the Component Processor

Data Buffer Classes

RowsetA rowset object is a data structure used

to describe hierarchical data. It is made up of a collection of rows.Think of a rowset as a scroll on a page

that contains all that scroll’s data.A level 0 rowset contains all the data for

the entire component.

Page 23: PeopleCode and the Component Processor

Data Buffer Classes

RowA row object represents a single

row in a component scrollA row contains one or more

records.A row may also contain child

rowsets.

Page 24: PeopleCode and the Component Processor

Data Buffer Classes

RecordA record object is a single

instance of data within a row and is based on a record definition.

A record contains one or more fields.

Page 25: PeopleCode and the Component Processor

Data Buffer Classes

FieldA field object is a single instance

of data within a record and is based on a field.

Page 26: PeopleCode and the Component Processor

Occurs Level Review

Component Level 0Every component has at least one

level 0 definition. The search key, and other fields from

the same record definition, have a level of 0.

There can only be one row of data for each level 0 record definition because scrolls begin at occurs level 1.

Page 27: PeopleCode and the Component Processor

Occurs Level Review

Component Level 0

Page 28: PeopleCode and the Component Processor

Occurs Level Review

Occurs Level 1 Scrolls allow you to insert, delete, and

navigate through multiple rows of data. The keys of the occurs level 1 record

definition must include the same search keys as level 0, with at least one additional key.

PeopleSoft allows only one primary record definition per scroll. Fields from other record definitions may appear on a level for related display or as derived/work fields.

Page 29: PeopleCode and the Component Processor

Occurs Level Review

Occurs Level 1

Page 30: PeopleCode and the Component Processor

Occurs Level Review

Other Occurs Levels The maximum possible value of an occurs

level for a component is 3. PeopleSoft allows multiple primary record

definitions at occurs level 2 and 3, but each primary record definition requires its own scroll.

Occurs level 2 primary record definitions must have the same key fields as occurs level 1 plus at least one additional key field.

Occurs level 3 primary record definitions must have the same key fields as occurs level 2 plus at least one additional key field.

Page 31: PeopleCode and the Component Processor

Occurs Level Review

Other Occurs Levels

Page 32: PeopleCode and the Component Processor

Looping through Scroll Levels

Local rowset &RS;

Local row &Row;

Local record &Rec;

Local field &Field;

&RS = GetLevel0()(1).GetRowset(SCROLL.Owner);

For &i = 1 to &RS.ActiveRowCount

&Row = &RS.GetRow(&i);

For &j = 1 to &Row.RecordCount

&Rec = &Row.GetRecord(&j);

For &k to &Rec.FieldCount

&Field = &Rec.GetField(&k)

End-For;

End-For;

End-For;

Page 33: PeopleCode and the Component Processor

PeopleCode and the Component Processor

PeopleCode can be performed at different times during a component’s processing flow (called events) to allow for additional processing.

Page 34: PeopleCode and the Component Processor

PeopleCode and the Component Processor

Whenever coding PeopleCode to enforce a business rule governing your data, you will need to know three things:

1. WHEN you want it to execute

2. WHERE to place your PeopleCode

3. WHAT to program

Page 35: PeopleCode and the Component Processor

WHEN you want it to execute

When during the flow of the Component Processor do you need your code to execute?

Before the Search Page is displayed?

When the page is activated?

When a row is inserted or deleted?

When a field is changed?

When the user clicks the Save button?

Page 36: PeopleCode and the Component Processor

WHERE to place your PeopleCode

Many different events are available:Record Field EventsComponent Record Field EventsComponent Record EventsComponent EventsPage EventMenu Event

Page 37: PeopleCode and the Component Processor

- Part 1

Page 38: PeopleCode and the Component Processor

PeopleSoft Component Processor Flow - Part 2

Page 39: PeopleCode and the Component Processor

WHAT to program

Page 40: PeopleCode and the Component Processor

Workshop Tomorrow

For more information on this topic, sign up for one of the workshops to be held tomorrow

9:00 am – 12:00 pm

1:00 pm – 4:00 pm