Using the PeopleCode Editor

This chapter discusses how to:

Click to jump to parent topicNavigating Between PeopleCode Programs

After you access a PeopleCode program associated with a Application Designer definition, you can access programs associated with other related definitions without having to close the editor window.

This section provides an overview of the PeopleCode Editor window and discusses how to:

See Also

Accessing PeopleCode and Events

Click to jump to top of pageClick to jump to parent topicUnderstanding the PeopleCode Editor Window

Application Designer supplies an independent editor window for each parent definition, such as a record, component interface, or an analytic model, for which you invoke the editor. The editor window’s title bar displays the name and type of the parent definition, as shown in the following illustration:

PeopleCode Editor window with record field PeopleCode

The editor window contains the main edit pane, the drop-down definition list at the upper-left, and the drop-down event list at the upper-right. The drop-down lists enable you to navigate directly to the PeopleCode associated with related child definitions, for example, fields within a record and their event sets.

Note. When you make a selection from either drop-down list box, your selected entry has a yellow background, indicating that you must click the edit pane before you can start typing.

You can open as many editor windows as you want and resize them in Application Designer. Each line of code wraps automatically based on the window’s current width. A vertical scroll bar appears if the program has more lines than the editor can display in the edit pane.

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

See Also

Navigating Between Programs Associated With a Definition and Its Children

Navigating Between Programs Associated With Events

Click to jump to top of pageClick to jump to parent topicNavigating Between Programs Associated With a Definition and Its Children

You use the drop-down definition list to navigate between PeopleCode programs that are associated with a parent definition and its children. The list displays the complete hierarchy of child definitions to which you can navigate; bold items have PeopleCode associated with at least one event in the item's event set. The structure of the definition list depends on the type of parent definition. Parent definitions include:

Click to jump to top of pageClick to jump to parent topicNavigating Between Programs Associated With Events

Use the PeopleCode Editor’s drop-down event list to select an event from the event set of the currently selected definition. Use this event list to navigate between PeopleCode programs that are associated with that definition. For every definition-event combination with associated PeopleCode, the event name is displayed in bold, and it appears at the top of the event list, as shown in the following illustration:

See Also

Accessing PeopleCode and Events

PeopleCode and the Component Processor

Click to jump to parent topicUsing the PeopleCode Editor

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

Click to jump to top of pageClick to jump to parent topicUnderstanding 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:

Click to jump to top of pageClick to jump to parent topicWriting and Editing PeopleCode

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:

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

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

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

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

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

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

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.

See Also

PeopleCode Editor Short Cut Keys

Click to jump to top of pageClick to jump to parent topicFind and Replace Dialogs

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.)

 

Click to jump to top of pageClick to jump to parent topicGo To Dialog

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.

Click to jump to top of pageClick to jump to parent topicValidate Syntax Utility

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

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.

See Also

Validating Projects

Compiling All PeopleCode Programs at Once

Click to jump to top of pageClick to jump to parent topicFormatting Code Automatically

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.

Click to jump to top of pageClick to jump to parent topicUsing Drag-and-Drop Editing

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.

Click to jump to top of pageClick to jump to parent topicAccessing PeopleCode External Functions

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_.

Click to jump to top of pageClick to jump to parent topicAccessing PeopleCode Application Packages and Application Classes

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:

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

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

The following example shows the context menu for a method.

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.

Click to jump to top of pageClick to jump to parent topicAccessing Definitions and Associated PeopleCode

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:

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:

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:

Click to jump to top of pageClick to jump to parent topicAccessing Help

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 name of what you want to look up, then press F1. If there is a corresponding entry in the online reference system it appears; otherwise a No Help Available error message appears.

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

See Also

PeopleTools Options

Click to jump to top of pageClick to jump to parent topicSetting up Help

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

The format of the URL is as follows:

http:// doc_location /f1search.htm?ContextID=%CONTEXT_ID%&LangCD=%LANG_CD%

The doc_location specifies where the documentation files are located on your system. The rest of the URL exactly the above format.

For example, you might place the following URL in the F1 Help URL field:

http://Pandora/doc/f1search.htm?ContextID=%CONTEXT_ID%&LangCD=%LANG_CD%

After you specify the help location, you must exit all PeopleTools sessions and start again before you can access the help.

Click to jump to top of pageClick to jump to parent topicChanging Colors in the PeopleCode Editor

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.

Click to jump to top of pageClick to jump to parent topicSelecting a Font for the PeopleCode Editor

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.

Click to jump to top of pageClick to jump to parent topicChanging Word Wrap in the PeopleCode Editor

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.

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.

Click to jump to top of pageClick to jump to parent topicUsing the PeopleCode Event Properties

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

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

Click to jump to parent topicGenerating PeopleCode Using Drag-and-Drop

You can generate references to definitions using a drag-and-drop operation. You can also generate PeopleCode templates for accessing business interlinks and component interfaces.

This section discusses how to:

Click to jump to top of pageClick to jump to parent topicGenerating Definition References

When you drag definitions, such as menus, records, record fields, and pages, from a project into an open PeopleCode editor window, you generate a reference to the definition. For example, suppose your project contain a component named QEACTIVITY_GUIDE_1. If you drag the QEACTIVITY_GUIDE_1 component definition from the project into an open PeopleCode window, the word QEACTIVITY_GUIDE_1 prefixed with the keyword COMPONENT is written to the PeopleCode program in the place where you dragged the definition.

Click to jump to top of pageClick to jump to parent topicGenerating PeopleCode for a Business Interlink

After you create a business interlink definition, you use PeopleCode to instantiate an interlink object and activate the interlink plug-in. This PeopleCode can be long and complex. Rather than write it directly, you can drag and drop the business interlink definition from the Application Designer Project view into an open PeopleCode edit pane. PeopleCode Application Designer analyzes the definition and generates initial PeopleCode as a template, which you can modify to suit your purpose.

The following is a snippet of the code that is generated:

/* ===> /* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '<*>' OR default values with references to PeopleCode variables and/or a Rec.Fields.*/ /* ===> Declare and instantiate: */ Local Interlink &QE_AE_NONSSL__1; Local BIDocs &inDoc; Local BIDocs &outDoc; Local boolean &RSLT; Local number &EXECRSLT; &QE_AE_NONSSL__1 = GetInterlink(INTERLINK.QE_AE_NONSSL_BI); . . . .

Click to jump to top of pageClick to jump to parent topicGenerating PeopleCode for a Component Interface

After you create a component interface definition, you can use PeopleCode to access it. This PeopleCode can be long and complex. Rather than write it directly, you can drag and drop the component interface definition from the Application Designer Project view into an open PeopleCode edit pane. Application Designer analyzes the definition and generates initial PeopleCode as a template, which you can modify to meet your requirements.

The following is a snippet of the code that is generated:

/* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '<*>' OR default values with references to PeopleCode variables and/or a Rec.Fields. */ Local ApiObject &oSession; Local ApiObject &oCurrencyCdCi; Local ApiObject &oPSMessageCollection; Local ApiObject &oPSMessage; Local File &LogFile; Local number &i; Local String &strErrMsgSetNum, &strErrMsgNum, &strErrMsgText, &strErrType; . . .

You can also access a component interface using the component object model (COM). You can automatically generate a Visual Basic template, a Java template, or a C template, similar to the PeopleCode template, to begin.

To generate a template:

  1. Open a component interface in Application Designer.

  2. Right-click anywhere in the open component interface and select a template type.

    You must save the component interface before generating the template.

    When the template is successfully generated, a message appears with the full path and name of the file containing the template.

  3. Open the generated file and modify the source code to meet the needs of your application.

    The following is the initial code snippet that is generated for a Visual Basic template:

    Option Explicit '===> 'This is a dynamically generated Visual Basic template to be 'used only as a helper to the application developer. 'You need to replace all references to '<*>' OR default 'values with references to Visual Basic variables. Dim oSession As PeopleSoft_PeopleSoft.Session Private Sub ErrorHandler() '***** Display PeopleSoft Error Messages ***** If Not oSession Is Nothing Then If oSession.ErrorPending Or oSession.WarningPending Then Dim oPSMessageCollection As PSMessageCollection Dim oPSMessage As PSMessage Set oPSMessageCollection = oSession.PSMessages Dim i As Integer For i = 1 To oPSMessageCollection.Count Set oPSMessage = oPSMessageCollection.Item(i) Debug.Print "(" & oPSMessage.MessageNumber & "," & oPSMessage.MessageSetNumber & ") : " & oPSMessage.Text Next i '***** Done processing messages in the collection; '***** OK to delete ***** oPSMessageCollection.DeleteAll End If End If End Sub . . . .

Click to jump to top of pageClick to jump to parent topicGenerating PeopleCode for a File Layout

After you create a file layout definition, you can use PeopleCode to access it. This PeopleCode can be long and complex. Rather than write it directly, you can drag and drop the file layout definition from the PeopleCode Application Designer Project view into an open PeopleCode edit pane. Application Designer analyzes the definition and generates initial PeopleCode as a template, which you can modify to meet your requirements.

This example shows some of the code that is generated:

Function EditRecord(&REC As Record) Returns boolean ; Local integer &E; REM &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + %Edit_YesNo + %Edit_TranslateTable + %Edit_PromptTable + %Edit_OneZero); &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + %Edit_YesNo + %Edit_OneZero); If &REC.IsEditError Then For &E = 1 To &REC.FieldCount &MYFIELD = &REC.GetField(&E); If &MYFIELD.EditError Then &MSGNUM = &MYFIELD.MessageNumber; &MSGSET = &MYFIELD.MessageSetNumber; &LOGFILE.WriteLine("****Record:" | &REC.Name | ", Field:" | &MYFIELD.Name ); &LOGFILE.WriteLine("****" | MsgGet(&MSGSET, &MSGNUM, "")); End-If; End-For; Return False; Else Return True; End-If; End-Function; . . . .