RPG/400 Help

SETLL (Set Lower Limit)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| SETLL   | Search        | File name       |                |   NR ER EQ    |
|         | argument      |                 |                |               |
*---------*---------------*-----------------*----------------*---------------*

The SETLL operation positions a file at the next record that has a key or relative record number that is greater than or equal to the search argument (key or relative record number) specified in factor 1. The file must be a full procedural file (identified by an F in position 16 of the file description specifications).

Factor 1 is required. If the file is accessed by key, factor 1 can be a field name, a named constant, a figurative constant, or a literal that is used as the search argument in positioning the file. You can also specify a KLIST name in factor 1 for an externally described file that is positioned by key. If the file is accessed by relative record number, factor 1 must contain an integer literal, named constant, or numeric field with no decimal positions.

Factor 2 is required and can contain either a file name or a record format name. A record format name in factor 2 is allowed only with an externally described file.

The resulting indicators reflect the status of the operation. If an indicator is specified in positions 54 and 55, it is set on when the search argument is greater than the highest key or relative record number in the file. If an indicator is specified in positions 56 and 57, it is set on when an error occurs during running of the operation. If an indicator is specified in positions 58 and 59, it is set on when a record is present whose key or relative record number is equal to the search argument.

If factor 2 contains a file name for which the lower limit is to be set, the file is positioned at the first record with a key or relative record number equal to or greater than the search argument specified in factor 1.

If factor 2 contains a record format name for which the lower limit is to be set, the file is positioned at the first record of the specified type that has a key equal to or greater than the search argument specified in factor 1.

Figurative constants can be used to position the file. When used with a file with a composite key, figurative constants are treated as though each field of the key contained the figurative constant value. In most cases, *LOVAL positions the file so that the first read retrieves the record with the lowest key. In most cases, *HIVAL positions the file so that a READP retrieves the last record in the file, or a READ receives an end-of-file indication. However, note the following cases for using *LOVAL and *HIVAL with numeric keys:

Figure "SETGT Operation" shows the use of figurative constants with the SETGT operation. Figurative constants are used the same way with the SETLL operation.

Remember the following when using the SETLL operation:

Figure "SETLL Operation" illustrates the SETLL operation.

SETLL Example

In this example, the file ORDFIL contains order records. The key field is the order number (ORDER) field. There are multiple records for each order. ORDFIL looks like this in the calculation specifications:

Figure 53. SETLL Operation

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C*  All the 101 records in ORDFIL are to be printed.  The value 101
C*  has previously been placed in ORDER.  The SETLL operation
C*  positions the file at the first 101 record.  Because there are
C*  101 records, indicator 55 is set on and the GOTO operation is
C*  not processed.
C           ORDER     SETLLORDFIL                   55 101 PRESNT
C  N55                GOTO NOTFND
C           LOOP      TAG
C*  The READE operation reads the first 101 record.  Because
C*  indicator 56 is not on, the lines conditioned by N56 are
C*  processed.
C           ORDER     READEORDFIL                   56 END OF GRP
C*  The EXCPT operation is processed, and the program branches to the
C*  label specified in the GOTO operation.
C  N56                EXCPTDETAIL                     PRINT A LINE
C  N56                GOTO LOOP
C*  The READE operation reads the second, third, and fourth 101
C*  records in the same manner as the first 101 record was read.
C*  After the fourth 101 record is read, the READE operation is
C*  attempted.  Because the 102 record is not of the same group,
C*  indicator 56 is set on and the two following operations are
C*  bypassed.
C           NOTFND    TAG
                                ORDFIL
 
                        ORDER          Other Fields
                        *-------*---------------------*
                        |100    |    1st record of 100|
                        |-------*---------------------*
                        |100    |    2nd record of 100|
                        |-------*---------------------*
                        |100    |    3rd record of 100|
             (SETLL)---*|-------*---------------------*
                        |101    |    1st record of 101|
                        |-------*---------------------*
                        |101    |    2nd record of 101|
                        |-------*---------------------*
                        |101    |    3rd record of 101|
                        |-------*---------------------*
                        |101    |    4th record of 101|
                        |-------*---------------------*
                        |102    |    1st record of 102|
                        *-------*---------------------*


[ Top of Page | Previous Page | Next Page | Table of Contents ]