Step 2 Write the Mini Filter Code

Visual LANSA Framework

Step 2. Write the Mini Filter Code

In this step you will write the code for your mini filter. You will need to manually code the filter because there is no Program Coding Assistant for mini filters.

1.   Display the Source tab of your filter.

2.   Add this statement after the component definitions:

Def_List Name(#Save_Keys)   Fields(#SURNAME) Type(*Working) Entrys(1)

  

The Save_Keys working list will be used to save the key values from overwrites done by the select loop.

 

3.   Next add a uInitialize method routine.

Mthroutine Name(uInitialize) Options(*Redefine)

 

#COM_OWNER.avMiniFilter := true

#COM_OWNER.avMiniFilterpanel <= #PANL_1

 

Endroutine

 

  • The uInitialize method routine is executed just once when the filter or command handler is being created.
  • The avMiniFilter property indicates that the filter should be a mini filter.
  • The avMinifilterpanel sets a reference to the panel within the filter. The characters “<=” between two components assign a reference. You can have multiple panels in your filter and use one of many mini filter panels based on a condition rather than always using the same one.

  

Your code will now look like this:

 

 

4.   Next add an event routine to handle the KeyPress event of the SURNAME field. This event will execute when the Enter key is pressed. 

EVTROUTINE HANDLING(#SURNAME.KeyPress) OPTIONS(*NOCLEARERRORS *NOCLEARMESSAGES) KeyCode(#keycode)

if ('#keycode.value = Enter')

 

endif

ENDROUTINE

 

 

5.   If the Enter key is pressed, save the current key values from overwrites done by the select loop:

 

Inz_List #Save_Keys 1

 

 

6.   Indicate that the instance list updating is about to start and then clear the instance list if the checkbox has been selected:

Invoke #avListManager.BeginListUpdate

 

If '#Clear_List.ButtonState = Checked'

Invoke #avListManager.ClearList

Endif

  

7.   Then select employees that match the search criteria and set up the visual identifiers, then add the entries to the instance list:

Select Fields(#EMPNO #SURNAME #GIVENAME #SALARY) From_File(PSLMST2) With_key(#SURNAME) Generic(*yes) Nbr_Keys(*Compute)

 

Use Builtin(BCONCAT) With_Args(#GIVENAME #SURNAME) To_Get(#FULLNAME)

Invoke #avListManager.AddtoList Visualid1(#EMPNO) Visualid2(#FULLNAME) NColumn1(#SALARY) AKey1(#EMPNO)

 

EndSelect

 

8. Lastly indicate that the instance list update is complete and restore the saved key values:

Invoke #avListManager.EndListUpdate

Get_Entry 1 #Save_Keys

 

Your finished event routine will look like this:

 

 

 

 

5.   Compile the filter.