Step 2. Implement Time Employed calculation in Employee Details Command Handler
VFW070 – Create Time Employed Reusable Part
1. Open the
command handler in the editor (iiiVFW06).2. Add a Group Box component to the main panel (BODY_HEAD) and change its Time Employed.
to3. Add field STD_NUM to the group box. Set up the followings properties:
Property |
Value |
Caption |
Years |
LabelType |
Caption |
Name |
EMP_YEARS |
MarginLeft |
50 |
Reduce the field's width as necessary.
4. Add another STD_NUM field to the group box and repeat step 3 the above steps except:
a. Change EMP_MONTHS
tob. Change Months
to5. Add another STD_NUM field to the group box and repeat step 3, except:
a. Change EMP_DAYS
tob. Change Days
to6. Adjust the width of each field as required.
7. On the
ribbon, use button to arrange the fields.
8. Save your changes.
Your design should look like the following:
9. In the iiiVFW12. Change its to EMPLOY_CALC
view, drag and drop your reusable part onto component. This will create a for10.Change the Group_By XG_HEAD to include STARTDTER.
11. In the
method routine add the following code, following the FETCH command:If_Status Is(*okay)
Invoke Method(#EMPLOY_CALC.uEmployTime) I_Strdte(#STARTDTER) O_Year(#EMP_YEARS) O_Month(#EMP_MONTHS) O_Days(#EMP_DAYS)
Endif
12. In the SAVE_BUTTON
event routine, add the following logic, after the UPDATE command:If_Status Is(*OKAY)
Invoke Method(#EMPLOY_CALC.uEmployTime) I_Strdte(#STARTDTER) O_Year(#EMP_YEARS) O_Month(#EMP_MONTHS) O_Days(#EMP_DAYS)
Endif
13. Compile the
command handler.14. Execute the
and test the calculator.15. Change
for an employee to a recent date, for example, 2012 or 2013, to easily check the results are as expected. Note, this is a 6 digit date.