2.10.7 Filling a List-Type Component

All lists are populated using a SELECT loop with an ADD_ENTRY statement:

SELECT fields(#EMPLIST) from_file(PSLMST)

ADD_ENTRY to_list(#EMPLIST)

ENDSELECT

In this example the list view is filled when the Fill List button is clicked:

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) CLIENTHEIGHT(295) CLIENTWIDTH(480) HEIGHT(333) LEFT(537) TOP(173) WIDTH(496)

DEFINE_COM CLASS(#PRIM_LTVW) NAME(#EMPLIST) COLUMNBUTTONHEIGHT(16) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(209) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(1) TOP(48) WIDTH(433)

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(25)

DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_4) DISPLAYPOSITION(4) PARENT(#EMPLIST) SOURCE(#SALARY) WIDTH(21) WIDTHTYPE(Remainder)

DEFINE_COM CLASS(#PRIM_PHBN) NAME(#PB_FILL) CAPTION('Fill List') DISPLAYPOSITION(2) LEFT(32) PARENT(#COM_OWNER) TABPOSITION(2) TOP(8)

EVTROUTINE handling(#PB_FILL.Click)

SELECT fields(#EMPLIST) from_file(PSLMST)

ADD_ENTRY to_list(#EMPLIST)

ENDSELECT

ENDROUTINE

END_COM