Step 8. Create an Index and Test

In this step, first create an index over the Employee Holidays table keyed by the Holiday Code:

1.  Create an index called iiiEmpHolByCode with a key of iiiHolCode.

2.  Compile the table. Display the Compile Options dialog to check you are using the correct compile options.

3.  This step should create a form to test the index. Create form iiiEnqEmpHols with the description Holidays by Holiday Code:

a.  Display the Common Controls tab, select the LANSA Controls and drag a Push button and a List view onto your form.

b.  Change the button Caption  to Fetch.

c.  Select the Details / Events tab and double click on the Click event to create an event routine for the push button.

d.  Display the iiiLIST tab, expand the table iiiEmpHolidays and drag the iiiHolCode (Holiday Code) to the top of the form.

e.  Drag the Employee Number (iiiEmployNumber), Surname (iiiSurnamePJC) and the Holiday Duration (iiiHolDuration) into the list view. You will probably need to widen the list view and the columns which will have been created for the fields.

f.  Display the Source tab and complete the push button Click event routine.

     Your code should look like the following:

Evtroutine Handling(#Button1.Click)

Clr_list #ListView1
Select Fields(*ALL) From_File(iiiEmpHolByCode) With_Key(#iiiHolCode)

Add_Entry To_List(#L
istView1)
Endselect

Endroutine

     Replace the table and field name with your own holiday table name and holiday code name.

g.  Compile and execute the form.

h.  Enter a holiday code and press the button to fetch the records with matching code:

i.  Replace the Holiday Code field on the form with the Employee Number field.

j.  Switch to the Source tab and change the Select statement to:

Select Fields(*ALL) From_file(iiiEmpHolidays) With_key(#iiiEmployNumber)

 

      The application will now retrieve records from the Holiday table based on the employee number:

k.  Close the form and close the form in the editor.