Step 1 Create the Employee Images for Section Command Handler

VLF Windows Application Development

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 Flow Across 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 Reusable Part / Panel:

     Name: iiiVFW28

     Description: Employee Images for a Section

2.  Give the RP an ancestor of VF_AC010.

3.  Use the Design ribbon to add a Flow Across manager to iiiVFW28.

4.  Switch to the Source 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 Reference(*dynamic) means that the collection will exist only once you use SET_REF 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 uExecute method routine which redefines the ancestor's method, and invoke the ancestor uExecute method.

     Retrieve the current instance list entry using the List Manager component and retrieve Akey1 and Akey2.

     The uExecute 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 uExecute 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 ImageCollection 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 iiiEMPIMG.filename.

     If this employee has an entry in iiiEmpImages, the IF_REF checks an entry for this employee doesn't exist in the ImageCollection.

     The SET_REF then creates an entry of PRIM_IMGE in ImageCollection, keyed on EMPNO.  

     Another SET_REF creates an entry for PRIM_FWLI in ImageFlowCollection.

     The SET Com(ImageCollection ) . . . 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 SET, sets the ImageFlowCollection entry Parent to FWLM_1, the flow across manager and the Manage property to this ImageCollection entry.

     The #COM_OWNER.Realize makes the panel components visible once they have all been  created.

10. Compile your new command handler, iiiVFW28 – Employee Images for a Section.

11. Start the VL Framework as Designer.

12. Open the Properties dialog for _Sections by double clicking on a section entry in the instance list.

13. Select the Commands Enabled tab, select the Images action and plug in iiiVFW28.

14. Save and Restart the VL Framework.

15. Use the By Location filter for employees and then use the Images 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 Images command handler. Your Images command handler should look like the following: