Page History
7.26.4 DEF_LIST Examples
Example 1: Write an RDML program to display the full details of an order.
...
To implement a "page at a time" technique for this particular program it could be modified like this:
The commands that have been inserted or changed are in red font.
| Panel |
|---|
| Code Block | theme | Confluence
| ******** Define work variables and browse list to be used
DEFINE FIELD(#L1COUNT) TYPE(*DEC) LENGTH(7) DECIMALS(0) DEFINE FIELD(#L1PAGE) TYPE(*DEC) LENGTH(7) DECIMALS(0) | DEFINE DEFINE FIELD(#L1TOP) TYPE(*DEC) LENGTH(7) DECIMALS(0) | /**Inserted commands **/ DEFINE DEFINE FIELD(#L1POS) TYPE(*CHAR) LENGTH(7) | DEF_LIST NAME(#L1) FIELDS((#SURNAME) (#GIVENAME) (#EMPNO) (#ADDRESS1)) COUNTER(#L1COUNT) PAGE_SIZE(#L1PAGE) TOP_ENTRY(#L1TOP) SCROLL_TXT(#L1POS) ******** Loop until teminated by EXIT or CANCEL BEGIN_LOOP ******** Get surname to search for REQUEST FIELDS(#SURNAME) ******** Build list of generically identical names CLR_LIST NAMED(#L1) CHANGE FIELD(#IO$KEY) TO(UP) | | /** Inserted commands **/ CHANGE CHANGE FIELD(#L1TOP) TO(1) | SELECT SELECT FIELDS(#L1) FROM_FILE(PSLMST2) WITH_KEY(#SURNAME) GENERIC(*YES) WHERE('#IO$KEY = UP') OPTIONS(*ENDWHERE) EXECUTE SUBROUTINE(DISPLAY) WITH_PARMS('''More...''') | /** Inserted command **/ ADD_ENTRY TO_LIST(#L1) ENDSELECT ******** If names found, display list to user IF COND('#L1COUNT *GT 0') EXECUTE SUBROUTINE(DISPLAY) WITH_PARMS('''Bottom''') | /** Inserted command **/ ******** else issue error indicating none found ELSE MESSAGE MSGTXT('No employees have a surname matching request') ENDIF ******** Loop back and request next name to search for END_LOOP ******** ******** Display names if the page is full or the list is complete ******** SUBROUTINE NAME(DISPLAY) PARMS(#L1POS) | DEFINE DEFINE FIELD(#L1REMN) TYPE(*DEC) LENGTH(5) DECIMALS(5) | /** Inserted commands **/ CHANGE CHANGE FIELD(#L1REMN) TO('#L1COUNT / #L1PAGE') | IF IF COND('(#L1COUNT *NE 0) *AND (#IO$KEY = UP) *AND ((#L1POS = ''Bottom'') *OR (#L1REMN *EQ 0.00000))') DOUNTIL COND('(#L1POS *NE ''Bottom'') *OR (#IO$KEY *NE UP)') | DISPLAY DISPLAY BROWSELIST(#L1) USER_KEYS((*ROLLUP)) | ENDUNTIL | CHANGE ENDUNTIL CHANGE FIELD(#L1TOP) TO('#L1TOP + #L1PAGE') | /** Inserted commands **/ ENDIF | ENDROUTINE | ENDIF ENDROUTINE |
The "page at a time" technique described here can be applied to just about any situation where a browse list is to be displayed and can considerably improve performance in most of them.
...