Step 3. Filter Code
Even though you can create most filters simply by using the Program Coding Assistant, you should understand how they are coded.
1. Switch to the Visual LANSA editor where the iiiCOM01 component is open.
2. Review the generated source code in the Source tab to see how the filter is coded to add data to the instance list:
The Framework is notified that an update is about to occur.
Invoke #avListManager.BeginListUpdate
Next, the list is cleared of any existing items.
Invoke #avListManager.ClearList
Next, data is selected. You can use one the techniques you learnt in the Visual LANSA Fundamentals tutorials to do this. For example:
Select Fields(#XG_Ident) From_File(PSLMST2) With_key(#XG_Keys) Generic(*yes) Nbr_Keys(*Compute)
Next, the visual identifiers are set up:
Change #UF_VisID1 #EMPNO
Change #UF_VisID2 #SURNAME
Then the data is added to the list.
Invoke #avListManager.AddtoList Visualid1(#UF_VisID1) Visualid2(#UF_VisID2) AKey1(#EMPNO)
VisualId1 will be shown in column one of the instance list and VisualId2 will be shown in column two of the instance list. Akey1 is the key that uniquely identifies an employee (in this case the field is alphanumeric, so its Akey1, not Nkey1).
Finally, the Framework is notified that the instance list update is complete.
Invoke #avListManager.EndListUpdate)
3. Next click on Details tab in the editor to display the properties of your component.
You need to ensure that all properties are displayed:
4. Select the Settings option in the Options menu.
5. Click on Details and make sure the Show Advanced Features option is selected.
6. Notice that the Ancestor property of the component is #VF_AC007. All filters inherit from this base class which provides a set of predefined behavior.
7. Click on the Outline tab in the editor to see what components you inherit from the VF_AC007 ancestor component.
8. Right-click the avLISTMANAGER component and select the Features option.
9. Expand the methods of the component and examine them.
10. Close the iiiCOM01 component.
You may want to read Windows Filter and Command Handler Anatomy to see how these components are structured.