Updating All Items in a List

Visual LANSA

Updating All Items in a List

This example shows how you can work with all the items in a list using the SELECTLIST statement and then update the items using the UPD_ENTRY command. The list view contains employee names and their salaries.  Every time the "Give Raise" push button is clicked every employee in the list has their salary increased by 10%.

To see how the example works,  copy this code and paste it to a form component:

FUNCTION options(*DIRECT)

BEGIN_COM role(*EXTENDS #PRIM_FORM) HEIGHT(334) LEFT(245) TOP(136) WIDTH(623)
DEFINE_COM class(#PRIM_LTVW) name(#EMPLIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(285) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TOP(8) WIDTH(505)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_1) DISPLAYPOSITION(1) PARENT(#EMPLIST) SOURCE(#EMPNO) WIDTH(24)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_2) DISPLAYPOSITION(2) PARENT(#EMPLIST) SOURCE(#SURNAME) WIDTH(25)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_3) DISPLAYPOSITION(3) PARENT(#EMPLIST) SOURCE(#GIVENAME) WIDTH(33)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_4) DISPLAYPOSITION(4) PARENT(#EMPLIST) SOURCE(#SALARY) WIDTH(18)
DEFINE_COM class(#PRIM_PHBN) name(#PB_RAISE) CAPTION('Give Raise') DISPLAYPOSITION(2) LEFT(528) PARENT(#COM_OWNER) TABPOSITION(2) TOP(8)
EVTROUTINE handling(#com_owner.Initialize)
SELECT fields(#EMPLIST) from_file(PSLMST)
ADD_ENTRY to_list(#EMPLIST)
ENDSELECT
ENDROUTINE
EVTROUTINE handling(#PB_RAISE.Click)
SELECTLIST named(#EMPLIST)
CHANGE field(#SALARY) to('#SALARY * 1.10')
UPD_ENTRY in_list(#EMPLIST)
ENDSELECT
ENDROUTINE
END_COM

 

Ý 6.15.8 Working with Items in Lists