Accessing the Structure of a Component Interface
The structure of a Component Interface can be accessed using a CompIntfPropInfoCollection object. You access a CompIntfPropInfoCollection object from a CompIntfPropInfoCollection collection. There is more than one way to instantiate a CompIntfPropInfoCollection collection.
Note: You don’t have to populate a Component Interface with data before you access the structure. You can access the structure of a Component Interface immediately after you use the GetCompIntfc method with a session object. Accessing the structure of a Component Interface before you populate it with data may increase your performance.
See GetCompIntfc.
There are two types of CompIntfPropInfoCollection object properties: field properties and collection properties.
A field property maps to a specific record field. You can access structural information about the field using a CompIntfPropInfoCollection object. This information includes the name of the field, whether it’s required, is it based on a prompt table, and so on.
A collection property is just that, a collection of properties. And before you can access a CompIntfPropInfoCollection object, you must first get a CompIntfPropInfoCollection collection. The following are the valid types of CompIntfPropInfoCollection collections:
CREATEKEYS, GETKEYS and FINDKEYS
When you create a component, you must specify the search record to be used with that component. You can also specify an alternate search record to be used when the component is accessed in Add mode. The key fields from those records make up the GETKEYS, FINDKEYS, and CREATEKEYS collections.
Note: In order for a component interface to validate a key against a prompt table, both the Search Edit and List Box Item options must be selected in the record field properties for the key.
CREATEKEYS: A collection containing the key fields of the search record specified to be used in Add mode. Use the CreateKeyInfoCollection property to instantiate the CompIntfPropInfoCollection collection.
GETKEYS: A collection containing the primary required key fields from the primary search record. Use the GetKeyInfoCollection property to instantiate the CompIntfPropertInfo collection.
FINDKEYS: A collection containing the key fields and the alternate key fields from the primary search record. Use the FindKeyInfoCollection property to instantiate the CompIntfPropertInfo collection.
A page scroll
The fields associated with a page scroll are in this type of collection. This may or may not be all the fields associated with the record. Use the PropertyInfoCollection property to instantiate this kind of collection.
If the page the Component Interface is based on contains a secondary scroll, you can check the Type property to determine if the object is a CompIntfPropInfoCollection object (that is, a field), or a scroll. Then, to get the properties of the fields associated with that secondary scroll, you can use the PropertyInfoCollection property on the CompIntfPropInfoCollection object.
For example, the following Component Interface has a level zero and level one scroll.
The level zero scroll is made up of three fields: CHECKLIST_CD, RESPONSIBLE_ID, COMMENTS, and a level one scroll, EMPL_CHKLST_ITM. The CompIntfPropInfoCollection collection for this Component Interface would have four items in it. Three would be CompIntfPropInfoCollection objects (the three fields.) The last item, EMPL_CHKLST_ITM would not be a valid CompIntfPropInfoCollection object. You can use the IsCollection property to verify if an item in a collection is itself a collection or a valid CompIntfPropInfoCollection object.
To access the fields in a lower level scroll, you must use the PropertyInfoCollection property first, to return a collection of those fields.
The following example loops through a Component Interface. It pulls out the names of the properties in the first three levels of a Component Interface. If the property is a nested collection, it prefixes the ancestor collection name to the property name.
&MYSESSION = %Session;
&CI = &MYSESSION.GetCompIntfc(COMPINTFC.VOLNEW);
&PROPINFO_0 = &CI.PropertyInfoCollection;
For &I = 1 To &PROPINFO_0.Count;
&PROPITEM_0 = &PROPINFO_0.Item(&I);
Warning (&PROPITEM_0.Name);
If (&PROPITEM_0.IsCollection) Then
&PROPINFO_1 = &PROPITEM_0.PropertyInfoCollection;
For &J = 1 To &PROPINFO_1.Count;
&PROPITEM_1 = &PROPINFO_1.Item(&J);
&S1 = &PROPITEM_0.Name | "." | &PROPITEM_1.Name;
Warning (&S1);
If (&PROPITEM_1.IsCollection) Then
&PROPINFO_2 = &PROPITEM_1.PropertyInfoCollection;
For &K = 1 To &PROPINFO_2.Count;
&PROPITEM_2 = &PROPINFO_2.Item(&K);
&S1 = &PROPITEM_0.Name | "." | &PROPITEM_1.Name | "." | &PROPITEM_2.Name;
Warning (&S1);
End-For;
End-If
End-For;
End-If;
End-For;