Using the PeopleCode Editor

This section provides an overview of the PeopleCode Editor and color-coded language elements and discusses how to:

  • Access PeopleCode Editor.

  • Editing functions.

  • Format code automatically.

  • Use drag-and-drop editing.

  • Access PeopleCode external functions.

  • Access definitions and associated PeopleCode.

  • Access help.

  • Set up help.

  • Change colors in the PeopleCode Editor.

  • Select a font for the PeopleCode Editor.

  • Change word wrap in the PeopleCode Editor.

  • Use PeopleCode Event properties.

  • Use auto-complete in the PeopleCode Editor.

  • Use event mapping button in the PeopleCode Editor..

The PeopleCode Editor works much like any other text editor, but has capabilities specifically geared toward the PeopleTools environment. Some of its features include:

  • Editing functions are integrated with the menus and toolbar of Application Designer and are also accessible from a pop-up window.

  • It checks, formats, and saves all programs associated with Application Designer definitions simultaneously when any definition is saved.

  • It includes a Validate Syntax command for checking and formatting a single PeopleCode program without saving.

  • It supports standard Microsoft Windows drag-and-drop editing.

  • It supports color-coding for the different elements of the PeopleCode language.

  • It supports word wrap based on either the size of the editor window or a specific number of characters per line.

  • You can open separate instances of the editor simultaneously, and you can use a drag-and-drop text operation between programs.

  • You can open the definition with which the current set of PeopleCode programs is associated from within the PeopleCode Editor.

  • You can open a field, record, page, file layout, or other definitions from a PeopleCode reference to the field, record, page, or file layout, and so on.

  • You can access PeopleCode programs associated with a field, record, page or file layout, or other definitions from a PeopleCode reference to the field, record, page, or file layout, and so on.

  • You can open a PeopleCode Editor window containing an external function definition from a function declaration or function call.

  • You can press F1 with the cursor in a PeopleCode built-in function, method, meta-SQL, and so on, to open the PeopleSoft help for that item.

When a definition is open in Application Designer, you can access the PeopleCode Editor by:

  • Clicking the View PeopleCode button in the toolbar.

  • Right-clicking the definition and selecting View PeopleCode from the pop-up menu.

  • Selecting the definition and pressing Ctrl + E.

To access the PeopleCode Editor for an Application Class:

  • Double-click the Application Class.

  • Select the Application Class and press Ctrl + E.

Using the View PeopleCode Button in the Toolbar

Field or Control

Definition

View PeopleCode button

For definitions where PeopleCode can be inserted, the View PeopleCode button appears in the dynamic Application Designer toolbar. Click this button to launch the PeopleCode Editor and view the PeopleCode associated with the current definition.

The View PeopleCode button appears for these definition types:

  • records

  • pages

  • components

  • menus

  • component interfaces

  • messages

  • Application Engine programs

Note: Depending on the definition type, the label of the button and the number of buttons that appear might be different. For example, with pages, you see two buttons: View Page PeopleCode and View Record PeopleCode.

Selecting View PeopleCode from the Pop-up Menu

Open a definition in Application Designer, and in the Application Designer workspace, right-click a field, which displays a pop-up menu. Click View PeopleCode to launch the PeopleCode Editor.

Note: Depending on the definition type, the options to launch PeopleCode Editor might be different. For example, with pages, you see two options: View Page PeopleCode and View Record PeopleCode.

Image: Example of accessing PeopleCode Editor from pop-up menu

This example illustrates accessing PeopleCode Editor from the current definition open in the Application Designer workspace.

Example of accessing PeopleCode Editor from pop-up menu

You can also access PeopleCode Editor by selecting the definition and then pressing Ctrl + E on the keyboard.

Accessing PeopleCode Editor for an Application Class

Image: Accessing PeopleCode Editor for an Application Class

This example illustrates accessing PeopleCode Editor for the Application Class from the Application Designer workspace.

Accessing PeopleCode Editor for an Application Class

You can either double click on the selected Application Class or press Ctrl + E on the keyboard after selecting the Application Class to access its PeopleCode Editor.

The PeopleCode Editor supports standard editing function commands such as Save, Cancel, Cut, Copy, Paste, Find, Replace, and Undo, from the PeopleCode Editor pop-up menu. Cut, Copy, and Paste use standard Microsoft Windows keyboard shortcuts. You can also cut, copy, and paste within the same PeopleCode program or across multiple programs.

Use these buttons to perform editing functions:

Field or Control

Definition

Save button

Save the current PeopleCode program. You can also use the key combination CTRL+S.

Cut button

Cut the selected text or item. You can also use the CTRL+X or SHIFT+DEL key combinations.

Copy button

Copy the selected text or item. You can also use the CTRL+C or CTRL+INS key combinations.

Paste button

Paste from the clipboard. You can also use the CTRL+V or SHIFT+INS key combinations.

Find button

Find specified text. You can also use the key combination CTRL+F.

Replace button

Find and replace specified text. You can also use the key combination CTRL+H.

Validate Syntax button

Validate the current PeopleCode program.

Undo the last change. Use the CTRL+Z or ALT+BACKSPACE key combinations.

Cancel the current operation. Use Esc key.

To add line numbers in PeopleCode Editor:

  1. Go to the menu bar of Application Designer.

  2. Click on View.

  3. Select Line Numbers.

    Image: Adding Line Numbers

    The following image illustrates how line numbers are displayed in PeopleCode Editor:

    Adding Line Numbers

To remove line numbers from PeopleCode Editor, uncheck Line Numbers.

Note: Line numbers in PeopleCode Editor are not the same as statement numbers in debug mode. While line numbers are valid for all the lines in PeopleCode editor including comments, declarations and new lines, statement numbers do not include the declare functions and functions that are not debuggable.

Image: Find dialog box

When you use the Find and Replace functions, any text string that is highlighted appears when either the Find or Replace dialog boxes are called. For example, if you select the method ActiveRowCount it appears in the Find dialog box when it's called, as shown in the following example:

Find dialog box

You can move through finding and replacing text strings one string at a time, or click Replace All to replace globally. The Undo function is available to undo the last replace or replace all.

The Mark All button places a bookmark next to all lines that have the matching text. Use Shift+CTRL+f2 to remove all bookmarks.

With the Replace dialog box, you can select to replace text either in a selected section or a whole file (that is, a PeopleCode program.)

Use the Go To dialog box to specify a line number in the current program, then go to that line. If you have line wrap not enabled, you can specify to go to statement numbers instead of line numbers.

Image: Go To dialog box

This example illustrates the fields and controls on the Go To dialog box.

Go To dialog box

To check the syntax of the current PeopleCode program and format it if it is syntactically correct, do one of the following:

  • Click the Validate Syntax button on the Application Designer toolbar.

  • Within Application Designer, select Tools, Validate Syntax.

  • Right-click in the PeopleCode Editor window, then select Validate Syntax.

The Validate utility has several functions, such as finding undeclared variables, mismatching data types, or invalid methods or properties for a class. You can check either a single component or an entire project.

Errors or warnings produced by the Validate utility are displayed in the Validate tab at the bottom of the PeopleCode Editor window.

Any variables that you don't declare are automatically declared for you, and a warning message appears in the Validate tab for each undeclared variable. You can right-click in the Validate tab and select Clear to delete all the warnings listed there, then use the Validate utility again to ensure that your code runs without errors or warnings.

Note: This feature is convenient if you have written multiple PeopleCode programs and you want to check the syntax of one without saving. All PeopleCode programs associated with an item (record, component, and so on) are checked prior to saving.

To display the name of the database in use in the current PeopleCode program:

  1. Open Configuration Manager.

  2. Click on the Display tab.

    Image: Display tab in Configuration Manager:

    The following image illustrates the Display tab in Configuration Manager:

    Enable Show Database Name
  3. Select the Show Database Name check box.

    When you access Application Designer, the name of the database in use is displayed at the bottom right corner of the status bar.

You do not need to format your PeopleCode statements; you need only to use the correct syntax. When you save or validate, the system formats the code according to the rules in the PeopleCode tables, no matter how you entered it originally. The PeopleCode Editor automatically converts field names to uppercase and indents statements.

PeopleCode is case-insensitive, except for quoted literals. PeopleCode does not format anything surrounded by quotation marks. String comparisons, however, are case-sensitive. When you compare the contents of a field or a variable to a string literal, make sure the literal is in the correct case.

All field names in a PeopleCode program must be fully qualified, even if the field is on the same record definition as the PeopleCode program. However, you only need to type in the name of the field. The editor validates if the field exists on the current record, and reformats the field name to recordname.fieldname.

In addition to the standard keyboard shortcuts and toolbar buttons, you can copy or move text within a window or between two PeopleCode Editor windows by using the mouse and the CTRL key.

Note: You cannot open two editor windows for a single parent definition, or for any two of its child definitions.

To move text between instances of the PeopleCode Editor:

  1. Select the text you want to move.

  2. Place the mouse over the text and drag the text to the other PeopleCode Editor window.

  3. When the cursor appears at the place where you want to insert the text, release the mouse button.

To copy text between instances of the PeopleCode Editor:

  1. Select the text you want to move.

  2. Hold down the CTRL key as you drag the text to the other PeopleCode Editor window.

  3. When the cursor appears at the place where you want to insert the text, release the mouse button.

An external PeopleCode function is a function written in PeopleCode (as opposed to a built-in function or external DLL function) and defined in a program outside the one from which it is called. External PeopleCode functions can be defined in any record PeopleCode program, but typically they are stored in the FieldFormula event in records beginning with FUNCLIB_.

The PeopleCode Editor provides immediate access to external PeopleCode function definitions. Right-click the function name in the program where the function is called, then select View Function FunctionName. This opens a new PeopleCode Editor window containing the external function definition.

Note: Internet scripts are contained in records similar to FUNCLIB_ records. However, their names begin with WEBLIB_.

The PeopleCode Editor provides immediate access to application packages, application classes, and application class method definitions.

Right-click the package, class, or method name and, depending on the context, select from:

  • View Application Package

  • View Application Class

  • View Application Class Method

This opens the application package or a new PeopleCode Editor window containing the application class.

Image: Context menu with options view to application packages and classes

The following example shows the context menu for a fully-qualified application class name.

Context menu with options to view application packages and classes

Image: Context menu with options to view application classes and methods

The following example shows the context menu for a method.

Context menu with options to view application classes and methods

Note: The application class context menu is not available for methods that are called by indirection.

In the following example the method CallMe would not be available to view using the context menu.

Object0.GetObject().CallMe();

Accessing Methods in Derived Classes

A method that is defined only in the superclass is not available if you attempt to view it using View Application Class Method with the derived class, or subclass.

For example, in the following code snippet CCI_CRM extends CCI_BASE. The method Validate is not defined in CCI_CRM; it is available to CCI_CRM by extension. The method Submit, on the other hand, is overridden in CCI_CRM.

If you right-click Validate and select View Application Class Method, the cursor will be placed at the beginning of the application class CCR_CRM, not at the method definition in CCI_BASE.

If you right-click Submit and select View Application Class Method, you will be taken to the method definition for Submit in CCI_CRM.

Import EOCC:CCI_CRM;
&CCI = Create EOCC:CCI_CRM();
&CCI.Validate(&Card); 
&CCI.Submit(&Card);

This may be helpful when you need to know whether a method has been overridden.

You can open fields, records, pages, application packages, and other definitions from the PeopleCode Editor. Or you can open a new PeopleCode Editor window containing the programs associated with a field, record, page, application class, or other definition.

To open a definition from the PeopleCode Editor, right-click a PeopleCode definition reference and select View Definition or View Application Package.

For example, you could open definitions by clicking the following references:

  • Record.BUS_EXPENSE_PER

  • BUS_EXPENSE_PER.EXPENSE_PERIOD_DT

  • Page.BUSINESS_EXPENSES

  • PT_BRANDING:BrandingBase

If you access a record definition from a record field reference (that is, recordname.fieldname) the specified record field is selected when the record definition opens.

To open a new PeopleCode editor window, right-click a reference to the definition and select View PeopleCode or, for application class PeopleCode, select View Application Class Method or View Application Class.

For example, you can access record PeopleCode from the following record and record field references:

  • Record.BUS_EXPENSE_PER

  • BUS_EXPENSE_PER.EXPENSE_PERIOD_DT

Note: You can only view the PeopleCode and definition when the text is in the format recordname.fieldname. If the text is in the format method(i).recordname, method(i).fieldname, or &MyRecord.Fieldname, the View PeopleCode and View Definition commands are not available.

You can access application class PeopleCode from the following references:

  • PT_BRANDING:BrandingBase

  • %This.ValidateSave(&aErrs)

The PeopleCode Editor has context-sensitive online help for all PeopleCode built-in functions, methods, properties, system variables, and meta-SQL. To access online help, place the cursor in the item that you want to look up, then press F1. If there is a corresponding entry in the online reference system it appears; otherwise an error message similar to the following appears.

Help cannot be displayed because no help topic was found for the help context ID "my_topic". 

If more than one entry is applicable, a pop-up window that lists all applicable entries appears. Select the entry for the item of interest.

To set up the help, use the F1 Help URL field on the PeopleTools Options page to specify where the PeopleTools documentation is installed.

You can change the display (foreground) color for many language elements in the PeopleCode Editor, including quoted strings, keywords, and built-in functions. You can also change the background color.

To change the display colors:

  1. Select Edit, Display Font and Colors.

  2. Select the language element that you want to change.

  3. Select the foreground color.

    If you click the Automatic check box, the default color is used.

    A box displaying the selected color is only available if the Automatic check box is not selected.

    If you click the box displaying the selected color, the standard color chart for your display appears. If you click Other from this dialog or click the drop-down list on the Font and Color Settings dialog box, the custom color chart for your display appears.

  4. Select the background color.

If you click Reset All, the default colors for the PeopleCode language elements are reassigned.

The default font for the PeopleCode Editor is 9-point Courier New.

To change the PeopleCode Editor font, select Edit, Display Fonts and Colors. Use this dialog box to change the font for the editor.

Note: When you select a font for the PeopleCode Editor, the font selection dialog box provides choices based on a character set appropriate for your international version of Microsoft Windows. If you experience trouble embedding foreign characters (such as Thai characters) in PeopleCode, you might need to change the font setting. If you are trying to display Thai characters in Microsoft Windows 95, you might also need to change your keyboard input settings for the characters to display correctly. You can change your keyboard input settings from the Input Locales tab on the Windows Regional Settings control panel, or on the Keyboard control panel.

The PeopleCode Editor supports text word wrapping. You can turn word wrapping on and off for an open editor window. You can also specify the default value for word wrap, as well as whether the text wraps to the editor's window size or to a fixed number of characters per line.

To turn word wrapping on or off for an open editor window, go to Edit, Word Wrap. After you close Application Designer, all word wrap values are reset to the default value for the editor.

Specifying Word Wrap Options

Go to the Tools, Options dialog box, Editors tab, to specify the word wrap options.

Image: Options dialog box: Editors tab

This example illustrates the fields and controls on the Options dialog box: Editors tab. You can find definitions for the fields and controls later on this page.

Options dialog box: Editors tab

Field or Control

Definition

Enable (word wrap)

Specify whether word wrap is the default mode when opening the editor. If this box is not checked, wrapping text based on window size is the default.

Wrap on Window Size

Specify whether the text wraps based on the size of the window.

Wrap on Line Size

Specify whether the text wraps based on the number of characters in a line. If this box is checked, you can specify the number of maximum number of characters per line.

Maximum Characters per Line

Specify the maximum number of characters allowed for a line before the text wraps. The default value is 90. Valid values are between 25 and 2000.

To access the PeopleCode Event properties, open a PeopleCode editor window, then either press Alt + Enter or click the Properties button.

Image: PeopleCode Event Properties dialog box

This example illustrates the fields and controls on the PeopleCode Event Properties dialog box.

PeopleCode Event Properties dialog box

Important! This dialog box has been deprecated. It has no effect on the location of the execution of code.

The PeopleCode Editor provides an auto-complete feature for PeopleCode application classes, built-in classes, built-in functions, system variables and constants. The auto-complete feature displays the possible options when you insert a period (.) or dot after an object.

The auto-complete feature also supports the display of a tool tip when you hover the mouse over the selected list item. The tool tip displays the method name, parameter type, and the return type.

If you select any item listed in the auto-complete list control and then press F1, it will take you to the context-sensitive online help for that item.

The auto-complete feature is not applicable for objects that are declared as automatic variable and objects that get resolved at run-time.

Setting Up Auto-Complete Feature

To use the auto-complete feature, you must enable the Auto-completion for PeopleCode option on the Editors tab of the Options dialog box.

Image: Options page - PeopleCode Editor group box

This example illustrates the fields for the auto-complete feature.

Options page - PeopleCode Editor group box

PeopleCode Built-in Class Objects

If an object is created out of any built-in classes, such as Record, Document, Feed, the methods or properties of the appropriate class are displayed in a list from which an application developer can choose the required method or property. The list displays the set of methods and properties relevant to the object. As the user types in a string for a method, the nearest matching item gets displayed at the top of the auto-complete list control

Methods and properties are differentiated by using different icons.

For example, in the following code snippet, when you enter a period (.) after the object &sqlObject, methods and properties are displayed in a list box.

rem &sqlObject is of type PeopleCode built-in class SQL;
Local SQL &sqlObject;

&sqlObject = CreateSQL("%SelectAll(:1) where EMPLID = :2", RECORD.ABSENCE_HIST, &EMPLID);
&sqlObject.

Note: The auto-complete feature is not applicable if you create an object as an automatic variable without using the PeopleCode built-in class.

Image: Auto-complete list box for built-in classes

This example illustrates the auto-complete list box for built-in classes.

Auto-complete list box for built-in classes

Application Class Objects

If an object is declared and created from an application class (PeopleTools delivered or customized), the methods or properties of the appropriate class are displayed in a list box.

For example, in the following code snippet, when you enter a period (.) after the object &objHLBase, methods and properties are displayed in a list box.

import PT_BRANDING:HeaderLinkBase;
import PT_BRANDING:HeaderLinkHP;

Local PT_BRANDING:HeaderLinkBase &objHLBase;
Local PT_BRANDING:HeaderLinkHP &objHeaderLink;

&objHLBase = create PT_BRANDING:HeaderLinkBase(&apiPortal, &strtabIndex, &bHdrSearch, &SearchURL, &SearchASLimit, &bGblHdrSearch);
&objHeaderLink = create PT_BRANDING:HeaderLinkHP(&Portal, &tabindex, &navPortal.IsSearchInHdr(), &navPortal.GetSearchPageURL(), &navPortal.GetSearchASLimit(), &navPortal.IsGblSearchInHdr());

rem b)    Objects of type Application Classes;
&objHLBase.

Image: Auto-complete list box for application class objects

This example illustrates the auto-complete list box for application class objects.

Auto-complete list box for application classes

Note: The auto-complete feature is not supported for objects that are created and assigned to a variable that is not declared explicitly.

If you create an object and assign it to a variable that is not declared in the PeopleCode program, the object type is not known at design time to display the relevant methods or properties. For example, in the following code snippet, variables &obj1 and &obj2 are not declared in the PeopleCode program.

,

&obj1 = Create PT_BRANDING:BrandingBase(...);
&obj2 = CreateObject("PT_BRANDING:BrandingBase");

In cases where the class type changes at run time, the methods or properties of the class type that was declared are displayed. For example, if a variable is declared as of type class A and at run-time the type is changed from type A to type B based on a run-time execution of a piece of PeopleCode, the auto-complete feature displays the methods or properties of the type class A because it was declared as type A.

In the following code snippet, the PeopleCode API CreateObject needs to resolve it's parameter to know the Application Package name and the Application Class name. Irrespective of the value of the variable &name that is resolved at run-time, the auto-complete support is provided for the class type PT_BRANDING:HeaderLinkBase on the variable &objHLBase.

Local PT_BRANDING:HeaderLinkBase &objHLBase;
&name = SomeFunction();
&objHLBase = CreateObject(&name);

PeopleCode Built-in Functions, System Variables, and Constants Objects

In the PeopleCode editor, press CTRL+ Space bar to view a list of delivered built-in functions, system variables, and constants. The list displays icons for the different items based on the item type. To list the desired set of options, you can enter the desired characters and then press CTRL+ Space bar. For example, to list all built-in functions, system variables, and constants beginning with “win,” type “win” and then press CTRL+Space bar.

Press the Esc key, to close the list box.

Image: Listing of built-in functions, system variables, and constants

This example illustrates the listing of built-in functions, system variables, and constants in PeopleCode Editor.

Listing of built-in functions, system variables, and constants

Auto-completion Support for Keywords

In a PeopleCode Editor, pressing CTRL + Spacebar brings up a list control with a list of delivered built-in functions, system variables, and constants. Pressing CTRL + Spacebar also lists keywords of PeopleCode.

Image: Auto-completion Support for Keywords

The following image illustrates the listing of keywords and other items in PeopleCode Editor:

Auto-complete Support for Keywords

Keywords are shown with a key icon to differentiate them from other items.

The PeopleCode Editor provides an Event Mapping button in the dynamic Application Designer toolbar. For an application developer, the Event Mapping button is a visual indicator of custom PeopleCode programs mapped to events of a component, component page, component record, or component record field.

Using the Event Mapping Button

The Event Mapping button in the toolbar is enabled when the PeopleCode being viewed for a component, component page, component record or component record field event are mapped to custom PeopleCode programs. When you select the Event Mapping button, the Find Definition References tab (of the output window) lists the events that are mapped to custom PeopleCode programs along with the application class.

Field or Control

Definition

Event Mapping button

Select the Event Mapping button to view a list of events in the selected component, component record, or component record field.

Image: Find Definition References tab (in output window)

This example illustrates the Find Definition References tab (in output window), which displays the list of events.

Find Definition References tab (in output window)

Finding Event Mapping References

To find references to other components where the custom PeopleCode programs of an application class are used, you should complete the following steps:

  1. In the Find Definition References, right-click the application class.

    A pop-menu is displayed.

  2. From the pop-up menu, select Event Mapping References.

    The list of components is displayed in the Event Mapping References tab (of the output window).

Image: Event Mapping References (in output window)

This example illustrates the Event Mapping References (in output window), which displays the components that use the application class.

Event Mapping References (in output window)