Sie sind auf Seite 1von 13

PeopleCode

Define PeopleCode?
Ans: PeopleCode is an object oriented proprietary (case-insensitive) language used to
express business logic for PeopleSoft applications.
Order of people code events firing
1. Searchinit
2. Searchsave
3. Rowselect
4. Prebuild
5. Field Default
6. Field Formula
7. RowInit
8. PostBuild
9. Activate
10. FieldEdit
11. FieldChange (PrePopup, ItemSelected)
12. RowInsert
13. RowDelete
14. SaveEdit
15. SavePreChange.
16. WorkFlow
17. SavePostChnage
Activate: The Activate event is initiated each time that a page is activated, including when
a page is first displayed by a user, or if a user presses TAB between different pages in a
component. Each page has its own Activate event.
This event is valid only for pages that are defined as standard or secondary. This
event is not supported for subpages.
FieldChange: Use FieldChange PeopleCode to recalculate page field values, change the
appearance of page controls, or perform other processing that results from a field change
other than data validation.
FieldChange PeopleCode is often paired with RowInit PeopleCode.
Field Default: The FieldDefault PeopleCode event enables you to programmatically set fields
to default values when they are initially displayed. If a field value is changed, whether
through PeopleCode or by a user, the IsChanged property for the row is set to True. The
exception to this is when a change is done in the FieldDefault or FieldFormula events. If a
value is set in FieldDefault or FieldFormula, the row is not marked as changed.
An error or warning issued from FieldDefault PeopleCode causes a runtime error.
FieldEdit: Use FieldEdit PeopleCode to validate the contents of a field, supplementing
standard system edits. If the data does not pass the validation, the PeopleCode program
should display a message using the Error statement, which redisplays the page, displaying
an error message and turning the field red.
If the validation must check for consistency across page fields, then use SaveEdit
PeopleCode instead of FieldEdit.
Field Formula: The FieldFormula event is not currently used. Because FieldFormula
PeopleCode initiates in many different contexts and triggers PeopleCode on every field on
every row in the component buffer, it can seriously degrade application performance. Use
RowInit and FieldChange events rather than FieldFormula.
FieldFormula is now often used in FUNCLIB_ (function library) record definitions to store
shared functions. However, you can store shared functions in any PeopleCode event.
ItemSelected: The ItemSelected event is initiated whenever a 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 button.
PostBuild: The PostBuild event is initiated after all the other component build events have
been initiated. This event is often used to hide or unhide pages. It is also used to set
component variables.
Prebuild: The PreBuild event is initiated before the rest of the component build events. This
event is often used to hide or unhide pages. It is also used to set component variables.
If a PreBuild PeopleCode program issues an error or warning, the user is returned to the
search page. If the search record has no keys, a blank component page appears.
Also use the PreBuild event to validate data entered in a search page after a prompt list is
displayed.
PrePopup: The PrePopup event is initiated just before the display of a pop-up menu.
You can use PrePopup PeopleCode to control the appearance of the pop-up menu.
RowDelete: The RowDelete event is initiated whenever a user attempts to delete a row of
data from a page scroll area. Use RowDelete PeopleCode to prevent the deletion of a row
(using an Error or Warning statement) or to perform any other processing contingent on
row deletion.When the last row of a scroll area is deleted, a new, dummy row is
automatically added
RowInit: The RowInit event is initiated the first time that the Component Processor
encounters a row of data. The RowInit event also occurs after a Select or SelectAll Rowset
method, or a ScrollSelect or related function, is executed. RowInit is not field-specific. It
triggers PeopleCode on all fields and on all rows in the component buffer. Do not use Error
or Warning statements in RowInit PeopleCode. They cause a runtime error.
RowInit PeopleCode is often paired with FieldChange PeopleCode. In these
RowInit/FieldChange pairs, the RowInit PeopleCode checks values in the component and
initializes the state or value of page controls accordingly. FieldChange PeopleCode then
rechecks the values in the component during page execution and resets the state or value of
page controls.
RowInsert: When a user adds a row of data, the Component Processor generates a
RowInsert event. You should use RowInsert PeopleCode for processing specific to the
insertion of new rows. Do not put PeopleCode in RowInsert that already exists in RowInit,
because a RowInit event always initiates after the RowInsert event, which will cause your
code to be run twice.
Rowselect: The RowSelect event is initiated 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. This event also occurs after a ScrollSelect or related function is executed.
A DiscardRow function in RowSelect PeopleCode causes the Component Processor to skip
the current row of data and continue to process other rows. A StopFetching statement
causes the Component Processor to accept the current row of data, and then stop reading
additional rows. If both statements are executed, the program skips the current row of
data, and then stops reading additional rows.
SaveEdit: The SaveEdit event is initiated whenever a user attempts to save the component.
You can use SaveEdit PeopleCode to validate the consistency of data in component fields.
Whenever a validation involves more than one component field, you should use SaveEdit
PeopleCode. If a validation involves only one page field, use FieldEdit PeopleCode.
An Error statement in SaveEdit PeopleCode displays a message and redisplays the
component without saving data. A Warning statement enables the user to click OK and
save the data, or to click Cancel and return to the component without saving.
Use the SetCursorPos function to set the cursor position to a specific page field following a
warning or error in SaveEdit.
SavePostChnage: After the Component Processor updates the database, it initiates the
SavePostChange event.
An error or warning in SavePostChange PeopleCode causes a runtime error. Avoid errors
and warnings in this event.
The system issues a SQL Commit statement after SavePostChange PeopleCode completes
successfully.
If you are executing Workflow PeopleCode, keep in mind that if the Workflow PeopleCode
fails, SavePostChange PeopleCode is not executed. If your component has both Workflow
and SavePostChange PeopleCode, consider moving the SavePostChange PeopleCode to
SavePreChange or Workflow.
SavePostChange does not execute if there is an error during the save. For example, if there
is a data conflict error because another user updated the same data at the same time,
SavePostChange does not execute.
SavePreChange: The SavePreChange event is initiated after SaveEdit completes without
errors. SavePreChange PeopleCode provides one final opportunity to manipulate data
before the system updates the database. If SavePreChange runs successfully, a Workflow
event is generated, and then the Component Processor issues appropriate Insert, Update,
or Delete SQL statements.
Searchinit : The SearchInit event is generated just before a search, add, or data-entry
dialog box is displayed. SearchInit triggers associated PeopleCode in the search key fields of
the search record. This enables you to control processing before a user enters values for
search keys in the dialog box.
You cannot use the following functions in SearchInit PeopleCode:
DoModal, DoModalComponent, Transfer,TransferExact, TransferNode, TransferPage,
TransferPortal.
Searchsave: SearchSave PeopleCode is executed for all search key fields on a search, add, or
data-entry dialog box after a user clicks Search. This enables you to control processing
after search key values are entered, but before the search based on these keys is executed.
You can use Error and Warning statements in SearchSave PeopleCode to send the user
back to the search page if the user entry does not pass validations implemented in the
PeopleCode.
WorkFlow: Workflow PeopleCode executes immediately after the SavePreChange event and
before the database update that precedes the SavePostChange event. The Workflow event
segregates PeopleCode related to workflow from the rest of the applications PeopleCode.
Only PeopleCode related to workflow (such as TriggerBusinessEvent) should be in workflow
programs. Your program should deal with the Workflow event only after any
SavePreChange processing is complete.
Where can you write the PeopleCode?
1. Record field level
2. Page people code
3. Component level people code
4. Component record people code
5. Component record field people code
6. Menu item people code
7. Application engine people code
8. Component interface people code
9. Messaging people code
10. Application package people code
3. Where people codes get stored?
Database server (PSPCMPROG) table
objectvalue1 table name objectvalue2 field name objectvalue3 event
name
6. What are the types of data types are available in PC? Give me some ex for each?
Two types
1. Conventional data type (Any, Boolean, float, integer, object, string, time, date,
number)
2. Object data type (record, rowset)
7. What are the comments available in PC?
REM can be used to comment a single line, but it will be processed by the component
processor
Single and multiple lines commenting:
/* PeopleCode Statements
------ ------ ------ ----
*/
Nested Comments:
<*
/* PC Statements..... ..... ..... */
/* ...... Some info on code ...... */
/* More comments */
*>
8. Variable types available in PC?
Two types of variables
1) user defined variable prefixed with & 2) system defined variable prefixed with %
10. Explain about the component buffer and data buffer?
In short Component Buffer contains all the Data of active component. The data buffer is
used to store data added from sources other than the component, such as from a
PeopleSoft Application Engine program, an application message, and so on. PeopleTools 8
provides an alternative to the scroll level, row, and field components in the form of the
data buffer classes Rowset, Row, Record, and Field, which you reference using dot notation
with object methods and properties.
11. Difference between SQLExec and CreateSql?
SQLExec can only select a single row of data. If your SQL statement retrieves more than
one row of data SQLExec sends only the first row to its output variables. Any subsequent
rows are discarded. If you need to SELECT multiple rows of data use the CreateSQL or
GetSQL functions and the Fetch SQL class method.
12. What is the getsql function in PC?
Use the GetSQL function to instantiate 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.
Syntax: GetSQL (SQL.sqlname [, paramlist]);
14. Transferpage () and Transfer() with syntax ?
Use the TransferPage function to transfer control to the page indicated by
PAGE.page__name or to the page set with the SetNextPage function. The page that you
transfer to must be in the current component or menu. To transfer to a page outside the
current component or menu, or to start a separate instance of PeopleTools prior to
transfer into, use the Transfer function.
You cant use TransferPage from a secondary page.
TransferPage([PAGE.page_name_name])
Use the Transfer function to close the current page and transfers the end user to another
page, either within the current component or in another component. Transfer can either
start a new instance of the application and transfer to the new page there, or close the old
page and transfer to the new one in the same instance of PeopleTools.
Transfer(new_instance,MENUNAME.menuname,BARNAME.barname,ITEMNAME.menu_itemname,
PAGE.component_item_name,action [, keylist] [, AutoSearch]);
16. Define about Funclib()
FUNCLIB is a reusable function stored in derived/work record field event. So, first create a
new record and set the record type to Derived/Work. FUNCLIB records do not hold data,
so they do not need to exist at the database
Level. Add the field ATTACHADD to this record and save the record as
APT_ATTACH_FUNC. PeopleSoft recommends placing FUNCLIB PeopleCode in the
FieldFormula event.
17. What is deferred processing?
Deferred processing is used speed up the data-entry process. This means that the
system does not validate the data for each field as you Tab through a page. You can enter
in all the data for your page without unnecessary trips to the server for data validation.
Entered data is validated when:
You navigate to another page in the component
Click the Save button
Click the Refresh button (access key: Alt+0)
If there are any errors in your data, you are notified at this time.
Field Edit event will not fire until we press the SAVE button if the deferred processing is
ON.
You can select Deferred Processing mode at the following levels:
Page control
Grid
Page (include subpage and secondary page)
Component levels
18. What is a rowset?
A rowset object, instantiated from a Rowset class, is a collection of rows associated
with buffer data. A component scroll is a rowset. You can also have a level zero rowset.
The default method for the Rowset class is GetRow. This means you can specify just a row
number, and not use the GetRow method. For example, the following two lines of code are
equivalent
&MyRow = GetRowset()(5); or &MyRow = GetRowset().GetRow(5)
24. Difference between winmessage and msgget functions?
a)The MsgGet function retrieves a message from the PeopleCode Message Catalog,
substitutes in the values of the parameters into the text message and is stored in database,
where as WinMessage doesnt store in database.
b) MsgGet function message number is mandatory parameter, but there is no such
parameter in WinMessage.
25. Explain use of gray and ungray fun?
Use the Gray function user to make field unavailable for entry a page. Preventing the
user from making changes to the field .Gray make a field display-only, while hide makes it
invisible.
Syntax: Gray (fieldname)
Use the Ungray function to make a gray (non-editable) page field editable .If the field was
grayed with call to the Gray function. If the page field is made display-only in page the
field properties dialog, then Ungray has no effect.
Syntax: UnGray (fieldname)
26. Purpose of all and none functions?
Use the all function to verify a field contain value, or if all the fields in a list of fields
contain values. If any of the fields are NULL, then all return false. A blank character field
or zero numeric value in a required numeric field is considered a null value.
Syntax: ALL (fieldname)
None function to checks that a field or lists of fields have no value.
28. What are the foundations classes which are useful to access component buffer?
Rowset, row, record and field.
31. Difference between getrowset and createrowset?
GetRowset is used to get rowset for a record in the component buffer.
CreateRowset is used to create rowset for a record which is in database, and is also
called as standalone rowset.
32. Use of scrollflush()
Used to remove all rows inside target scroll area and frees it associated buffer. Rows that
are flushed are not deleted from the database. This function is often used to clear work
scroll before a call to ScrollSelect.
Syntax: ScrollFlush (scrollpath)
35. In which PC events dosave function is useful?
FieldEdit, FieldChange, or ItemSelected
36. Callappengine () explain with syntax?
The CallAppEngine function should only be used in events that allow database updates
because generally, If you are calling PeopleSoft application engine. Youre intending to
perform database updates. This includes following events:
SavePreChange, SavePostChange, Workflow, Message Subscription, and FieldChange.
CallAppEngine Cannot use in Application engine PeopleCode actions. If you need to access
one application engine program from another application engine program, use the
CallSection action.
Difference between sql statements and metasql statements?
SQL statements:
The SQl statements are used to fetch/retrieve, update, insert, delete data from the
database. In PeopleSoft we use the sql stmts using sqlexec or createsql. Differnet sql
statements are:
Select, Insert, Update, Delete.
Meta Sqls:
Differnet RDBMS have differne date and time formats. though the component processor
takes care of the automatic convesion but at the time of using the sqlexec the automatic
conversion does not take place. So in order to understand this the meta sql concept has
come. Whcih we can use in diff sql stmts. for example %datetimein, %date, %time,
%currentdatetime, %datetimeout etc.
%dateIn: This is used in the where caluse of "Select and update"
%dateout: This is used while selecting the data.
44. In which PeopleCode would you code errors and warnings?
SearchSave, FieldEdit, SaveEdit and RowDelete primarily. You may also code errors and
warnings in RowSelect.
45. What is the biggest drawback to Fieldformula?
Since FieldFormula is performed every time the panel is displayed on every row of data,
its biggest drawback is the performance overhead it adds
51. How a PeopleCode function be defined so that it can be used as a variable in the calling
program?
In order for a PeopleCode function to be used as a variable, it must be defined using a
"Returns" in the Function statement. Also, at least one "Return" statement must be used in
the function code.
52. Why is the Message Catalog used?
The Message Catalog is used to store the text of error and warning messages that will be
used in PeopleSoft applications. This allows the same message to be used in more than one
PeopleCode program while only maintaining it in one place. It also prevents the text of
messages from being hard-coded into Peoplecode programs.
53. How is a message added to the Message Catalog?
To add a new message to the Message Catalog, the correct message set should first be
retrieved. A new message can be added to the set by performing a row insert (F7). The
new message number will automatically be assigned.
65. How do you turn on the PeopleCode trace?
The PeopleCode trace can be turned on by selecting the Set push button on the PeopleCode
Trace Control panel.
It can also be turned on by saving options in the Configuration manager, logging out of
Psoft and logging back on.
It can also be turned on within PeopleCode by using the SetTracePC built-in function.
75. What are the drawbacks of using a SQLExec built in function?
Since the SQL statement is contained within quotes, it is a black box to PeopleSoft. Means
the programmer is responsible for the syntax, efficiency and maintenance of the SQL. Also,
if a SQLSelect is being performed within the function, only one row of data can be
returned.
76. What are Inline variables? How are they used?
Inline variables are used to reference the value of fields stored in the buffers in SQL
statements. An inline variable consists of a colon followed by the appropriate record and
field name to be referenced. 136.
How are dates converted within SQLExec statements?
Dates are converted within SQLExec built-in function by using the system variables
%DateIn and %DateOut.
82. In which PC events domadel func can't be used?
savepre,save post,workfl,rowselect
83. What is domodal with syntax?
DoModal(PAGE.pagename, title, xpos, ypos, [level, scrollpath, target_row])
84. PeopleCode Tables
PSPCMNAME: PeopleCode Reference table.
PSPCMPROG: Store actual PeopleCode programs (actual code behind PeopleCode events).
Process Request Tables
PSPRCSQUE: This record contains the process request information to run a process request.
PSPRCSRQST: This record contains the process request information to run a process
request.
PS_PMN_PRCSLIST: A view to list all process requests in the Process Monitor except for
"Delete" (runstatus = 2) process requests.
89. Explain about hide and unhide?
Use the Hide function to make a page field invisible. It usually appear in RowInit programs
that set up the initial display of data, and in FieldChange programs that change field
display based on changes the user makes to a field.
Syntax: Hide (fieldname);
Use the Unhide function to make a field visible that was previously hidden with Hide. If the
field was hidden by setting its Invisible property in the Page Field Properties dialog box,
then Unhide has no effect. Generally, you want to put this function on the same scroll level
as the field that is being changed in RowInit (which executes on every row) or FieldChange
(which executes on the current row). This simplifies the functions syntax to:
Syntax:Unhide(fieldname);
DoSave() and DoSaveNow() ..?
Use the DoSave function to save the current page. DoSave defers processing to the end of
the current PeopleCode program event, as distinct from DoSaveNow, which causes save
processing (including SaveEdit, SavePreChange, SavePostChange, and Workflow
PeopleCode) to be executed immediately.
DoSave can be used in the following PeopleCode events only: FieldEdit, FieldChange, or
ItemSelected (for menu items in popup menus only).
The DoSaveNow function is designed primarily for use with remote calls. It enables a
PeopleCode program to save page data to the database before running a remote process
(most frequently a COBOL process) that will access the database directly. It is generally
necessary to call DoSaveNow before calling the RemoteCall function.
DoSaveNow causes the current page to be saved immediately. Save processing (including
SaveEdit, SavePreChange, SavePostChange, and Workflow PeopleCode) is executed before
continuing execution of the program where DoSaveNow is called. DoSaveNow differs from
the DoSave function in that DoSave defers saving the component until after any running
PeopleCode is completed.
DoSaveNow can only be called from a FieldEdit or FieldChange event.
If you call DoSaveNow and there are no changes to save, save processing is skipped entirely.
You can call SetComponentChanged right before you call DoSaveNow. The
SetComponentChanged function makes the Component Processor think there are changes
and so will force full save processing.








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

What is the sequence of Firing of Events in Add Mode / Update Mode ?
The Sequence of Firing of Events in Add Mode are
Add Mode Update Mode
Search Init Search Init
Search Save Search Save
Pre Build Row Select
Field Default Pre Build
Field Formula Field Default
Row Init Field Formula
Post Build Row Init
Activate Post Build
Field Change Activate
Row Insert Field Change
Row Delete Row Insert
Save Edit Row Delete
Save Pre Change Save Edit
WorkFlow Save Pre Change
Save Post Change WorkFlow
Save Post Change

Das könnte Ihnen auch gefallen