Step 1 Select Multiple Entries

Visual LANSA

Step 1. Select Multiple Entries

FRM075 - Using a Working List

1.  Create a New Form /Basic FormiiiUseWrkList – Using a Working List and make the form RDMLX enabled.

2.  From the Controls tab, drop a List View onto the form and resize it. Change the List View's Name property to EMPLOYS.

3.  Drop a Status Bar onto the form. It will attach to the bottom of the form. Your form should look like the following:

4.  On the Repository tab, locate the file PSLMST and expand its definition. Drag and drop the fields EMPNO, SURNAME, GIVENAME and SALARY into the list.

     Change the column headings as follows:

Field / column

Property

Value

EMPNO

Caption

Code

CaptionType

Caption

SURNAME

Caption

Surname

CaptionType

Caption

GIVENAME

Caption

Given Name

CaptionType

Caption

SALARY

Caption

Salary

 

CaptionType

Caption

 

     Resize the fields to display their content. Your List View should look like the following:

5.  Create an Initialize event for the list view EMPLOYS.

     Hint: You can create a click event by selecting EMPLOYS. On the Details tab, select the Events tab and double click on Initialize event. Alternatively, use the right mouse menu on the list view EMPLOYS and use the Events option to create an Initialize event routine.

6.  Add code to the EMPLOYS.Initialize event routine, to clear the list EMPLOYS and read all employee records, adding entries to EMPLOYS. Your code should look like the following:

Evtroutine Handling(#EMPLOYS.Initialize) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Clr_List Named(#EMPLOYS)
Select Fields(#EMPLOYS) From_File(pslmst)

Add_Entry To_List(#EMPLOYS)

Endselect

Endroutine

 

7.  Create a field in the Repository called iiiTOTSAL. Define it as Packed (15,2) field and give it an edit mask of J ( a format of 1,234,567.89-).

8.  Drop the field iiiTOTSAL onto the bottom right hand side of your form. Change its LabelPosition to Top.

9.  Select the EMPLOYS list view. On the Details tab, notice that the List View has a default SelectionStyle of Multiple.

10. Create an ItemGotSelection event routine for list view EMPLOYS.  Add code to add SALARY to iiiTOTSAL.

11. Create an ItemLostSelection event routine for list view EMPLOYS. Add code to subtract SALARY from iiiTOTSAL. Your code should look like the following:

Evtroutine Handling(#EMPLOYS.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#IIITOTSAL += #salary
Endroutine
Evtroutine Handling(#EMPLOYS.ItemLostSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#IIITOTSAL -= #salary
Endroutine
 

     In an RDML form you could have used:

Change Field(#IIITOTSAL) To('#iiitotsal + #salary')

 

12. Compile and test your form. Select multiple entries in the List View (hold down the Control key). Total Salary should show the correct total for selected employees.