Updating the Selected Item in a List

Visual LANSA

Updating the Selected Item in a List

To update the selected item in a list use the UPD_ENTRY command.

In this example an employee must be selected to enable the "Give Raise" push button. The salary increase is only applied to the selected employee.  

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(346) Left(245) Top(136) Width(623)
Define_Com Class(#PRIM_LTVW) Name(#EMPLIST) Displayposition(1) Fullrowselect(True) Height(285) Left(8) Parent(#COM_OWNER) Selectionstyle(Single) Tabposition(1) Top(28) 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) Enabled(False) Left(528) Parent(#COM_OWNER) Tabposition(2) Top(272)
Evtroutine Handling(#com_owner.Initialize)
Select Fields(#EMPLIST) From_File(PSLMST)
Add_Entry To_List(#EMPLIST)
Endselect
Endroutine
Evtroutine Handling(#PB_RAISE.Click)
Change Field(#SALARY) To('#SALARY * 1.10')
Upd_Entry In_List(#EMPLIST)
Endroutine
Evtroutine Handling(#EMPLIST.ItemGotSelection)
Set Com(#PB_RAISE) Enabled(TRUE)
Endroutine

End_Com

 

Ý 6.15.8 Working with Items in Lists