Understanding the Generated Code (Paged Controls)

The code used to load data into a paged control differs significantly from that used to load data into an unpaged control. In the latter case, all data from the specified source is loaded into the control (and into memory) when the control is displayed on the screen. With a paged control, however, only the data visible in the control (that is, a single page of data) is loaded into memory. This can result in a dramatic performance improvement when the data source contains large numbers of records.

Note that the method used to load data into a paged grid is substantially different from the method used to load data into a paged list box, because of fundamental differences in the control type.

Generated Event Paragraph Code Sample: Paged Grid

* Autoload paged control code generated by Drag-And-Drop
 Screen1-Gd-1-Ev-Msg-Paged-Next.
     PERFORM event-data-2 TIMES
        READ clients NEXT RECORD
           AT END
              MOVE event-action-fail TO event-action
              EXIT PARAGRAPH
        END-READ
     END-PERFORM.
     PERFORM ACU-Screen1-Gd-1-Autoload-Add.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Gd-1-Ev-Msg-Paged-Prev.
     PERFORM event-data-2 TIMES
        READ clients PREVIOUS RECORD
           AT END
              MOVE event-action-fail TO event-action
              EXIT PARAGRAPH
        END-READ
     END-PERFORM.
     PERFORM ACU-Screen1-Gd-1-Autoload-Load.
     MODIFY Screen1-Gd-1, INSERTION-INDEX=2,
     RECORD-TO-ADD = Screen1-Gd-1-Autoload.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Gd-1-Ev-Msg-Paged-First.
     MOVE LOW-VALUES TO cl-client-id
     START clients, KEY >= cl-client-id
        INVALID KEY
           MOVE event-action-fail TO event-action
     END-START.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Gd-1-Ev-Msg-Paged-Last.
     MOVE HIGH-VALUES TO cl-client-id
     START clients, KEY <= cl-client-id
        INVALID KEY
           MOVE event-action-fail TO event-action
    END-START.

Generated Event Paragraph Code Sample: Paged List-Box

* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-Next.
     PERFORM Screen1-Lb-1-get-next-item .
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-Prev.
     PERFORM Screen1-Lb-1-get-prev-item .
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-Nextpage.
     MODIFY Screen1-Lb-1, MASS-UPDATE = 1
     PERFORM Screen1-Lb-1-Get-Next-Item
             Screen1-Lb-1-page-size times
     MODIFY Screen1-Lb-1, MASS-UPDATE = 0.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-Prevpage.
     MODIFY Screen1-Lb-1, MASS-UPDATE = 1
     PERFORM Screen1-Lb-1-Get-Prev-Item
             Screen1-Lb-1-page-size times
     MODIFY Screen1-Lb-1, MASS-UPDATE = 0.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-First.
     MOVE LOW-VALUES TO cl-client-id
     START clients, KEY NOT < cl-client-id
     END-START.
     SET Screen1-Lb-1-READING-FORWARDS TO TRUE
     MODIFY Screen1-Lb-1, MASS-UPDATE = 1
                          RESET-LIST = 1.
     PERFORM Screen1-Lb-1-get-next-item
             Screen1-Lb-1-page-size times
     MODIFY Screen1-Lb-1, MASS-UPDATE = 0.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-Ev-Ntf-Pl-Last.
     MOVE HIGH-VALUES TO cl-client-id
     START clients, KEY NOT > cl-client-id
     END-START.
     SET Screen1-Lb-1-READING-BACKWARDS TO TRUE
     MODIFY Screen1-Lb-1, MASS-UPDATE = 1
                          RESET-LIST = 1.
     PERFORM Screen1-Lb-1-get-prev-item
             Screen1-Lb-1-page-size times
     MODIFY Screen1-Lb-1, MASS-UPDATE = 0.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-get-next-item.
     EVALUATE TRUE
         WHEN Screen1-Lb-1-at-start
             MOVE low-value to cl-client-id
             START clients, key not < cl-client-id
             END-START
             ADD 1 to Screen1-Lb-1-page-size
                 GIVING Screen1-Lb-1-number-reads-needed
         WHEN Screen1-Lb-1-at-end
              EXIT paragraph
         WHEN Screen1-Lb-1-reading-backwards
              MOVE Screen1-Lb-1-page-size to
                   Screen1-Lb-1-number-reads-needed
         WHEN Screen1-Lb-1-reading-forwards
              MOVE 1 to Screen1-Lb-1-number-reads-needed
     END-EVALUATE.
     PERFORM Screen1-Lb-1-number-reads-needed times
        READ clients next record
             AT END
                SET Screen1-Lb-1-at-end TO TRUE
                EXIT PARAGRAPH
        END-READ
     END-PERFORM.
     INITIALIZE Screen1-Lb-1-Autoload
     PERFORM Acu-Screen1-Lb-1-Autoload-Load
     MODIFY Screen1-Lb-1, item-to-add = Screen1-Lb-1-Autoload
     SET Screen1-Lb-1-reading-forwards TO TRUE.
* Autoload paged control code generated by Drag-And-Drop
 Screen1-Lb-1-get-prev-item.
     EVALUATE TRUE
        WHEN Screen1-Lb-1-at-end
           MOVE high-value to cl-client-id
           START clients, KEY NOT > cl-client-id
           END-START
           ADD 1 TO Screen1-Lb-1-page-size
                 GIVING Screen1-Lb-1-number-reads-needed
        WHEN Screen1-Lb-1-at-start
           EXIT paragraph
        WHEN Screen1-Lb-1-reading-forwards
           MOVE Screen1-Lb-1-page-size TO
                Screen1-Lb-1-number-reads-needed
        WHEN Screen1-Lb-1-reading-backwards
           MOVE 1 TO Screen1-Lb-1-number-reads-needed
     END-EVALUATE.
     PERFORM Screen1-Lb-1-number-reads-needed times
        READ clients previous record
           AT END
              SET Screen1-Lb-1-at-start TO TRUE
              EXIT PARAGRAPH
        END-READ
     END-PERFORM.
     INITIALIZE Screen1-Lb-1-Autoload
     PERFORM Acu-Screen1-Lb-1-Autoload-Load
     MODIFY Screen1-Lb-1, insertion-index = 1
     ITEM-TO-ADD = Screen1-Lb-1-Autoload
     SET Screen1-Lb-1-reading-backwards TO TRUE.