Session Class Methods

Component Interfaces don’t have any built-in functions. They are instantiated from the Session class.

This section discusses the Session class methods used to instantiate Component Interfaces. The methods are discussed in alphabetical order.

Syntax

FindCompIntfcs([ComponentName])

Description

The FindCompIntfcs method, used with the Session object, returns a reference to a Component Interface collection, filled with zero or more Component Interfaces. The ComponentName parameter takes a string value. You can use a partial value to limit the set of Component Interfaces returned. You can also specify a null value, that is, two quotation marks with no space between them, ("") to return the entire list of Component Interfaces available.

Using the FindCompIntfcs method is equivalent to using File, Open, and selecting Component Interface in Application Designer.

Example

In the following example, a partial key was used to open all components starting with "APP".

Local ApiObject &MYSESSION;
Local ApiObject &MYCI;

&MYSESSION = %Session;
&MYCICOLL = &MYSESSION.FindCompIntfcs("APP");
&MYCI = &MYCICOLL.First();

Syntax

GetCompIntfc([COMPINTFC.]ComponentName)

Description

The GetCompIntfc method, used with the session object, returns a reference to a Component Interface. ComponentName when used by itself takes a string value. If you use COMPINTFC.componentname it isn’t a string value: it’s a constant that automatically is renamed in your code if the Component Interface definition is ever renamed. You must specify an existing Component Interface, otherwise you receive a runtime error.

Example

Local ApiObject &MYSESSION;
Local ApiObject &MYCI;

&MYSESSION = %Session;
&MYCI = &MYSESSION.GetCompIntfc(COMPINTFC.PERSONAL_DATA_BC);

The following example uses the '@' operator to dynamically call a Component Interface from PeopleCode.

&MYCI = &MYSESSION.GetCompIntfc(@("CompIntfc." | &CIname));

Syntax

ValidateCompIntfc(ComponentInterfaceName)

Description

The ValidateCompIntfc method, used with the Session object, returns an integer value indicating whether the validation is successful. The validation fails if no component interface exists with the given name. The primary purpose of this method is to validate the successful compilation of all PeopleCode programs associated with both the component and the component interface. In addition, this method verifies other relationships of the component interface to the component, such as, but not limited to checking whether the component interface:

  • Contains a reference to an invalid component.

  • Is defined with CREATEKEYS, but the component does not allow the add action.

  • Is defined with CREATEKEYS, but the specified field is not a search key.

  • Has a reference to an invalid field.

  • Has a reference to an invalid record.

  • Is defined with FINDKEYS, but the specified field is not a search key or an alternate search key.

  • Is defined with GETKEYS, but the specified field is not a search key.

  • Has references to a search or add record that is invalid.

Parameters

Field or Control

Definition

ComponentInterfaceName

Specify the component interface name as a string.

Returns

An integer value indicating whether the validation is successful: 0 indicates success; any non-zero value indicates failure.

Example

In the following example, a component interface with name "DEMOAPP_CI" is validated.

Local ApiObject &MYSESSION; 
Local integer &nRet; 

&MYSESSION = %Session; 
&nRet = &MYSESSION.ValidateCompIntfc("DEMOAPP_CI"); 

If &nRet <> 0 Then
   /* Failure Case */
Else
   /* Success Case */
End-If;