Step 4 Display Employee Details and Skills

Visual LANSA

Step 4. Display Employee Details and Skills

FRM085 - Update from a Grid

In this step you will extend the form design and add logic to retrieve employee details and skills when selected in the employees list view.

1.  Enlarge the form and drag and drop a Group Box onto the right hand side. Resize the Group Box and change its Caption to Details. Your form should look like the following:

2.  Expand the file definition on the Repository tab for file PSLMST. Select all the fields from EMPNO to PHONEBUS while holding down the Shift key and drag them to the top right side of the Details Group Box.

 

3.  Reduce the field widths and if necessary widen the Form and Group Box, and then select fields from DEPTMENT to TERMDATE and drag and drop them to the right of the first set of fields:

4.  Save your form.

5.  Make adjustments to field width and reduce the width of the Group Box and form if necessary.

     Do not spend time on this step. If you follow the Windows development training path, you will learn how to use Layout Managers to control your form design in an intelligent way.

6.  Drop a Grid control onto the lower area of the Details group box and resize it. Change its Name to SKILLS.

 

7.  In the Repository tab, find the file PSLSKL and expand its definition. Drag and drop field EMPNO into the SKILLS grid. Change its Visible property to false.

8.  Drag fields SKILCODE, GRADE, COMMENT and DATEACQ into grid SKILLS.  Adjust the Caption, CaptionAlign and CaptionType so that your Grid columns look like the following:

9.  On the Repository tab, expand the file SKLTAB and drop the field SKILDESC into the SKILLS grid.
Change its DisplayPosition to 2.
Your grid should look like the following:

10. Add field DATEACQR from the file PSLSKL to the Grid. Make the column Visible false.

     The field DATEACQR will be used to recognize entries which were loaded from the file PSLSKL.

11. Save your form definition.

12. Create an ItemGotSelection event for the list view EMPLOYS.

a.  Define a GROUP_BY for all employee fields on the form. Your code should look like the following:

Group_By Name(#empdata) Fields(#EMPNO #SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #PHONEBUS #DEPTMENT #SECTION #SALARY #STARTDTE #TERMDATE)

b.  This event should:

Fetch all fields for current employee number using GROUP_BY EMPDATA

Retrieve all skills (file PSLSKL) for this employee number

Fetch the skill description from file SKLTAB for this skill code

Add entry to grid SKILLS.     

Your code should look like the following:

Evtroutine Handling(#EMPLOYS.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)

Group_By Name(#empdata) Fields(#EMPNO #SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #PHONEBUS #DEPTMENT #SECTION #SALARY #STARTDTE #TERMDATE)
Fetch Fields(#EMPDATA) From_File(pslmst) With_Key(#EMPNO)

Clr_List Named(#SKILLS)

Select Fields(#SKILLS) From_File(pslskl) With_Key(#EMPNO)

Fetch Fields(#skildesc) From_File(SKLTAB) With_Key(#skilcode)

Add_Entry To_List(#SKILLS)

Endselect

Endroutine

 

13. Compile and test your form. Complete a search and select an employee in the list view. Your form should look like the following: