Step 8 Create a Logical View and Test

Visual LANSA

Step 8. Create a Logical View and Test

REP011 - Repository Summary

In this step first create a logical view of the Employee Holidays file keyed by the Holiday Code:

1.  Create a logical view called iiiEmpHolByCode and key it by the iiiHolCode field.

2.  Compile the file. Use Verify / Compile to check you are using the required compile options.

     Create a form to test the logical view:

3.  Create form iiiEnqEmpHols with the description Holidays by Holiday Code:

a.  Display the Common Controls tab and drag a Push button and a List view to your form.

b.  Change the button Caption to Fetch.

c.  Select the 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 file iiiEmpHolidays and drag the iiiHolCode (Holiday Code) to the top of the form.

e.  Drag the Employee Number (iiiEmployNumber), Surname (iiiSurnamePJF) 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.

  • Clear the list view.
  • Select entries from the logical file in holiday code order.
  • Retrieve each entry with the key Holiday Code.
  • Add an entry to the list view.
  • End the Select loop.

     New code is shown in red.

Evtroutine Handling(#PHBN_1.Click)

Clr_list #LTVW_1Select Fields(*ALL) From_File(iiiEmpHolByCode) With_Key(#iiiHolCode)
Add_Entry To_List(#LTVW_1)

Endselect

Endroutine
 

     Replace the file and field name with your own holiday file 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 file based on the employee number:

k.  Close the form.