Step 1. Creating Your Real WAM Filter
In this step, you will create your own filter by creating a WAM which will be snapped into the Visual LANSA Framework.
1. Make sure that the Enable Framework for WAMs option in the Framework Details tab is selected. In the Visual LANSA editor check that you can create new WAMs (the option is available if your system is enabled for Web).
2. Start the Program Coding Assistant in the Framework using the (Framework) menu.
The Program Coding Assistant window is displayed. It allows you to create different types of components that can be plugged into your filters, instance lists and command handlers. It is highly recommended to use the program coding assistant when you first start using the Framework.
Initially you will most likely use filters that generate a component that can be executed (e.g. CRUD Filter (Create/Read/Update/Delete), Filter that searches a file or view). As you progress you might only use a skeleton filter or simply copy from one that is similar to one that you want to create.
3. If you are using a non-English system, click on Framework -> Your Framework in the top-left tree view. The Set LANSA code generation preferences option appears at the bottom. Select this option and set your preferences.
4. Select the iii HR application and then the By Name filter.
5. Choose Web – using WAM components as the platform and and Filter that searches using a file or a view.
6. Click the Next button.
7. Specify PSLMST as the Physical File that most closely resembles this business object
The Program Coding Assistant detects the Visual and Programmatic Identifiers required.
8. Click the Next button.
9. On the next page specify PSLMST2 as The view to be used for searching/filtering operations.
10. Specify SURNAME as the Key of the selected view to be used for search operations.
11. Click the Generate Code button.
The next page, Generated Code, displays the source code for your filter. You now need to create the component that will contain this code:
12. Specify iiiCOM04 as the name of your real filter and By Name 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 3 characters DEM to replace iii).
13. Click on the Create button to create the WAM.
After a brief delay a message is shown indicating the WAM has been created.
14. Switch to the Visual LANSA editor. Your filter is displayed in the Visual LANSA editor.
15. Examine the code:
This statement tells the Framework that new entries are about to be added to the instance list:
#avListManager.BeginListUpdate
This statement clears the instance list:
#avListManager.ClearList
This statement reads the records that match the surname entered by the user:
Select Fields(#XG_Ident) From_File(PSLMST2) With_key(#XG_Keys) Generic(*yes) Nbr_Keys(*Compute)
This statement sets up the visual Identifier(s)
#UF_VisID1 := #EMPNO
#UF_VisID2 := #SURNAME
#UF_VISID2 := #UF_VISID2.BlankConcat(#GIVENAME )
This statement adds the data to the instance 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).
This statement tells the Framework that you have finished adding entries to the instance list:
#avListManager.EndListUpdate
You may want to read WAM Filter and Command Handler Anatomy to see how WAMs are structured.
16. If you are using a partition with language NAT, you need to change the default value of the #UB_SEARCH field to SEARCH and change the Web_Map statement to:
Web_Map For(*both) Fields(#XG_Keys (#UB_SEARCH *Desc))
17. Select the Compile option in the Verify menu.
18. Ensure that the All webroutines option is selected for the Generate XSL option.
19. Ensure the compilation was successful.
20. Check in your changes to the server. First check in the layout weblet for your WAM::
a. Locate the layout weblet for your WAM under Weblets in the Repository. It is called iiiCOM04_layout (where iii correspond to your initials).
b. Right-click the weblet to bring up the associated pop-up menu and choose the Check in option.
c. Click OK.
Then locate the WAM to check it in:
a. Right-click the WAM to bring up the associated pop-up menu and choose the Check in option.
b. Ensure that the All webroutines option is selected for the Generate XSL option.
c. Click OK to check the changes in.
d. Wait until the compiles have finished.