# PeopleSoft Component Interface PeopleCode Generator

> Source: https://netray.co/tools/peoplesoft-component-interface-peoplecode-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generate the standard PeopleCode to open a Component Interface, Get or Create a key, set properties, Save with PSMessages error handling, plus a CallAppEngine example.

## Category

developer

## Erp

Oracle PeopleSoft

## Audience

- PeopleSoft developer
- PeopleSoft technical consultant

## Tool

**Kind:** template

**Output:** code

**Language:** peoplecode

**Fields:**

#### Component Interface name

**Key:** ci_name

**Type:** text

**Default:** CI_PERSONAL_DATA

#### Key property

**Key:** key_prop

**Type:** text

**Default:** EMPLID

**Help:** Exact key property name as shown in the CI definition in Application Designer.

#### Key value

**Key:** key_value

**Type:** text

**Default:** KU0001

#### Mode

**Key:** mode

**Type:** select

**Options:**

- Get
- Create

**Default:** Get

**Help:** Get opens an existing instance; Create starts a new one.

#### GetHistoryItems

**Key:** history

**Type:** select

**Options:**

- True
- False

**Default:** True

**Help:** True loads all effective-dated rows (like Update/Display All); False loads current and future rows only (like Update/Display).

#### Property assignments (one PeopleCode line each)

**Key:** props

**Type:** textarea

**Default:** &oCi.PROPERTY_ONE = "Value 1";
&oCi.PROPERTY_TWO = "Value 2";

**Help:** Replace with real property names from your CI.

#### Application Engine program for CallAppEngine

**Key:** ae_name

**Type:** text

**Default:** MY_AE_PROG

#### AE state record

**Key:** state_rec

**Type:** text

**Default:** MY_AET

**Blocks:**

#### Component Interface: open, {{mode}}, set, save

**Body:** Local ApiObject &oSession;
Local ApiObject &oCi;
Local integer &i;

&oSession = %Session;
&oSession.PSMessagesMode = 1;

&oCi = &oSession.GetCompIntfc(CompIntfc.{{ci_name}});
If &oCi = Null Then
   Error ("Unable to get Component Interface {{ci_name}}");
End-If;

&oCi.InteractiveMode = False;
&oCi.GetHistoryItems = {{history}};
&oCi.EditHistoryItems = False;

&oCi.{{key_prop}} = "{{key_value}}";
If Not &oCi.{{mode}}() Then
   For &i = 1 To &oSession.PSMessages.Count
      MessageBox(0, "", 0, 0, &oSession.PSMessages.Item(&i).Text);
   End-For;
   &oSession.PSMessages.DeleteAll();
   Error ("{{mode}} failed for {{key_prop}} = {{key_value}}");
End-If;

{{props}}

If Not &oCi.Save() Then
   For &i = 1 To &oSession.PSMessages.Count
      MessageBox(0, "", 0, 0, &oSession.PSMessages.Item(&i).Text);
   End-For;
   &oSession.PSMessages.DeleteAll();
End-If;

&oCi.Cancel();

#### CallAppEngine with a state record

**Body:** Local Record &stateRec;

&stateRec = CreateRecord(Record.{{state_rec}});
/* set state record fields the program reads, for example: */
/* &stateRec.EMPLID.Value = "{{key_value}}"; */

CallAppEngine("{{ae_name}}", &stateRec);

**Notes:** The fastest way to get exact property and collection names is to open the CI in Application Designer and drag it into a PeopleCode editor window, which generates a full template. The user running the code needs the CI and its methods granted on a permission list (Component Interfaces tab). CallAppEngine runs synchronously in the current session; for long runs, schedule the program with a ProcessRequest object instead.

## Content

**Intro:** This generator writes the PeopleCode that opens a PeopleSoft Component Interface, gets or creates an instance by key, sets properties, saves and reports errors from the PSMessages collection. It also gives a CallAppEngine call with a state record.

**Sections:**

#### How to use it

**Body:** Type the CI name, its key property and a test key value, choose Get for an existing row or Create for a new one, and paste your property assignments as PeopleCode lines. The generated code runs from an Application Engine PeopleCode action, an application class or a component event. For effective-dated components, set GetHistoryItems to True when you need to see or insert history rows, and keep EditHistoryItems False unless you deliberately want to change past rows. For collections (child scrolls), the generated template from Application Designer shows the collection names, InsertItem and Item methods you need.

**Bullets:**

- Get: set all key properties, then call Get().
- Create: set create keys, then call Create().
- Save validates exactly like the online component, including SaveEdit and SavePreChange PeopleCode.

#### Why the CI and not SQL

**Body:** A Component Interface runs the component's own edits, prompt validation, PeopleCode and save logic, so data written through it behaves as if a user keyed it into the page. Direct SQL updates skip all of that and can leave audit records, effective-dated rows and derived tables out of step. The trade-off is speed: CIs are slower than set-based SQL, so for very large loads consider an Application Engine with set-based SQL plus the delivered audit and validation steps, or a delivered Excel to CI or integration where one exists.

#### Errors and messages

**Body:** PSMessagesMode = 1 sends messages to the PSMessages collection instead of raising them, so your loop can log every error and continue with the next row. When Get, Create or Save returns False, loop from 1 to PSMessages.Count and read Item(&i).Text, then call DeleteAll() so the next row starts clean. InteractiveMode False defers field edits until Save, which is the normal batch setting and much faster. Call Cancel() after each instance so the CI releases its buffer before the next key.

**Bullets:**

- Wrap per-row work in try-catch so one bad row does not end the program.
- Commit frequency in Application Engine controls how much work is lost on failure.

**Cta:** If you want staff to look up and check PeopleSoft records in plain English on your own servers before a CI load runs, we can set that up as a private AI layer.

**Faq:**

#### How do I call a Component Interface from PeopleCode?

**Answer:** Get the session with %Session, call GetCompIntfc(CompIntfc.NAME), set InteractiveMode, GetHistoryItems and EditHistoryItems, set the key properties, and call Get() or Create(). Then set properties and call Save(). Check the Boolean return of each method and read errors from the session PSMessages collection.

#### How do I call an Application Engine from PeopleCode?

**Answer:** Use CallAppEngine("PROGRAM_NAME", &stateRecord) where the state record is a record object of the program's state record with the input fields populated. It runs synchronously in the same session. For anything long-running or that should appear in Process Monitor, create a ProcessRequest object and schedule the program instead.

#### What does GetHistoryItems do on a CI?

**Answer:** When True, the CI loads all effective-dated rows, like opening the component in Update/Display All mode. When False, it loads only current and future rows, like Update/Display. Setting EditHistoryItems True as well gives Correction mode, which allows changes to history rows and needs a user with Correction access on that component.

#### Why does my Component Interface Save fail with no message?

**Answer:** Usually PSMessagesMode is not set, or the loop that reads PSMessages runs after DeleteAll. Set PSMessagesMode = 1, read every item after a False return, and check that the running user has the CI methods granted on a permission list. Missing required fields and prompt table edits are the most common real causes.

## Search terms

peoplecode component interface example, peoplesoft component interface peoplecode, peoplecode call app engine, peoplesoft how to update data, peoplesoft ci psmessages, getcompintfc peoplecode, callappengine peoplecode example

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
