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 Details. Your form should look like the following:
and change its to
2. Expand the file definition on the Repository tab for file PSLMST. Select all the fields from EMPNO to PHONEBUS while holding down the
key and drag them to the top right side of the Details .
3. Reduce the field widths and if necessary widen the
and , 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
to control your form design in an intelligent way.6. Drop a SKILLS.
control onto the lower area of the Details group box and resize it. Change its to
7. In the false.
tab, find the file PSLSKL and expand its definition. Drag and drop field EMPNO into the SKILLS grid. Change its property to8. Drag fields SKILCODE, GRADE, COMMENT and DATEACQ into grid SKILLS. Adjust the
and so that your columns look like the following:
9. On the
Change its to 2.
Your grid should look like the following:
10. Add field DATEACQR from the file PSLSKL to the false.
. Make the columnThe field DATEACQR will be used to recognize entries which were loaded from the file PSLSKL.
11. Save your form definition.
12. Create an
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: