Programming Component Interfaces Using PeopleCode

This chapter provides an overview of PeopleCode behavior and limitations and discusses how to:

Click to jump to parent topicUnderstanding PeopleCode Behavior and Limitations

Note the behavior and limitations discussed in this section when you write PeopleCode for a component interface.

Click to jump to top of pageClick to jump to parent topicPeopleCode Event and Function Behavior

PeopleCode events and functions that relate exclusively to the graphical user interface and online processing cannot be used by component interfaces. These include:

Click to jump to top of pageClick to jump to parent topicCopyRowset Language Considerations

In previous PeopleSoft releases, CopyRowset* functions for component interfaces were not sensitive to the language code on PSCAMA. Because of this, related language processing did not take place when language code on PSCAMA was different from the base language code. PeopleSoft now detects the language code in PSCAMA.

Click to jump to top of pageClick to jump to parent topicLimitations of Client-Only PeopleCode

Component interfaces can run on either the client or the server. By default, a component interface runs on the server. It runs on the client only if the code calling the component interface is running on a client machine.

Component interfaces must run either entirely on the server or entirely on the client. To ensure this runtime restriction, component interface references declared in PeopleCode must be declared as local, not global, variables.

Some built-in functions are always client-only; others are client-only under specific conditions.

Some built-in functions behave differently when used in three-tier mode, as opposed to two-tier mode.

Click to jump to parent topicGenerating PeopleCode Templates to Access Component Interfaces

To access a component interface using PeopleCode, PeopleSoft Application Designer generates a template in the form of boilerplate PeopleCode that you can adapt to your purposes. This section describes how to generate the template code.

To generate a PeopleCode template for a component interface:

  1. Open the desired component interface definition in PeopleSoft Application Designer.

  2. Insert the component interface into a project.

    1. Select Insert, Current Object into Project.

    2. Save the project.

  3. Open the PeopleCode editor.

    You can associate component interface PeopleCode with a record, a component, a service operation handler, or an Application Engine program.

  4. Select the component interface from the project workspace.

    Drag and drop the object from the project into the PeopleCode Editor.

  5. Make any necessary changes to the PeopleCode in the PeopleCode Editor window.

Click to jump to parent topicUnderstanding PeopleCode Templates

The code shown in this section is a dynamically generated PeopleCode template that you can use as a starting point. Replace all default values or <*> notations with specific values or references to valid PeopleCode variables (replace this entire three-character string: <*> ).

Note. The requirement to populate a non-create key is no longer a requirement to do the initial save.

PeopleCode runs only if you are connected. This means that you do not have to explicitly connect. Instead, connect to the existing session, using the %Session system variable.

See Session Classes Methods and Properties.

You cannot connect to a different database through PeopleCode.

Set the PeopleSoft session error message mode. This property is used to determine how messages are output. This property takes either a numeric value or a constant. The default value is 1 (%PSMessages_CollectionOnly).

This property sets the value for the session. You can change modes during a session, for example, if you're starting a component interface. However, after you run the component interface, you should set the value back. Here is the list of modes that you can use:

Mode Value

Purpose

0

Return no messages.

1

Default. Log messages into the PSMessage collection.

2

Display a pop-up message or dialog box.

3

Log messages into the PSMessage collection and pop up a message dialog box.

See PSMessagesMode.

PeopleCode Template Notes

Get a reference to the component interface providing its name. (A runtime error occurs if the component interface does not exist.)

Set the keys for the component interface. In this example SDK_EMPLID is the Get key.

The get() method retrieves data from the database, associated with the key values.

Get and print properties at level 0.

Similar code is generated for the properties SDK_BIRTHDATE and SDK_DEPTID.

Get collection at level 1 (SDK_BUS_EXP_PER).

Get and print properties at level 1.

Similar code is generated for the properties SDK_EMPLID and SDK_BUS_EXP_SUM in the SDK_BUS_EXP_PER collection.

Get collection at level 2 (SDK_BUS_EXP_DTL).

&oSdkBusExpDtlCollection = &oSdkBusExpPer.SDK_BUS_EXP_DTL;

Get and print properties at level 2.

Similar code is generated for the properties SDK_EMPID, SDK_EXP_PER_DT, SDK_EXPENSE_CD, SDK_EXPENSE_AMT, SDK_CURRENCY_CD, SDK_BUS_PURPOSE, and SDK_DEPTID.