EXAMPLE PROGRAM 1 (Sequential-within-Limits Processing)

EMPMST is processed sequentially within limits (L in position 28) by the record address file LIMITS. Each set of limits from the record-address file consists of the low and high employee numbers of the records in the EMPMST file to be processed. Because the employee number key field (ENUM) is five digits long, each set of limits consists of two 5-digits keys. (Note that ENUM is in packed format, therefore, it requires three positions instead of five.)

Figure 1. Sequential-within-Limits Processing of an Externally Described File
      *****************************************************************
      *  PROGRAM NAME:  ESWLIM1                                       *
      * RELATED FILES:  EMPMST   (Physical File)                      *
      *                 LIMITS   (Physical File)                      *
      *                 PRINT    (Printer File)                       *
      *   DESCRIPTION:  This program shows the processing of an       *
      *                 indexed file sequentially within limits.      *
      *                 This program prints out information for the   *
      *                 employees whose employee numbers are within   *
      *                 the limits given in the file LIMITS.          *
      *****************************************************************
     FLIMITS    IR   F    6     3  DISK    RAFDATA(EMPMST)
     FEMPMST    IP   F   28L    3PIDISK    KEYLOC(1)
     FPRINT     O    F   80        PRINTER
      *  Input specifications must be used to describe the records in the
      *  program-described file EMPMST.
     IEMPMST    NS  01
     I                             P    1    3 0ENUM
     I                                  4   23  ENAME
     I                                 24   24  ETYPE
     I                             P   25   26 0EDEPT

      *  As EMPMST is processed within each set of limits, the corres-
      *  ponding records are printed.  Processing of the EMPMST file is
      *  complete when the record-address file LIMITS reaches end of file.

     OPRINT     H    1P                     1
     O                                           12 'SERIAL #'
     O                                           22 'NAME'
     O                                           45 'DEPT'
     O                                           56 'TYPE'
     O          D    01                     1
     O                       ENUM                10
     O                       ENAME               35
     O                       EDEPT               45
     O                       ETYPE               55