Step 3 Filter Code

Visual LANSA

Step 3. Filter Code

Although 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 iiiCOM21 component is open.

2.  Use the GoTo tab to select the uSelectData method routine.

     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 of the techniques you learnt in the Visual LANSA Fundamentals exercises 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 key field is alphanumeric).

     Finally, the Framework is notified that the instance list update is complete.

Invoke #avListManager.EndListUpdate)
 

3.  Click on Details tab in the editor to display the properties of your component.

     You need to ensure that all properties are displayed:

4.  From the File menu, select Options.

5.  In the LANSA Settings dialog, select the General group, click on Details and make sure the Show Advanced Features option is selected.

Click OK to close the LANSA Settings dialog.

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 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.

If you double click on any of the methods, help text is displayed in the Help tab.

10.  Close the iiiCOM21 component.

     You may want to read Windows Filter and Command Handler Anatomy in the in the Visual LANSA Framework Guide to see how these components are structured.