Step 3. Add Logic to Switch from Sections to the Employees Business Object
In this step you will add logic to the Sections’ Details command handler to display the details of a section's employees in the Details command handler of the Employees business object.
The switch to the Employees’ Details command handler is executed in the button click event.
1. Display the Source tab of the Section Details command handler.
2. Locate the Override Field(#UB_PUSHB1) statement and change it to:
Override Field(#UB_PUSHB1) Default('Details')
3. In the #avFrameworkManager.uWAMEvent_1 eventroutine (handling the Details button click event) add this code to clear the instance list in the Employee Details command handler and populate it with the selected section's employees:
Invoke Method(#avListManager.BeginListUpdate) ForBusineesObject(EMPLOYEES)
Invoke Method(#avListManager.ClearList)
Select Fields(#EMPNO #GIVENAME #SURNAME) From_File(PSLMST1) With_key(#DEPTMENT #SECTION) Generic(*yes) Nbr_Keys(*Compute)
Invoke #avListManager.AddtoList Visualid1(#EMPNO) Visualid2(#SURNAME) AColumn1(#givename)AKey1(#EMPNO)
EndSelect
Invoke Method(#avListManager.EndListUpdate)
In WAM command handlers you can name the instance list you want to use, in this case the instance list for business object EMPLOYEES. (In Windows you use the avAddSwitchInstances event to work with another business object's instance list.)
4. Then add a statement to switch to the Details command handler of the Employees business object:
#avframeworkmanager.avSwitch To(BUSINESSOBJECT) NAMED(EMPLOYEES) EXECUTE(DETAILS) Caller(#com_owner)
- The To parameter contains BUSINESSOBJECT to indicate the switch is to a business object (you can also switch to the Framework or an application).
- The NAMED parameter must contain your actual business object name.
- The EXECUTE parameter contains the name of the command to execute.
Your code will now look like this:
5. Compile the command handler and check it in.
6. Execute the Framework as a web application.
7. Test the switching: when you select a section and click on the Details button on the command handler, the Employees business object is displayed with the section's employees in the instance list. The details of the first employee in the list are shown.
8. Close the application.