In this step you will add an event routine to the Employees filter to listen for the EMPLOYEE_CHANGED event.
1. Locate and open the Employees filter iiiCOM07.
2. Display the Source tab.
3. Add an event routine to listen for an avEvent signal:
Evtroutine Handling(#Com_Owner.avEvent) WithId(#EventId) Options(*NOCLEARMESSAGES *NOCLEARERRORS) WithAinfo1(#Ainfo1)
The avEvent event is an event that is signaled by the Framework when the avSignalEvent method is called. The event routine receives the event being signaled along with any alphanumeric or numeric data that accompanies the event.
4. Next add a CASE command to test which event has been signaled in the event routine:
It is important to test to make sure that the EventID matches one of the events that this event routine handles as the event being signaled might not apply to the component in which you have placed this event routine.
5. Then place appropriate WHEN VALUE_IS commands to handle various event ids that apply to this component. In this case we only want to handle the EMPLOYEE_CHANGED event:
When (= EMPLOYEE_CHANGED)
Your code will now look like this:
6. Next add code to save the current key values from overwrites:
Inz_List #Save_Keys 1
7. Assign the value passed by the signaled event to the EMPNO field:
#xEmployeeIdentification := #Ainfo1
8. Start updating the instance list:
9. Fetch the details of the employee that has been updated:
Fetch Fields(#xEmployeeSurname) From_File(XEMPLOYEE) With_Key(#xEmployeeIdentification)
10. Update the entry in the instance list:
Invoke Method(#avListManager.AddtoList) Visualid1(#xEmployeeIdentification) Visualid2(#xEmployeeSurname) Akey1(#xEmployeeIdentification)
11. Complete the instance list update:
Your finished code will look like this:
12. Compile the filter.