Step 2 Enhance Employee Images for Section Command Handler

VLF Windows Application Development

Step 2. Enhance Employee Images for Section Command Handler

VFW122 – Launching a VLF Window

In this step you will change iiiVFW28 to handle the new event uOpenEmpWindow signalled by iiiVFW29.

At present the Employee Images for Section CH handles the uShowEmpDetails event by using avSwitch to open the Employee Details CH within the same Framework window.

The Employee Images for Section CH will handle the uShowWindow event by invoking the avShowWindow method to open the Employee Details command handler in a new Framework window.

In the next step you will change the Employee Details CH (iiiVFW06) to process the avShowWindow request.

1.  Open iiiVFW28 – Employee Images for Section in the editor

2.  Add an event routine for ImageCollection<>.uOpenEmpWindow

Evtroutine Handling(#ImageCollection<>.uOpenEmpWindow) uEmpNum(#I_EmpNum)

Endroutine

 

     This will execute when the pop-up menu option Open Employee Details Window is selected on an employee image.

3.  This routine will invoke the avShowWindow method for the window name III_EMP.

     The routine must first declare a temporary reference to the framework's User Interface to multiple Windows component, VF_SY154.

     The Framework avWindow property returns a reference for a requested window name. New code is highlighted in red.

Evtroutine Handling(#ImageCollection<>.uOpenEmpWindow) uEmpNum(#i_empnum)

* define a temporary class #VF_SY154 reference Define_Com Class(#vf_sy154) Name(#window) Reference(*dynamic)
* Ask the framework manager to locate a window by name and return a reference
#window <= #avFRAMEWORKMANAGER.avWindow<'III_EMP'>
Endroutine

 

4.  If this reference is not *null, invoke avShowWindow for the business object EMPLOYEES to execute DETAILS, in window name III_EMP.

Evtroutine Handling(#ImageCollection<>.uOpenEmpWindow) uEmpNum(#i_empnum)
* define a temporary class #VF_SY154 reference
Define_Com Class(#vf_sy154) Name(#window) Reference(*dynamic)
* Ask the framework manager to locate a window by name and return a reference
#Window <= #AvFrameworkManager.avWindow<'III_EMP'>
If (#Window *IsNot *Null)
Message Msgtxt('Window III_EMP is already open')
* Display employee details in III_EMP window
#empno := #i_empnum
#AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(BUSINESSOBJECT) Oftype(EMPLOYEES) Windowname(III_EMP) Execute(DETAILS) Openinfo1(#EMPNO)
Else
* Open a new window
#AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(BUSINESSOBJECT) Oftype(EMPLOYEES) Windowname(III_EMP) Execute(DETAILS)
Endif
Endroutine
 

5.  Review the above code:

  • A temporary reference to VF_SY154 is defined.
  • Check if window III_EMP exists
    and then:
    set EMPNO from passed value I_EMPNUM.
  • Invoke avShowWindow for business object EMPLOYEES, window III_EMP, command handler DETAILS, passing EMPNO as open information 1.
    Else
    use avShowWindow to open a new window.

6.  Compile iiiVFW28.