PeopleCode Interview Question
PeopleCode Interview Question
1. Define PeopleCode?
PeopleCode is an object oriented proprietary (case-insensitive) language used to express business
logic for PeopleSoft applications.
Database server (PSPCMPROG) table objectvalue1 – table name objectvalue2 – field name
objectvalue3 – event name.
1. Searchinit
2. Searchsave
3. Rowselect
4. Prebuild
5. Field Default
6. Field Formula
7. RowInit
8. PostBuild
9. Activate
10. FieldEdit
12. RowInsert
13. RowDelete
14. SaveEdit
15. SavePreChange.
16. WorkFlow
17. SavePostChnage.
After the save pre change work flow event get fired.
1. Conventional data type (Any, Boolean, float, integer, object, string, time, date, number)
/* PeopleCode Statements
*/
Nested Comments:
<*
/* More comments */
*>
Example:
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.
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.
Page control
Grid
Component levels
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 following two
lines of code are equivalent:
In Save Prechange we can get the data from Component Buffer for that particular Component
where as in SavePost change Component Buffer is cleared we have to get data from Database and
this is used to update values outside the database.
If a field value is changed, whether through PeopleCode or by a user, the IsChanged property for
the row is usually set to True. However, if a value is set in FieldDefault or FieldFormula, the row is
not marked as changed. At save time, all newly inserted and changed rows are written to the
database. All newly inserted but not changed rows are not written to the database.
As a matter of convention, 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. FieldFormula PeopleCode is only associated with record fields.
During the PostBuild event you will have access to the data read from the database into the
component buffer structure. That’s why it is called PostBuild.
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.
27. What are the PC function use to control the translate values dynamically?
a) AddDropDownItem: The AddDropDownItem method adds an item to the dropdown list in the
control for the field. The first time this method is called, it overrides the prompt table or translate
table used to populate the list. Those items no longer appear in the list. Only the items added using
this method display. Subsequent calls to this method add additional items to the dropdown list. The
items added with the first call to the method also display. If there is an existing value and the
dropdown list is changed with these functions, the selection shows as (Invalid value) unless the new
list contains an entry with the same code as the existing value.
b) ClearDropDownItem: The ClearDropDownList method clears all items added to the dropdown
list using the AddDropDownItem method. In addition, this method causes the prompt table or
translates table values defined for the list to come back into effect again (unless they’re
subsequently overridden again with AddDropDownItem).
28. What are the foundations classes which are useful to access component buffer?
Rowset, row, record and field.
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.
Think-time function hold avoids the following events: SavePreChange, Workflow, RowSelect,
SavePostChange.
37. What is the difference b/n err msgget and war msgget?
Error stop the process, warning allow processing to continue. An error in FieldEdit prevents the
system from accepting the new value of a field. A warning enables the component processor to
accept the new data.
An error in SaveEdit prevents the system from saving any row of data. A warning in SaveEdit also
is applied to all data in the page or component, but the component processor will accept the data
Use the AddAttachment function to upload a file from an end-user machine to a specified storage
destination. Note that it is the responsibility of the calling PeopleCode program to store the returned
file name for further use.
b) DeleteAttachment
Use the DeleteAttachment function to delete a file from the specified storage location.
DeleteAttachment does not generate any type of "Are you sure" message. If you want the user to
verify the deletion before it is performed, you must write your own checking code in your
application
c) DetachAttachment
Use the DetachAttachment function to enable a user to make a copy of an attached file on their local
client system. The file is sent to the browser with appropriate HTTP headers to cause the browser to
display a save dialog box to the user. The user can save the copy of the file with any filename.
d) ViewAttachment.
Any method of accessing PeopleCode programs displays a window where PeopleCode programs
can be input or modified. This window is the PeopleCode editor. The PC editor enables you to edit
and navigate all pc programs that belong to the same parent definition.
On the left side of the window is a drop-down list box showing the current field and other available
fields, records, and components. Any field with PeopleCode attached is listed in bold. The right side
of the window has a drop-down list box listing the current PeopleCode event and other acceptable
events for that definition. Events already containing PeopleCode for that definition are listed in
bold.
MetaSQL: - %Bind, %Execute Edits, %Select, %SelectInit, %Sql, %Table, %Truncate Table.
SQL: The SQL statements are used to fetch/retrieve, update, insert, delete data from the database. In
PeopleSoft we use the SQL statements using SQLExec or CreateSQL. Different SQL statements
are: Select, Insert, Update, Create and Delete.
MetaSQL: Different RDBMS have different date and time formats. Though the component
processor takes care of the automatic conversion but at the time of using the SQLExec the
automatic conversion does not take place. So in order to understand this, MetaSQL concept has
come. Which we can use in diff SQL stmts.
Application Designer.
Since FieldFormula is performed every time the panel is displayed on every row of data, its biggest
drawback is the performance overhead it adds.
46. What other PeopleCode event might you expect to find with RowInit?
FieldChange. Since RowInit initializes the data before it is displayed, usually it is used along with
FieldChange to accommodate any of the changes that are performed by the operator once the panel
is displayed.
47. How does SavePostChg differ from all other Peoplecode events?
SavePostChg is different from all other Peoplecode events since it is performed after the updates are
made on the database.
A PeopleCode function is called by referencing the function name and then passing the function the
appropriate number of parameters in parentheses.
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.
61. Which two cross reference reports are best for PeopleCode?
How do they present their data? XRFFLPC reports for one field all of the PeopleCode programs
where it is referenced. XRFPCFL does the opposite. It reports for one PeopleCode program all of
the fields it uses.
63. When is it useful to select the Export to File option in Find in PeopleCode?
An Export report produces an unformatted copy of all of the source code where the character string
was found. This can be very helpful in an upgrade.
64. How can you use WinMessage as part of the debugging process?
A WinMessage can be used to set break points and display the current value of fields and variables
in the PeopleCode debugging process.
·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.
Once the PeopleSoft session is closed, the PeopleCode trace will also automatically be turned off.
70. What must exist at occurs levels 1, 2, and 3 but not occurs level 0?
A scroll bar.
71. How does the application processor allocate buffers to hold data?
The application processor starts allocating buffers at occurs level 0 and then works its way down. It
uses the panel and record definitions to determine the data it needs. From a panel definition, fields
are allocated in TAB order. Generally, if there is one field from record definition on the panel, the
entire row will be brought into the buffers. The exceptions are fields that are in the search dialog
box, derived work fields and related display fields.
73. In what order will PeopleCode be performed on the buffers in a panel group?
PeopleCode starts at the top of the buffers in a panel group and works its way down to the bottom.
The PeopleCode programs on a given row will be performed in the same order as the fields on the
record definition.
74. When should the SQLExec function be used instead of the scroll buffer functions?
Dates are converted within SQLExec built-in function by using the system variables %DateIn and
%DateOut.
79. What functions may be used to alter the appearance of a menu item?
DisableMenuItem, EnableMenuItem, HideMenuItem, CheckMenuItem and UnCheckMenuItem.
savepre,save post,workfl,rowselect
PSPCMPROG: Store actual PeopleCode programs (actual code behind PeopleCode events).
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.
Using java.lang.Thread.sleep()
To use this approach, add the following line to your PeopleCode, passing a value in milliseconds
which is the amount of time to sleep:
GetJavaClass("java.lang.Thread").sleep(1000);
The code above will sleep for 1000 milliseconds (1 second). Note that this approach uses up CPU
cycles and has a performance hit on the application server. If you find this to be an issue, then the
second approach may be better suited if you have an Oracle database.
Using DBMS_LOCK.SLEEP()
SQLExec("exec DBMS_LOCK.SLEEP(1)");
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 function’s syntax to:
Syntax: Unhide (fieldname);
%Component returns an uppercase character string containing the name of the current component,
as set in the component definition.
&MYARRAY.Push (100);
&MYARRAY.Push (200);
&MYARRAY.Push (300);
·A Record contains one or more Fields. Records contain the Fields that makes up the Record.
·A Row contains one or more Records and zero or more child Rowsets. A Row contains the records
that make up that row.
A Rowset contain one or more Rows. A Rowset is a data structure that describes hierarchal data.
a) Using EDITTABLE fields for Prompt Table. I.e., Prompt table property of Record Fields should
be assigned with %EDITTABLE value.
97. Where we write the PC in app packages? In OnExecute event we write our PeopleCode.
·PostBuild Event
·PreBuild Event
·SavePostChange Event
·SavePreChange Event
·Workflow Event
Dates are converted within SQLExec built-in function by using the system variables %DateIn and
%DateOut.