PeopleCode
Built-In Functions:
Applications
Engine:
1.
CallAppEngine
- This is how to start your Application Engine programs synchronously from a
page.
a.
must include the
CallAppEngine PeopleCode function within events that allow database updates.
i. SavePreChange
(Page)
ii. SavePostChange
(Page)
iii. Workflow
iv. FieldChange
2. CommitWork.
a.
CommitWork()
b. FieldChange
and SavePreChange events.
c.
Use the CommitWork
function to commit pending changes (inserts, updates, and deletes) to the
database.
3. GetAESection
a.
GetAESection(ae_applid,
ae_section [, effdt])
b.
Use the GetAESection
function to open and associate an AESection PeopleCode object.
Array:
1. CreateArray
a.
CreateArray(paramlist)
·
To construct an array and
returns a reference to it.
·
The type of the first
parameter determines the type of array that is built.
·
If the first parameter is
of type NUMBER, an array of number is built.
·
If there is no first
parameter an empty array of ANY is built.
2. CreateArrayAny
a. CreateArrayAny([paramlist])
b.
Use the CreateArrayAny
function to construct an array whose elements are of data type ANY and returns
a reference to it.
3. CreateArrayRept
a. CreateArrayRept(val,
count)
b.
Use the CreateArrayRept
function to create an array that contains count copies of val.
c.
If val is itself an array,
the created array has one higher dimension, and each element (sub-array) is the
array reference val.
4. SplitSyntax
a. Split(string, separator)
b.
Use the Split function to convert
a string into an array of strings by looking for the string separator in the
given string.
&test
= "value1:value2:"; &array = Split(&test, ":");
5. SQLExec
§ SQLExec({sqlcmd |
SQL.sqlname}, bindexprs, outputvars)
§ Use
the SQLExec function to execute a SQL command from within a PeopleCode program
by passing a SQL command string.
§ The
SQL command bypasses the Component Processor and interacts with the database
server directly.
§ SQLExec
can only Select a single row of data.
§ 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
class method.
6.
CreateSQL
§ CreateSQL([{sqlstring
| SQL.SqlName}[, paramlist]])
§ Use
the CreateSQL function to instantiate 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.
§ &Sql1
= CreateSql("Select * from " | &TableName);
7. GetSQL
§ GetSQL(SQL.sqlname
[, paramlist])
§ 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.
§ GetSQL(SQL.INSERT_TEST,
&AAny);
8. AddAttachment
§ AddAttachment(URLDestination,
DirAndFilename, FileType, UserFile, MaxSize [, PreserveCase,
UploadPageTitle])
§ URLDestination
- URL.URLname
or ftp://user:password@ftp.ps.com/
§ Use the AddAttachment function to
transfer a file from one server to another. You could use this to associate a
file with a row in a record, or with a page of data.
9. GetAttachment:
a. GetAttachment(URLSource, SysFileName,
LocalFile [, LocalDirEnvVar[, PreserveCase]])
b. Use the GetAttachment function to
transfer a file from the file server to the application sever.
10. ViewAttachment
a. ViewAttachment(URLSource, DirAndFileName,
UserFile [, NewWindow[, PreserveCase]])
b. Use the ViewAttachment function to
enable an end-user to view a file on a system.
Component Buffer:
1. ActiveRowCount
o Use the ActiveRowCount function to
return the number of active (non-deleted) rows for a specified scroll area in
the active page.
§
ActiveRowCount(Scrollpath)
§
scrollpath
is:
§ [RECORD.level1_recname,
level1_row, [RECORD.level2_recname, level2_row, ]] RECORD.target_recname
§
To
prevent ambiguous references, you can use SCROLL. scrollname,
where scrollname is the same as the scroll level’s primary record name.
§ ActiveRowCount is often used to get
a limiting value for a For statement. This enables you to loop through the
active rows of a scroll area, performing an operation on each active row.
2. ComponentChanged
a. ComponentChanged()
b. Use the ComponentChanged function to
determine whether a component has changed since the last save, whether by the
user or by PeopleCode.
c. Returns a Boolean value: True if the
component has changed.
3. CopyFields
a. CopyFields(from, to)
b.
Use the CopyFields
function to copy like-named fields from a row on the specific source record to
a row on the specific target record.
c. where
from and to are constructions that reference rows of data on specific source
and target records in the component buffer; each have the following syntax: level, scrollpath, target_row
4. CopyRow
a. Use the CopyRow function to copy
data from one row to another row.
b. Syntax: CopyRow(destination_row,
source_row)
5. CurrentLevelNumber
a. Use the CurrentLevelNumber function
to return the scroll level where the function call is located.
b. Syntax : CurrentLevelNumber()
6. CurrentRowNumber
a. Use the CurrentRowNumber function to
determine the row number of the row currently displayed in a specific scroll
area.
b. CurrentRowNumber([level])
7. DeleteRecord
a. Use the DeleteRecord function to
remove a high-level row of data and all dependent rows in other tables from the
database.
b. DeleteRecord(level_zero_recfield)
c. DeleteRecord deletes the component’s
level-zero row from the database, deletes any dependent rows in other tables
from the database, and exits the component.
8. DeleteRow
a. Use the DeleteRow function to delete
rows programmatically.
b. DeleteRow(scrollpath, target_row)
c. A call to this function causes the
RowDelete event sequence to fire, as if an user had manually deleted a row.
9. FetchValue
a. Use the FetchValue function to
return the value of a buffer field in a specific row of a scroll level.
b. FetchValue(scrollpath, target_row,
[recordname.]fieldname)
c. This function is generally used to
retrieve the values of buffer fields outside the current context; if a buffer
field is in the current context, you can reference it directly using a [recordname.]fieldname
expression.
10. FieldChanged
a. The FieldChanged function returns
True if the referenced buffer field has been modified since being retrieved
from the database either by a user or by a PeopleCode program.
b. The syntax of the FieldChanged
function varies depending on whether you want to use a scroll path reference or
a contextual reference to specify the field.
i. scroll path reference -
FieldChanged(scrollpath, target_row, [recordname.]fieldname)
ii. contextual reference -
FieldChanged([recordname.]fieldname
c. This is useful during SavePreChange
or SavePostChange processing for checking whether to make related updates based
on a change to a field.
11.
InsertRow:
a. Use the InsertRow function to
programmatically perform the ALT+7 and ENTER (RowInsert) function.
b. InsertRow(scrollpath, target_row [,
turbo])
c. InsertRow(RECORD.BUS_EXPENSE_PER,
&L1_ROW, RECORD.BUS_EXPENSE_DTL, &L2_ROW);
12.
IsDate
a. Use the IsDate function to determine
if Value contains a valid date.
b. IsDate(Value)
13.
RowFlush
a. Use the RowFlush function to remove
a specific row from a page scroll and from the component buffer.
b. Rows that are flushed are not
deleted from the database.
c. RowFlush(scrollpath, target_row)
14.
SetDefault
a. Use the SetDefault function to set a
field to a null value, so that the next time default processing occurs, it is
set to its default value
b. SetDefault([recordname.]fieldname)
15.
StopFetching
a. The StopFetching function is called
during Row Select processing, during which rows of data that have been selected
down from the database can be filtered as they are added to the component.
b. This function is valid only in
RowSelect PeopleCode.
c. StopFetching()
16.
TotalRowCount
a. Use the TotalRowCount function to
calculate the number of rows (including rows marked as deleted) in a specified
scroll area of a page.
b. TotalRowCount(scrollpath)
c. TotalRowCount is used to calculate
the upper limit of a For loop if you want the loop to go through rows in the
scroll
17.
%Component
a. %Component returns an uppercase
character string containing the name of the current component, as set in the
component definition.
18.
%Menu
a. %Menu returns an uppercase string
containing the current menu name. It can be used to restrict edits or
processing to a specific menu.
19.
%Mode
a. %Mode returns a String value
consisting of an uppercase character specifying the action a user selected when
starting the current component.
b. You can check either for the string
value ("A", "U", and so on.) or for the constant:
A - %Action_Add - Add
U - %Action_UpdateDisplay > Update/Display
L > %Action_UpdateDisplayAll >
Update/Display All
C > %Action_Correction > Correction
E > %Action_DataEntry > Data Entry
P > %Action_Prompt > Prompt
20.
%OperatorClass
a. This system variable returns a
string representing the primary or base class of the current operator.
21.
%OperatorId
a. %OperatorId returns an uppercase
character string containing the operator currently logged on. This is typically
used to restrict access to records or fields to specific operators.
22.
%UserId
a. %UserId returns a character string
containing the user currently logged on. This is typically used to restrict
access to records or fields to specific users.
23.
%OperatorRowLevelSecurityClass
a. This system variable returns a
string representing the row-level security class of the current operator. The
row-level security class is now distinct from the operator’s primary class.
24.
%Table
a. The %Table construct returns the SQL
table name for the record specified with recname.
b. %Table(recname [, instance])
c. %Table(ABSENCE_HIST) returns
PS_ABSENCE_HIST
Component Interface
1.
GetMethodNames
a.
Use
the GetMethodNames function to return either the method names for a Component
Interface, or the function names of a WEBLIB record.
b.
GetMethodNames(Type, Name)
c. Local array of string &Array;
&Array =
GetMethodNames("CompIntfc", CompIntfc.USER_PROFILE);
&Array =
GetMethodNames("WebLib", Record.WEBLIB_PORTAL);
2. GetSession
a. Use the GetSession function to
retrieve a PeopleSoft session object.
b. After you use GetSession, you can
instantiate many other types of objects, like Component Interfaces, data trees,
and so on.
c. GetSession()
3. %CompIntfcName
a. %CompIntfcName returns the name of
the Component Interface, if the currently executing PeopleCode program is being
run from a Component Interface.
Current Date and Time
1.
%CurrentDateIn
a.
The
%CurrentDateIn meta-SQL variable expands to a platform-specific SQL substring
representing the current date in the Where clause of a SQL Select or Update
statement, or when the current date is passed in an Insert statement.
2.
%CurrentDateOut
a.
The
%CurrentDateOut meta-SQL variable expands to platform-specific SQL for the
current date in the Select clause of an SQL query.
3.
%DateAdd
a.
The
%DateAdd meta-SQL function returns a date by adding add_days to date_from.
The add_days variable can be negative.
b.
%DateAdd(date_from, add_days)
4.
%DateDiff
a.
The
%DateDiff meta-SQL function returns an integer representing the difference
between two dates in number of days.
b.
%DateDiff(date_from, date_to)
5.
%DateIn
a.
The
%DateIn meta-SQL variable expands into platform-specific SQL syntax for the
date. Use %DateIn whenever a date literal or Date bind variable is used in a
comparison in the Where clause of a Select or Update statement, or when a Date
value is passed in an Insert statement.
b.
%DateIn(dt)
c.
UPDATE
PS_PERSONAL_DATA SET LASTUPDT = %DATEIN('2002-12-11')
d.
UPDATE
PS_PERSONAL_DATA SET LASTUPDT = %DATEIN(:1)
6.
%DateTimeDiff
a.
The
%DateTimeDiff meta-SQL function returns a time value, representing the
difference between two datetimes in minutes.
b.
%DateTimeDiff(%CurrentDateIn,
RQSTDTTM) < " | RECORD.FIELDNAME * 60;
c.
%DateTimeDiff(%CurrentDateIn,
RQSTDTTM) < " | RECORD.FIELDNAME;
Database and Platform:
1.
%DbName
a.
%DbName
returns the name of the current database as a String value.
2.
%DbServerName
a.
%DbServerName
returns the name of the current Sybase or Informix database server as a string.
This is not valid for other database types.
3.
%DbType
a.
%DbType
returns a string representing the type of the current database.
Data Buffer Access
1. CreateRecord
a.
CreateRecord(RECORD.recname)
b.
Use
the CreateRecord function to create a standalone record definition and
its component set of field objects.
c.
if
you are calling this function from PeopleCode associated with a page, the
record does not have to be included on the current page.
d.
Local
Record &REC2;
&REC2 =
CreateRecord(RECORD.OPC_METH);
2. CreateRowset
a.
CreateRowset({RECORD.recname | &Rowset}
[, {FIELD.fieldname, RECORD.recname | &Rowset}]
. .
.)
b.
Use
the CreateRowset function to create an unpopulated, standalone rowset.
c.
A
standalone rowset is a rowset that has the specified structure, but is not tied
to any data
d.
&RS
= CreateRowset(RECORD.QA_MYRECORD);
e.
The
following creates a rowset with the same structure as the specified rowset:
&RS2 = CreateRowset(&RS);
3. GetField
a.
GetField([recname.fieldname])
b.
Use
the GetField function to create a reference to a field object for the current
context; that is, from the row containing the currently executing program.
c.
If
you don't specify recname.fieldname, the current field executing the
PeopleCode is returned.
d.
When
GetField is used with an associated record and field name on component buffer
data, the following is assumed:
i. &FIELD =
GetRow().recname.fieldname;
ii. Local Field &CHARACTER; -
&CHARID = GetField(FIELD.CHAR_ID);
4. GetLevel0
a.
GetLevel0()
b.
Use
the GetLevel0 function to create a rowset object that corresponds to level 0 of
the component buffer. If used from PeopleCode that isn’t associated with a
page, it returns the base rowset from the current context.
c.
GetLevel0
has no parameters. However, it does have a default method, GetRow, and a
shortcut. Specifying GetLevel0()(1) is the equivalent of specifying GetLevel0().GetRow(1).
5. GetRecord
a.
GetRecord([RECORD.recname])
b.
Use
the GetRecord function to create a reference to a record object for the current
context, that is, from the row containing the currently executing program.
c.
&REC
= GetRecord(); or &REC = GetRow().GetRecord(Record.recname);
d.
&REC
= GetRow().recname;
6. GetRow
a.
GetRow()
b.
Use
the GetRow function to obtain a row object for the current context, that is the
row containing the currently executing program.
c.
&ROW
= GetRowset().GetRow(CurrentRowNumber());
7. GetRowset
a.
Use
the GetRowset function to get a rowset object based on the current context.
That is, the rowset is determined from the row containing the program that is
running.
b.
GetRowset([SCROLL.scrollname])
i. Local Rowset &RS1, &RS2;
&RS1 = GetRowset();&RS2 = GetRowset(SCROLL.EMPL_CHKLST_ITM);
DEFAULT:
1.
SetDefault
a.
SetDefault([recordname.]fieldname)
b.
Use
the SetDefault function to set a field to a null value, so that the next time
default processing occurs, it is set to its default value
Exceptions
1. CreateException
a.
CreateException(message_set, message_num,
default_txt [, subslist])
b.
Use
the CreateException function to create an exception object with the given
properties. You can use this in your exception handling. Use this function
either in conjunction with the Throw statement, or on its own to get more
information of a message.
2. Throw
a.
Throw Expression
b.
Use
the Throw statement to throw an exception. This can be used to create your own
exceptions, instead of using one generated by the system.
c.
Function t2
throw CreateException(2, 160, "'%1'
doesn't support property or method '%2'", "SomeClass",
"SomeMethod");
End-Function;
3. Try
a.
try
Protected
StatementList
catch QualifiedID
&Id
StatementList
end-try
b.
Use
the Try statement as part of a Try-Catch statement to trap exceptions thrown
either by the system or created using the CreateException function.
c. try
&res = 15.3 / 7 *
22.1;
catch Exception &c1
MessageBox(0,
"", 0, 0, "Caught exception: " | &c1.ToString());
end-try;
Files
1. FileExists
a. FileExists(filename [, pathtype])
b. Use the FileExists function to
determine whether a particular external file is present on your system, so you
can decide which mode to use when you open the file for writing.
2. FindFiles
a. FindFiles(filespec_pattern [,
pathtype])
b. Use the FindFiles function to return
a list of the external filenames that match the filename pattern you provide,
in the location you specify.
3. GetFile
a. GetFile(filename, mode [, charset]
[, pathtype])
b. Use the GetFile function 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.
4. %FilePath
a. This meta-variable returns the
current file path as a string.
MAIL:
1. SendMail
a. SendMail(flags, recipients, CCs,
BCCs, subject, text,
[,
attachment_filenames][, attachment_titles] [, Mail_From] [,mail_sep]
[, Content_Type]
[,Reply_To] [,Sender])
b. Use the SendMail function to send an
email message from a PeopleSoft page. The APIs that support these subsystems
must be present on the system for the function to work.
&MAIL_FLAGS = 0;
&MAIL_TO =
"dduffield@peoplesoft.com;sweet_pea@peoplesoft.com";
&MAIL_CC = "";
&MAIL_BCC =
"mom@aol.com";
&MAIL_SUBJECT = "Live long
and prosper!";
&MAIL_TEXT = "Please read
my attached CV. You will be amazed and
hire me forthwith.";
&MAIL_FILES =
"c:\mydocs\resume.doc;c:\mydocs\coverlet.doc";
&MAIL_TITLES = "My CV;READ
ME";
&MAIL_SENDER =
"MyEmail@Yahoo.com";
&RET = SendMail(&MAIL_FLAGS,
&MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT,
&MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER);
if not (&RET = 0) then
WinMessage("Return status from mail = " | &RET);
end-if;
2. %EmailAddress
a. This system variable returns the
email address of the current user.
Menu Appearance:
1. CheckMenuItem
a. CheckMenuItem(BARNAME.menubar_name,
ITEMNAME.menuitem_name)
b. Use the CheckMenuItem function to
change the menu state by placing a check mark beside the menu item.
2. DisableMenuItem
a. DisableMenuItem(BARNAME.menubar_name,
ITEMNAME.menuitem_name)
b. Use the DisableMenuItem function to
disable (make unavailable) the specified menu item. To apply this function to a
pop-up menu, use the PrePopup Event of the field with which the pop-up menu is
associated.
3. EnableMenuItem
a. EnableMenuItem(BARNAME.menubar_name,
ITEMNAME.menuitem_name)
b. Use the EnableMenuItem function to
enable (make available for selection) the specified menu item. To apply this
function to a pop-up menu, use the PrePopup Event of the field with which the
pop-up menu is associated.
c. EnableMenuItem(BARNAME.MYPOPUP1,
ITEMNAME.DO_JOB_TRANSFER);
4. HideMenuItem
a. HideMenuItem(BARNAME.menubar_name,
ITEMNAME.menuitem_name)
b. Use the HideMenuItem function to
hide a specified menu item. To apply this function to a pop-up menu, use the
PrePopup Event of the field with which the pop-up menu is associated.
Message Catalog and Message
Displays:
1. Error
a. Error str
b. Use the Error function in FieldEdit
or SaveEdit PeopleCode to stop processing and display an error message.
2. MessageBox
a. MessageBox(style, title, message_set,
message_num, default_txt [, paramlist])
b. Use the MessageBox function to
display a message box window. This function combines dialog-display ability
with the text-selection functionality of MsgGet, MsgGetText, or
MsgGetExplainText. The style parameter selects the buttons to be
included. title determines the title of message.
c. MessageBox(0, "", 30000,
1, "Message not found.", BUS_EXPENSE_PER.EMPLID,
BUS_EXPENSE_PER.EXPENSE_PERIOD_DT);
d. MessageBox(%MsgStyle_RetryCancel,
"", 30000, 2, "Message not found.");
3. MsgGet
a. MsgGet(message_set, message_num,
default_msg_txt [, paramlist])
b. Use the MsgGet function to retrieve
a message from the PeopleCode Message Catalog and substitutes in the values of
the parameters into the text message.
c. &MsgText = MsgGet(30000, 2,
"Message not found");
4. MsgGetText
a. MsgGetText(message_set, message_num,
default_msg_txt [, paramlist])
b. Use the MsgGetText function to
retrieve a message from the PeopleCode Message Catalog and substitutes the
values of the parameters in paramlist into the text message. It returns
the resulting message text as a String data type.
c. &MsgText = MsgGetText(30000, 2,
"Message not found");
5. Warning
a. Warning str
b. You typically use the Warning
function in FieldEdit or SaveEdit PeopleCode to display a message alerting the
end-user about a potentially incorrect data entry or change.
6. WinMessage
a. WinMessage(message [, style] [, title])
b. Use the WinMessage function to
display a message in a message box.
PAGE:
1. GetPage
a. GetPage(PAGE.pagename)
b. Use the GetPage function to return a
reference to a page object. Generally, page objects are used to hide or unhide
pages in a component.
c. If PAYROLE_TYPE = "Global"
Then
GetPage(PAGE.JOB_EARNINGS).Visible
= False;
End-If;
Page Control Appearance.
1. Gray
a. Gray(Fieldname)
b. Use the Gray function to make a
field unavailable for entry a page field, preventing the user from making
changes to the field.
2. Hide
a. Hide(scrollpath, target_row,
[recordname.]fieldname)
b. Use the Hide function to make a page
field invisible.
3. HideRow
a. HideRow(scrollpath) [, target_row])
b. Use the HideRow function to hide a
row occurrence programmatically.
4. HideScroll
a. HideScroll(scrollpath)
b. Use the HideScroll function to
programmatically hide a scroll bar and all data items within the scroll.
5. IsHidden
a. IsHidden(scrollpath, target_row)
b. Use the IsHidden function to verify
whether a row is hidden or not.
6. SetCursorPos
a. SetCursorPos(Page.pagename, scrollpath,
target_row, [recordname.]fieldname)
b. Use the SetCursorPos to place the
focus in a specific field anywhere in the current component. To transfer to a
page outside the current component, use Transfer.
7. SetLabel
a. SetLabel(scrollpath, target_row,
[recordname.]fieldname, new_label_text)
b. Use the SetLabel function to change
the label text of a page field or grid column heading.
8. Ungray
a. Ungray(scrollpath, target_row,
[recordname.]fieldname)
b. Use the Ungray function to make a
gray (non-editable) page field editable, if the field was grayed with a call to
the Gray function.
9. Unhide, UnhideRow,UnHideScroll.
Saving and Canceling
1. DoCancel
2. DoSave
3. DoSaveNow
4. WinEscape
Secondary Pages
1. DoModal
a. DoModal(PAGE.pagename, title, xpos,
ypos,[level, scrollpath, target_row])
b. Use the DoModal function to display
a secondary page. Secondary pages are modal, meaning that the user must dismiss
the secondary page before continuing work in the page from which the secondary
page was called.
2. EndModal
a. EndModal(returnvalue)
b. Use the EndModal function to close a
currently open secondary page. It is required only for secondary pages that do
not have OK and Cancel buttons.
3. IsModal
a. IsModal()
b. The IsModal function returns True if
executed from PeopleCode running in a modal secondary page and False if
executed elsewhere.
SQL
- CreateSQL
- DeleteSQL
- ExpandBindVar
- ExpandSqlBinds
- FetchSQL
- FlushBulkInserts
- GetSQL
- SQLExec
- StoreSQL
- %FirstRows
- %InsertSelect
- %InsertValues
- %Join
- %KeyEqual
- %KeyEqualNoEffDt
- %Like
- %LikeExact
- %NoUppercase
- %OldKeyEqual
- %SQL
- %SignonUserId
- %SQL
- %SQLRows
- %Table
- %UpdatePairs