Step 1. Create the Employee Images for Section Command Handler
VFW104 – Simple Keyed Collections
This component will dynamically create a keyed collection of image components (PRIM_IMGE) keyed by EMPNO for the employees in a department / section. Employee images are retrieved from the file iiiEmpImages.
The images are displayed on the command handler panel, managed by a
layout manager.The component will also create a keyed collection of flow item managers (PRIM_FWLI) keyed by EMPNO which position each image across the panel.
1. Create a new
:iiiVFW28
Employee Images for a Section
2. Give the RP an ancestor of VF_AC010.
3. Use the
ribbon to add a manager to iiiVFW28.4. Switch to the
tab and define a keyed collection, to collect PRIM_IMGE keyed by EMPNO.Define_Com Class(#PRIM_KCOL<#PRIM_IMGE #empno>) Name(#ImageCollection) Reference(*dynamic) Style(Collection)
The
means that the collection will exist only once you use to create it.5. Similarly define a keyed collection, to collect PRIM_FWLI keyed by EMPNO.
Define_Com Class(#PRIM_KCOL<#PRIM_FWLI #EMPNO>) Name(#ImageFlowCollection) Reference(*dynamic) Style(Collection)
6. Create a
method routine which redefines the ancestor's method, and invoke the ancestor method.Retrieve the current instance list entry using the List Manager component and retrieve Akey1 and Akey2.
The
method is called when an entry in the instant list is selected.Mthroutine Name(uExecute) Options(*redefine)
#com_ancestor.uExecute
#avlistmanager.getCurrentInstance Akey1(#deptment) Akey2(#section)
Endroutine
7. Add the following code to the
routine:* clear existing collections
Set_Ref Com(#ImageCollection) To(*null)
Set_Ref Com(#ImageFlowCollection) To(*null)
* Create collections dynamically
Set_Ref Com(#ImageCollection) To(*Create_as #PRIM_KCOL<#prim_IMGE #EMPNO>)
Set_Ref Com(#ImageFlowCollection) To(*Create_as #PRIM_KCOL<#prim_FWLI #EMPNO>)
This clears existing collections (from a previous execution).
The
and the ImageFlowCollection are then created dynamically using SET_REF.8. Add the following code to populate the keyed collections:
* Load images into panel
Select Fields(#empno) From_File(pslmst1) With_Key(#deptment #section)
Fetch Fields(#iiiempimg) From_File(iiiEmpImages) With_Key(#empno) Val_Error(*next)
If_Status Is(*okay)
If (*Not #iiiempimg.filename.isnull)
If_Ref Com(#ImageCollection<#EMPNO>) Is(*NULL)
Set_Ref Com(#ImageCollection<#EMPNO>) To(*CREATE_AS #PRIM_IMGE)
Set_Ref Com(#ImageFlowCollection<#EMPNO>) To(*CREATE_AS #PRIM_FWLI)
Set Com(#ImageCollection<#EMPNO>) Parent(#COM_OWNER) Filename(#iiiempimg.filename) Displayposition(99)
Set Com(#ImageFlowCollection<#EMPNO>) Parent(#FWLM_1) Manage(#ImageCollection<#EMPNO>)
Endif
Endif
Endif
Endselect
#com_owner.realize
9. Review this new logic:
Employee numbers are retrieved from the logical file PSLMST1 using the keys retrieved from the instance list.
An employee image is read from the file iiiEmpImages.
Field iiiEMPIMG is a BLOB field. Retrieving it from a file, restores the image file to a local folder. The path and file name are held in
.If this employee has an entry in iiiEmpImages, the
checks an entry for this employee doesn't exist in the .The
then creates an entry of PRIM_IMGE in , keyed on EMPNO.Another
creates an entry for PRIM_FWLI in .The
sets the Parent and Filename property for this collection entry.The Parent must be #COM_OWNER for the image to be shown on the RP's panel.
Similarly the next
, sets the entry Parent to FWLM_1, the flow across manager and the Manage property to this entry.The
makes the panel components visible once they have all been created.10. Compile your new command handler, iiiVFW28 –
.11. Start the VL Framework as Designer.
12. Open the
dialog for _Sections by double clicking on a section entry in the instance list.13. Select the
tab, select the action and plug in iiiVFW28.14.
the VL Framework.15. Use the
filter for employees and then use the command handler to ensure that images have been saved for a number of employees in this department / section (for example, department ADM and section 01).Remember to select the Clear List checkbox before rebuilding the list of employees.
16. Now select the Departments business object and expand ADM to display the first section (Internal Admin SRV) and select this section. Select the
command handler. Your command handler should look like the following: