This example fills a list view with employee details. Additionally the list view contains two columns titled Selected and Focused that contain YES when the employee list view entry is selected or in focus.
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(381) TOP(135) WIDTH(549)
DEFINE_COM class(#PRIM_LTVW) name(#EMPLIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(285) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TOP(28) WIDTH(529)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_1) CAPTION('Focus') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#EMPLIST) SOURCE(#STD_CODE) WIDTH(13)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_2) CAPTION('Selected') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#EMPLIST) SOURCE(#STD_CODEL) WIDTH(13)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_3) DISPLAYPOSITION(3) PARENT(#EMPLIST) SOURCE(#EMPNO) WIDTH(22)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_4) DISPLAYPOSITION(4) PARENT(#EMPLIST) SOURCE(#SURNAME) WIDTH(25)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_5) DISPLAYPOSITION(5) PARENT(#EMPLIST) SOURCE(#GIVENAME) WIDTH(33)
EVTROUTINE handling(#com_owner.Initialize)
SELECT fields(#EMPLIST) from_file(PSLMST)
CHANGE field(#STD_CODEL #STD_CODE) to(*BLANKS)
ADD_ENTRY to_list(#EMPLIST)
ENDSELECT
ENDROUTINE
EVTROUTINE handling(#EMPLIST.ItemGotFocus)
CHANGE field(#STD_CODE) to(YES)
UPD_ENTRY in_list(#EMPLIST)
ENDROUTINE
EVTROUTINE handling(#EMPLIST.ItemLostFocus)
CHANGE field(#STD_CODE) to(*BLANKS)
UPD_ENTRY in_list(#EMPLIST)
ENDROUTINE
EVTROUTINE handling(#EMPLIST.ItemGotSelection)
CHANGE field(#STD_CODEL) to(YES)
UPD_ENTRY
ENDROUTINE
EVTROUTINE handling(#EMPLIST.ItemLostSelection)
CHANGE field(#STD_CODEL) to(*BLANKS)
UPD_ENTRY in_list(#EMPLIST)
ENDROUTINE
END_COM