870-FIND-PREV-<Index>

Name

870-FIND-PREV-<Index>

Description

Once you have defined a position in the file with a successful 850-FIND-NLT-<Index> , use the 870-FIND-PREV-<Index> routine to process database records sequentially in reverse <Index> order. This routine reads the record preceding the current record for this index.

Using the API in a Program

You must precede 870-FIND-PREV-<Index> with 850-FIND-NLT-<Index> .

860-FIND-NEXT-<Index> and 870-FIND-PREV-<Index> each require their own 850-FIND-NLT-<Index> calls to function properly; do not use together after a single 850-FIND-NLT-<Index> call.

Input Values

Field Description

<Index>

You must specify the index in the FIND statement.

Return Values

Field Description
<FileName>-SW The Find routines set the <FileName>-SW switch to indicate the outcome of the read.

<FileName>-NOTFOUND

<FileName>-FOUND

Each routine sets the logical value <FileName>-NOTFOUND or <FileName>-FOUND based on the outcome of the read process.

Programming Example

This example shows a way to move backward and forward in a file depending on the action being processed. In this example, the index key to be used is set, the action code is checked, and the routine gets either the next record or the previous record.

Notice that the 850-FIND-NLT-<Index> call is made separately for each type of action code.

***   The action codes "N" and "P" are used to indicate that
***   the next or previous record is desired, respectively.
      MOVE BL00F1-OEC-COMPANY     TO DB-COMPANY.

      IF (BL00F1-FC = "N")
          PERFORM 850-FIND-NLT-OECSET1
          IF  (OECOMPANY-FOUND)
          AND (OEC-COMPANY = DB-COMPANY)
              PERFORM 860-FIND-NEXT-OECSET1. 

      IF (BL00F1-FC = "P")
          PERFORM 850-FIND-NLT-OECSET1
          PERFORM 870-FIND-PREV-OECSET1.