The PeopleCode built-In functions and language constructs beginning with the letter F are listed in alphabetical order within this topic.
Related LinksFact(x)
Use the Fact function to return the factorial of a positive integer x. The factorial of a number x is equal to 1*2*3*. * x . If x is not an integer, it is truncated to an integer.
Returns a Number equal to the factorial of x.
FetchSQL([SQL.]sqlname[, dbtype[, effdt]] )
Use the FetchSQL function to return the SQL definition with the given sqlname as SQL. sqlname or a string value, matching the dbtype and effdt . If sqlname is a literal name, it must be in quotes.
Field or Control
Specify the name of a SQL definition. This is either in the form SQL . sqlname or a string value giving the sqlname.
Specify the database type associated with the SQL definition. This parameter takes a string value. If dbtype isn’t specified or is null (""), it is set by default to the current database type (the value returned from the %DbType system variable.)
Values for dbtype are as follows. These values are not case-sensitive:
Note: Database platforms are subject to change.
Specify the effective date associated with the SQL definition. If effdt isn’t specified, it is set by default to the current as of date, that is, the value returned from the %AsOfDate system variable.
The SQL statement associated with sqlname as a string.
The following code gets the text associated with the ABCD_XY SQL Definition for the current DBType and as of date:
The following code gets the text associated with the ABCD_XY SQL Definition for the current DBType and November 3, 1998:
Related LinksFetchValue(scrollpath, target_row, [recordname.]fieldname)
[RECORD.level1_recname, level1_row, [RECORD.level2_recname, level2_row, ]] RECORD.target_recname
To prevent ambiguous references, you can also use SCROLL . scrollname , where scrollname is the same as the scroll level’s primary record name.
Use the FetchValue function to return the value of a buffer field in a specific row of a scroll level.
Note: This function remains for backward compatibility only. Use the Value field class property instead.
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.
Field or Control
A construction that specifies a scroll level in the component buffer.
An integer specifying the row on the target scroll level where the referenced buffer field is located.
The name of the field where the value to fetch is located. The field can be on scroll level one, two, or three of the active page. The recordname prefix is required if the call to FetchValue is not on the record definition recordname .
Returns the field value as an Any data type.
The following example retrieves the value from field DEPEND_ID in record DEPEND on row &ROW_CNT from scroll level one:
Related LinksThe 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.
If you want to use a scroll path reference, the syntax is:
FieldChanged(scrollpath, target_row, [recordname.]fieldname)
[RECORD.level1_recname, level1_row, [RECORD.level2_recname, level2_row, ]] RECORD.target_recname
To prevent ambiguous references, you can also use SCROLL . scrollname , where scrollname is the same as the scroll level’s primary record name.
If you want to use a contextual reference, the syntax is:
FieldChanged([recordname.]fieldname)
In this construction the scroll level and row number are determined based on the current context.
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.
Note: This function remains for backward compatibility only. Use the IsChanged field class property instead.
This is useful during SavePreChange or SavePostChange processing for checking whether to make related updates based on a change to a field.
Field or Control
A construction that specifies a scroll level in the component buffer.
The name of the field where the value to check is located. The field can be on scroll level one, two, or three of the active page. The recordname prefix is required if the call to FieldChanged is not on the record definition recordname .
The row number of the target row. If this parameter is omitted, the function assumes the row on which the PeopleCode program is executing.
Save PeopleCode programs (SaveEdit, SavePreChange, SavePostChange) normally process each row of data in the component. The following four functions enable you to control more precisely when the Component Processor should perform save PeopleCode:
These functions enable you to restrict save program processing to specific rows.
The following example checks three fields and sets a flag if any of them has changed:
/* Set the net change flag to 'Yes' if the scheduled date, scheduled */ /* time or quantity requested is changed */ If FieldChanged(QTY_REQUESTED) Or FieldChanged(SCHED_DATE) Or FieldChanged(SCHED_TIME) Then NET_CHANGE_FLG = "Y"; End-If;
Related LinksFileExists(filename [, pathtype])
Use the FileExists function to determine whether a particular file or directory is present on your PeopleSoft system, so, in the case of a file, you can decide which mode to use when you open the file for writing or whether the file is available to be read, and, in the case of a directory, you can decide whether the directory already exists or needs to be created.
Note: If you want to open a file for reading, you should use the "E" mode with the GetFile function or the File class Open method, which prevents another process from deleting or renaming the file between the time you tested for the file and when you open it.
Important! The FileExists function can be used to confirm the existence of a directory on a Windows share—for example, \\my_server\temp\mydir. However, if the root of a Windows share (for example, \\my_server\temp) is passed to FileExists, the return value will always be False.
Field or Control
Specify the name, and optionally, the path, of the file or directory you want to test.
If you have prepended a path to the file name, use this parameter to specify whether the path is an absolute or relative path. The valid values for this parameter are:
If you don’t specify pathtype the default is %FilePath_Relative.
If you specify a relative path, that path is appended to the path constructed from a system-chosen environment variable. A complete discussion of relative paths and environment variables is provided in documentation on the File class.
If the path is an absolute path, whatever path you specify is used verbatim. You must specify a drive letter and the complete path. You can’t use any wildcards when specifying a path.
The Component Processor automatically converts platform-specific separator characters to the appropriate form for where your PeopleCode program is executing. On a Windows system, UNIX "/" separators are converted to "\", and on a UNIX system, Windows "\" separators are converted to "/".
Note: The syntax of the file path does not depend on the file system of the platform where the file is actually stored; it depends only on the platform where your PeopleCode is executing.
A Boolean value: True if the file or directory exists, False if it doesn’t.
The following example opens a file for appending if it exists in the system:
If FileExists("c:\work\item.txt", %FilePath_Absolute) Then &MYFILE = GetFile("c:\work\item.txt", "A"); /* Process the file */ &MYFILE.Close(); End-If;
Related LinksFind(string, within_string [, number])
Use the Find function to locate one string of text within another string of text and returns the character position of the string as an integer. Find is case-sensitive and does not allow wildcards.
If you need to do either case-sensitive search or pattern matching, just to find if a string matches a pattern, use the DBPatternMatch function.
If you need to find a quotation mark, you need to escape it with a single " . For example
Field or Control
The text you are searching for.
A tilde character ( ~ ) used in the string parameter stands for an arbitrary number of white spaces.
The text string you are searching within.
The position of within_string at which you want to start your search. If you omit number , Find starts at the first character of within_string .
Returns a Number value indicating the starting position of string in within_string .
Find returns with 0 if string does not appear in within_string , if number is less than or equal to zero, or if number is greater than the length of within_string .
In the following example, the first statement returns 1; the second statement returns 6.
&POS = Find("P", "PeopleSoft") &POS = Find("e", "PeopleSoft", 4)
Related LinksFindb(string, within_string [, number])
Note: This function has been deprecated and is no longer supported.
FindCodeSetValues(CodesetName, &NameValuePairs, SourceNodeName, TargetNodeName)
Use the FindCodeSetValues function to find a list of code set name-value pairs. Code sets are primarily used with data value translations as part of a transformation.
Field or Control
Specify the name of the code set you want to find, as a string.
Specify a 2 dimensional array containing the name value pairs in the specified code set that you want to use.
Specify the name of the source (initial) node used in the data transformation.
Specify the name of the target (result) node used in the data transformation.
A two-dimensional array of any.
This example checks the specified CodeSet values, with the name value pairs of "locale/en_us" and "uom/box". It takes the returned array and adds XML nodes to the document. The XML nodes names are the unique names of the CodeSet value, and the XML node value is the corresponding return value.
/* Get the data from the AE Runtime */ Local TransformData &incomingData = %TransformData; /* Set a temp object to contain the incoming document */ Local XmlDoc &tempDoc = &incomingData.XmlDoc; /* Declare the node */ Local XmlNode &tempNode; /* Create an array to hold the name value pairs */ Local array of array of string &inNameValuePairsAry; /* Clear out the doc and put in a root node */ If (&tempDoc.ParseXmlString("")) Then /* Load the array with some values */ &inNameValuePairsAry = CreateArray(CreateArray("locale", "en_us"), CreateArray("uom", "box")); /* Find the codeset values */ &outAry = FindCodeSetValues("PS_SAP_PO_01", &inNameValuePairsAry, "SAP_SRC", "PSFT_TGT"); /* Local XmlNode &tempNode; */ /* Make sure something was returned */ If &outAry.Len > 0 Then /* Loop through the quantities and make sure they are all above 5 */ For &i = 1 To &outAry.Len /* Add the current system date to the working storage*/ &tempNode = &tempDoc.DocumentElement.AddElement(&outAry [&i][1]); &tempNode.NodeValue = &outAry [&i][2]; End-For; End-If; End-If;
Related LinksFindFiles(filespec_pattern [, pathtype])
Use the FindFiles function to return a list of the external file names that match the file name pattern you provide, in the location you specify.
Field or Control
Specify the path and file name pattern for the files you want to find. The path can be any string expression that represents a single relative or absolute directory location. The file name pattern, but not the path, can include two wildcards:
* (Asterisk): matches zero or more characters at its position.
? (Question mark): matches exactly one character at its position.
If you have prepended a path to the file name, use this parameter to specify whether the path is an absolute or relative path. The valid values for this parameter are:
If you don’t specify pathtype the default is %FilePath_Relative.
If you specify a relative path, that path is appended to the path constructed from a system-chosen environment variable. A complete discussion of relative paths and environment variables is provided in documentation on the File class.
If the path is an absolute path, whatever path you specify is used verbatim. You must specify a drive letter and the complete path. You can’t use any wildcards when specifying a path.
The Component Processor automatically converts platform-specific separator characters to the appropriate form for where your PeopleCode program is executing. On a Windows system, UNIX "/" separators are converted to "\", and on a UNIX system, Windows "\" separators are converted to "/".
Note: The syntax of the file path does not depend on the file system of the platform where the file is actually stored; it depends only on the platform where your PeopleCode is executing.
A string array whose elements are file names qualified with the same relative or absolute path you specified in the input parameter to the function.
The following example finds all files in the system’s TEMP location whose names end with ".txt", then opens and processes each one in turn:
Local array of string &FNAMES; Local file &MYFILE; &FNAMES = FindFiles("\*.txt"); while &FNAMES.Len > 0 &MYFILE = GetFile(&FNAMES.Shift(), "R"); /* Open each file */ /* Process the file contents */ &MYFILE.Close(); end-while;
Related LinksFlushBulkInserts()
Use the FlushBulkInserts function to move the bulk inserted rows from the bulk insert buffers of the PeopleSoft process to the physical tables on the database. This flushes all open SQL objects that have pending bulk inserts, but performs no COMMITs. If the flush fails, the PeopleCode program terminates.
When executing a SQL insert using a SQL object with the BulkMode property set to True, the rows being inserted cannot be selected by this database connection until the bulk insert is flushed. For another connection to the database to be able to select those rows, both a flush and a COMMIT are required. To have your process see the bulk inserted rows without committing and without closing the SQL object or its cursor (that is, maintaining reuse for the SQL object), use FlushBulkInserts.
An example of using this function would be in preparation for a database commit where you do not want to close the SQL insert statement, but need to ensure that all the rows you have inserted up to this point are in fact in the database and not in the buffer.
Another example would be when another SQL statement in the same PeopleSoft process needs to select rows that have been inserted using bulk insert and you do not want to close the SQL insert statement. The SELECT cannot read rows in the bulk insert buffer, so you need to flush them to the table from which the SELECT is reading.
None. If the flush fails, the PeopleCode program terminates.
&CM_DEPLETION_REC = CreateRecord(Record.CM_DEPFIFO_VW); &CM_DEPLETE_REC = CreateRecord(Record.CM_DEPLETE); &DEPLETE_FIFO_SEL = GetSQL(SQL.CM_DEPLETE_FIFO_SEL); &ONHAND_FIFO_SEL = GetSQL(SQL.CM_ONHAND_FIFO_SEL); DEPLETE_INS = GetSQL(SQL.CM_DEPLETE_INS); &DEPLETE_INS.BulkMode = True; &DEPLETE_FIFO_SEL.Execute(&CM_DEPLETION_REC, CM_COSTING_AET.BUSINESS_UNIT, CM_COSTING_AET.CM_BOOK); While &DEPLETE_FIFO_SEL.Fetch(&CM_DEPLETION_REC); /* Call functions that populate &CM_DEPLETE_REC.values */ . . . &DEPLETE_INS.Execute(&CM_DEPLETE_REC); . . . If &CM_DEPLETION_REC.CM_COST_PROC_GROUP.Value = "BINTOBIN" Then /* Bin to Bin transfers are both a deplete and receipt, call functions to create the receipt */ . . . /* Flush Bulk Insert to be able to see the current on hand quantities in CM_ONHAND_VW */ FlushBulkInserts(); End-if; End-While; . . .