Previous Topic: Sequential FilesNext Topic: Accessing IMS-DL/I Files with Reporting Facility


GET Command

A GET command presents the next logical record from the file. Once a return code of E is posted, no further reading is done. The return code from the GET command is Y if a record has been retrieved; otherwise, the return code is E.

Full Key Argument

A GET command with a full key argument retrieves the next logical record that conforms to the logical expression supplied. Since the logical expression is considered to be a key argument, retrieval is on the basis of reading through the file until a match is found. This is an example of a logical expression:

 FILE001: FILE TAPE RECORD=100  BLOCK=1000 KEY=A,B,C
	   DEFINE FILEKEY 1 - N
          DEFINE A       1 - 4 N
          DEFINE B       5 - 6 N
          DEFINE C       7 - 9 N
            .
            .
            .
          DEFINE FILEKEY 1 - 9
          GET FILE001 FILEKEY = 123456789

If the key in a record is found to be lower than the argument, further records are read. If a record is found to be higher than the argument, the key argument has not been satisfied.

If the file contains duplicate key values, you must clear the key field after each read with a return code of Y to ensure that the next occurrence of the duplicate key will be read.

On the first GET command for this file, a record is read. On all subsequent GETs, the previous record is examined before another record is read. Once an END-OF-FILE return code E is posted, no further reading is done.

The return code from the GET command is Y if a record has been retrieved. The return code is N if no record with this key has been found or the record has already been passed. The return code is E if END-OF-FILE has been reached.

Full Key and Non-Key Argument

A GET command with full key as well as additional non-key arguments in the logical expression develops the same logical flow as the previous example, with the addition of the non-key argument comparison when a match is found.

The record is retrieved only if both the key and the non-key arguments are satisfied. If the non-key arguments are not satisfied, the system reads and examines further records until either a match is found or the record is found to be higher than the key argument.

The return code from the GET command is Y (RECORD-FOUND) if a record has been retrieved. Otherwise, it is N (NO-RECORD-FOUND) or E (END-OF-FILE).

Non-Key Argument

A GET command with one or more non-key arguments in the logical expression reads each record from the file until the non-key argument is satisfied. On the first GET command for this file, a record is read; on all subsequent GETs, the previous record is examined before another record is read.

Once an uppercase return code E is posted, no further reading is done. The return code from the GET command is Y (RECORD-FOUND) if a record has been retrieved. Otherwise, it is E (END-OF-FILE).