Step 2 Create a Details Command Handler for Department Sections

Visual LANSA Framework

Step 2. Create a Details Command Handler for Department Sections

In this step you will create a Details command handler which will show the employees in the selected Section.

1.   Create a reusable part. Specify iiiCOM10 as the name of your command handler and Section Details as the description. (iii are your initials. If you are using an unlicensed or trial version of Visual LANSA,  you must always use the three characters DEM to replace iii).

2.   Click on the Details tab and specify VF_AC010 as the Ancestor of your component.

 

 

You will first add a layout manager to the command handler to control the placement of the controls on it:

3.   Start the Layout Helper from the View menu.

4.   Add an Attachment Manager to the reusable part iiiCOM10.

 

 

5.   Display the Common Controls tab on the Favorites tab.

6.   Drag and drop a panel to the right hand side (PANL_1). Change its Width to 94. This area will later contain the Details push button.

7.   Drag and drop another Panel over the centre of the remaining area (PANL_2). Use the Layout Helper to add the attachment manager (ATLM_1) to this panel using the dropdown on the right hand side.

8.   Drag and drop the grid control to the centre of PANL_2. Your grid will be attached to the sides of PANL_2. You have created a command handler which will automatically resize with the rest of the framework.

Your command handler will now look like this:

 

9.   Display the PSLMST file in the repository and expand it.

10.   Drag the fields EMPNO, SURNAME and GIVENAME to the grid.

11.   Make the WidthType of the GIVENAME column (GDCL_3) Remainder.

12.   Make the SelectionStyle of the grid WholeRow.

 

Now write the code to populate the Employee grid in the command handler:

13.   Display the Source tab.

14.   Add a uExecute method routine after the BEGIN_COM statement:

 

Mthroutine uExecute Options(*Redefine)

 

The uExecute method is invoked whenever the user executes the Framework command that is associated with the command handler.

 

15.   Use the GetCurrentInstance method to get the current Department and Section.

 

Invoke #avListManager.GetCurrentInstance AKey1(#DEPTMENT) AKey2(#SECTION)

 

 

16.   Clear the Employee grid:

 

Clr_list #Grid_1

 

 

17.    Lastly select the employees that belong to the section from the PSLMST1 logical view and add them to the grid:

Select fields(#EMPNO #SURNAME #GIVENAME) from_file(PSLMST1) with_Key(#DEPTMENT #SECTION)

 

Add_entry #GRID_1

 

Endselect

 

Your code will now look like this:

 

18.   Compile your command handler.

19.   Snap the command handler in the Details command of the Department Sections business object.

20.   Test your command handler.