PEOPLECODE
PEOPLECODE
Note. The FLOAT and INTEGER data types should be used only where a performance analysis indicates
that the increased speed is useful and an application analysis indicates that the different representations
won't affect the results of the computations.
NUMBER
OBJECT
STRING
TIME
Object Data Types
For most classes in PeopleTools, you need a corresponding object data type to instantiate objects from
that class.
The following are the data buffer access types:
Field
Record
Row
Rowset
The following are the page display types:
Grid
GridColumn
Page
The following are the Internet Script types:
Cookie
Request
Response
The following are the miscellaneous object types:
AESection
Array
File
Interlink
BIDocs
Note. BIDocs and Interlink objects used in PeopleCode programs run on the application server can only
be declared as type Local. You can declare Interlinks as Global only in an Application Engine program
JavaObject
Note. JavaObject objects can only be declared as type Local.
Message
OptEngine
ProcessRequest
SoapDoc
SQL
SyncServer
TransformData
Note. TransformData objects can only be declared as type Local
XmlDoc
XmlNode
What is the scope of variables, local, global, component, derived work field, system?
Local: local variables created automatically by assigning a value to the variable. We can declare
anywhere with in a people code program
Global variables: To use these variables we must declare it at the beginning of the program. Once
declared it can be referenced the operator logs off peoplesoft. Only comments or other declarations are
allowed top of these declaration. These variables should be used to transfer values between components
only.
External Non peoplecode functions: A common c++ routine that is loaded from a DLL. It defines by a
Declare statement with the keyword library.
Row: Row represents a single row in a component scroll. A row contains one or more records or child
rowsets.
Record: Record is a single instance of data within a row and is based on a record definition. A record
contains one or more fields.
Field: Field is a single instance of data within records and is based on a field definition.
What is SQLExec?
The SQLExec function executes a SQL command from within a PeopleCode program by passing a SQL
command string. We can use SQLExec with insert, delete, update commands to modify data in tables that
have not been loaded into the component buffer. If you want to delete, insert, or update a single record,
use the corresponding PeopleCode record object method.
If you want to delete, insert, or update a series of records, all of the same type, use the CreateSQL or
GetSQL functions then the Execute SQL object method.
Syntax: SQLExec (“SQL statement”, <input values> <output variable>);
In which peoplecode events we can place SQLExec updates, deletes and inserts?
FieldChange
SavePreChange
WorkFlow
SavePostChange
Peoplecode Events:
SearchInit- This event is performed before the search page is displayed to the user. It’s a way to control
processing before the user enters any value in the search page. Placed on search record field or
component search record.
SearchSave- This event is performed when the user clicks on the search button in the search dialog.
Error and warning messages can be placed on this event to prompt the user to enter at least one value in
the search dialog. Placed on the search record or component search record.
RowSelect- This event is performed as the component processor reads data into the buffer. This
peoplecode can prevent the component processor to load any specific data into the component by using
the DiscardRow and StopFetching functions. Placed on record field or component record.
PreBuild- This event is performed once before the rest of the component build events. It can be used to
hide or unhide pages and to set component variables. It can also be used to validate data entered in the
search page. Placed on a component.
FieldDefault- This event is performed when a field has no value. It is used to set the default value to the
field. Placed on record field or component record.
FieldFormula- After the FieldDefault is performed successfully, FieldFormula is performed. But it
increases the performance overhead as it processes unconditionally every time the page is displayed.
Now this event is used to store the web function libraries. Placed on a record field.
RowInit- This event is performed for every new row encountered by the component buffer. It is used to
control the initial appearance of the fields. Placed on record field or component record.
PostBuild- This is performed after the component processor builds the page and before the page is
displayed to the user. It is used to hide or unhide pages and set component variables. Placed only on the
component.
Activate- This is performed when the page is displayed to the user. This is the only page event. It occurs
each time the user selects a page. Placed on a page.
FieldEdit- This is performed once the value of the field is changed and the new value satisfies the system
edits. It is used to validate the new value of the field. Error and warning messages can be placed. Placed
on record field or component record.
FieldChange- After the FieldEdit is performed successfully, this event is performed but it is not used for
validation. It is used for any additional processing based on the new value of the changed field. Placed on
record field or component record.
RowInsert- This is performed when the user inserts a new row in the scroll. Placed on record field or
component record.
RowDelete- It occurs when a row is deleted from the scroll. Error and warning messages can be placed
to prevent the user to delete any row. Placed on record field or component record.
SaveEdit- It is performed once the user tries to save the component. It is used to validate data before it is
updated on the database. This applies to all the rows of data and all pages in the component. Placed on
record field and component record.
SavePreChange- It occurs after the SaveEdit is performed successfully. It provides one last chance to
manipulate data before the database is updated. Placed on record field, component record or component.
WorkFlow- It occurs when a component is saved. Use Workflow to trigger a business event. Workflow
PeopleCode is not field-specific: it triggers PeopleCode on all fields and on all rows of data in the
component buffer. Placed on record field, component record or a component.
SavePostChange- After SavePreChange completes successfully, and the component processor issues
the SQL statement to update the database, SavePostChange peoplecode is applied. It occurs after the
system updates the database. Code in this event is used to update the data not in the buffer but in the
database. Placed on record field, component record or component.
ItemSelected- The ItemSelected event fires whenever the end-user selects a menu item from a pop-up
menu. In pop-up menus ItemSelected PeopleCode executes in the context of the page field from where
the pop-up menu is attached, which means that you can freely reference and change page fields, just as
you could from a pushbutton. This event and all its associated peoplecode will not fire if run from a
component interface.
ItemSelected PeopleCode is only associated with pop-up menu items.
PrePopup- 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. This event and all its
associated peoplecode will not fire if run from a component interface.
PrePopup PeopleCode can be associated with record fields and component record fields
Save processing:
Save edit
Save prechange
Workflow
Save postchange
Itemselected processing:
Prepopup
Push button- Push buttons are used to trigger peoplecode programs. The advantage is that the user
determines when the program should be performed by clicking on the push button. A push button will
perform any FieldEdit and FieldChange events where the push button is attached.
The component processor flow changes for which events in add mode?
Search Record and Page display.
Traversing the data buffer- Accessing specific data by working through the data buffer hierarchy is
known as traversing the data buffer. We can traverse the data buffer from the top down, starting from
level 0 rowset and working the way down to a specific field.
Step 1: Declare the data buffer objects
Component Rowset &RS_level0, &RS_level1;
Component Row &Row_level0, &Row_level1;
Component Record &Record;
Component Field &Field;
Step 2: Get the level 0 rowset and level 0 row
&RS_level0 = Getlevel0();
&Row_level0 = &RS_level0.GetRow(1);
Step3: Get the level 1 rowset
&RS_level1 = &Row_level0.GetRowset(SCROLL.Empl_Checklist);
Step 4: Get the level 1 row
&Row_level1 = &RS_level1.GetRow(2);
Step 5: Get the level 1 record
&Record = &Row_level1.GetRecord(Record.Empl_Checklist);
Step 6: Get the level 1 field
&Field = &Record.GetField(Field.Briefing_status);
Traversing multiple occurs level-
Rowset &RS_level0 = Getlevel0();
Row &Row_level0 = &RS_level0(1);
Rowset &RS_level1 = &Row_level0.GetRowset(SCROLL.Empl_Checklist);
For &I = 1 To &RS_level1.ActiveRowCount
Row &Row_level1 = &RS_level1(&I);
Rowset &RS_level2 = &Row_level1.GetRowset(SCROLL.Empl.Chklst_Itm);
For &J = 1 To &RS_level2.ActiveRowCount
Row &Row_level2 = &RS_level2(&J);
Record &Record = &Row_level2.Empl_Chklst_Itm;
Field &Field = &Record.Briefing_status;
End For;
End For;
Using Shortcut-
&Field = GetLevel0() (1).Empl.Checklist(1).Empl_Chklst_Itm(1).Empl_Chklst_Itm.Briefing_status;
&LEVEL0 = GetLevel0();
&LEVEL0_ROW = &LEVEL0(1);
&LEVEL1 = &LEVEL0_ROW.GetRowset(SCROLL.EMPL_CHECKLIST);
Using Shortcuts
The previous code is the long way of accessing this field. What if you wanted to use all the shortcuts, and
access the field in one line of code? Here it is! The following code assumes all rows are 1.
&REC2 = CreateRecord(RECORD.OPC_METH);
GetRecord creates a reference to a record object for the current context, that is, from the row containing
the currently executing program. GetRecord returns a record object.
What is CreateSQL and GetSQL and how they differ with SQL EXEC?
The GetSQL function instantiates a SQL object and associates it with the SQL definition specified by
sqlname. The SQL definition must already exist, either created using PeopleSoft Application Designer or
the StoreSQL function.
Processing of the SQL definition is the same as for a SQL statement created by the CreateSQL function.
The CreateSQL function instantiates a SQL object from the SQL class and opens it on the given sqlstring
and input values. sqlstring is a PeopleCode string value giving the SQL statement.
Any errors in the SQL processing cause the PeopleCode program to be terminated with an error
message.
You can use CreateSQL with no parameters to create an empty SQL object that can be used to assign
properties before being populated and executed.
WHAT IS THE IMPORTANCE OF ROWINIT, ROWSELECT & FIELD CHANGE? IS THERE ANY
RELATION SHIP B/W THESE EVENTS?
IF WE ARE RUNNING AE PROGRAM THROUH ONLINE PAGE CAN WE USE COMPONENT BUFFER
DATA IN AE PEOPLECODE?
IF AN ERROR OCCURS IN SAVE POST CHANGE PEOPLECODE WILL THE DATA MODIFIED BY
THE USER IN COMPONENT BUFFER UPDATES IN DATABASE? WHY?
No it will not update the database
If there is same Component X in two different menus, menu1 and menu2 and if u want to assign a
different search record for each menu, then which peoplecode function do u use and where do u
write the code?
Difference between component rec field events and record field events?
From Level 1 how can we access level 2 3rd row record field?
How can you get a different component by clicking the hyperlink on a page? How can you open a different
component in a new window by clicking on a hyperlink?
What is the scope of variables local global derived work field and system
If you are running AE through online page can you use component buffer data in ae peoplecode