Step 3. Create a Hidden Filter for Company Departments
In this step you will create a hidden filter that loads the Company Departments to the instance list when you select the Company Departments business object in the navigation pane. With a hidden filter there is no end-user interaction and the filter is not visible.
1. Display the Visual LANSA Editor.
2. Create a reusable part. Specify iiiCOM08 as the name of your filter and Departments Hidden Filter as the description. (iii are your initials. If you are using an unlicensed or trial version of Visual LANSA, you must always use the three characters DEM to replace iii).
3. In the Details tab specify VF_AC007 as the Ancestor of the reusable part.
4. Display the Source tab.
5. Create a uInitialize routine after the BEGIN_COM statement:
Mthroutine Name(uInitialize) Options(*Redefine)
Endroutine
The Endroutine statement may be created automatically if you have the AutoComplete Prompter turned on.
6. In the uInitialize routine make the filter hidden so that all that will show at run-time is the instance list:
Set #Com_Owner avHiddenFilter(TRUE)
7. Then indicate that the instance list updating is about to start and clear the instance list:
Invoke #avListManager.BeginListUpdate
Invoke #avListManager.ClearList
8. Read all the departments and add them to the instance list:
Select Fields(#Deptment #DeptDesc) From_File(DEPTAB)
Invoke #avListManager.AddtoList Visualid1(#DeptDesc) Visualid2(#Deptment) AKey1(#Deptment) BusinessObjectType(COMPANY_DEPARTMENTS) NColumn1(0) Acolumn1('') Acolumn2('') Acolumn3('') Acolumn4('') Acolumn5('') Acolumn6('') Acolumn7('')
EndSelect
Note: It is necessary to initialize the additional columns with the AddToList, as you will later populate the list with entries for Department Sections, which will fill these columns.
9. Lastly indicate that instance list updating is now complete:
Invoke #avListManager.EndListUpdate
Your code will look like this:
10. Compile the filter.
11. Display the Framework and then the properties of the Company Departments object.
12. Display the Filter Snap-in Settings tab.
13. Specify iiiCOM08 as the real filter.
14. Close the Company Departments’ properties.
15. Click on Employees and then Company Departments again so that the hidden filter loads the departments to the instance list.
16. Expand a Department. Notice that no Department Sections are loaded. You will create the relationship handler that loads the sections in the next step.