GET is the controlled sequential read verb in Easytrieve. It places the next record—or with PRIOR the previous record—of a named Library FILE into that file's record buffer so field definitions for the file become current. Automatic JOB INPUT already issues the equivalent of sequential reads for you; GET is how you read when automatic input is off (JOB INPUT NULL), when you need a second file in the same activity, or when PROGRAM logic drives I/O without a JOB auto-loop. You must test end-of-file or file presence after GET before trusting buffer contents. You cannot GET a file that is the activity's automatic input, and you cannot GET SQL files—use relational verbs instead. Optional PRIOR, HOLD/NOHOLD, and STATUS refine direction, update locking, and status checking. This page walks through syntax, EOF patterns, reverse direction rules with POINT, CICS differences, secondary-file designs, and mistakes that cause empty buffers or execution errors.
12345678910GET file-name [PRIOR] [HOLD | NOHOLD] [STATUS] * Forward read with status: GET PERSNL STATUS * Controlled loop with EOF test: GET MASTER IF EOF MASTER STOP END-IF
File-name must match a FILE in the Library section and must not be SQL. PRIOR, HOLD/NOHOLD, and STATUS are optional and independent: you can combine PRIOR with STATUS when the access method supports backward reads.
After a successful GET, the file's record buffer holds the retrieved record. Fields defined under that FILE (or macro) now reflect the new record. A failed or end-of-file condition means you must not treat those fields as valid business data. File presence tests (IF file-name) and IF EOF file-name are the standard guards Broadcom documents for GET-based logic.
| Pattern | How records arrive | GET allowed? |
|---|---|---|
| JOB INPUT MASTER | Easytrieve auto-reads MASTER each iteration | No GET on MASTER; GET other files yes |
| JOB INPUT NULL | No auto input; you drive I/O | Yes—GET any eligible non-SQL file |
| JOB INPUT PRIMARY + GET SECOND | Primary automatic; secondary manual | GET SECOND only |
To turn off automatic input entirely, code JOB INPUT NULL. Without STOP or TRANSFER somewhere in that activity, a NULL-input JOB can loop forever—pair GET loops with clear exit conditions.
GET PRIOR places the previous sequential record into the buffer. If direction reverses from forward GET to GET PRIOR, you receive the record immediately before the one currently in the buffer. If you reverse from PRIOR back to plain GET, you receive the record immediately after the current buffer contents. When PRIOR is used and file position is not yet established, Easytrieve places the last record of the file in the buffer. If the operating system access method does not support previous-record retrieval, execution fails—do not assume every sequential dataset allows PRIOR.
Restrictions with POINT: you cannot issue GET PRIOR after POINT, and you cannot issue GET after POINT PRIOR. Positioning and GET direction must stay consistent with Broadcom POINT rules.
Outside CICS, when FILE specifies UPDATE, Easytrieve automatically holds records so you can update them. NOHOLD overrides that automatic hold when you want to browse without locking. HOLD requests an explicit hold for update; it is invalid if UPDATE is not on the FILE statement. HOLD keeps position for a possible update—you are not forced to rewrite. Records release when the update completes or a commit point occurs; RELEASE can free a hold early.
In CICS, NOHOLD is the default. If you specify HOLD, you cannot browse with GET—an execution error occurs. For CICS updates, Broadcom directs you to READ rather than held GET browse patterns.
STATUS asks Easytrieve to set the file's FILE-STATUS field with the I/O return code instead of only failing hard. Test zero versus non-zero for most programs; detailed codes are in the system-defined fields appendix. FILE-STATUS is not defined unless you specify a file type parameter on FILE—another reason to code SEQUENTIAL or INDEXED explicitly when you need status. Without STATUS, a non-zero operating-system status usually produces a diagnostic message.
123456789FILE PERSNL INDEXED %PERSNL PROGRAM NAME MYPROG GET PERSNL STATUS IF PERSNL:FILE-STATUS NE 0 DISPLAY PERSNL:FILE-STATUS ELSE DISPLAY HEX PERSNL END-IF
12345678910FILE MASTER FB(80 800) * field definitions... JOB INPUT NULL NAME READ-MASTER GET MASTER IF EOF MASTER STOP END-IF * process MASTER fields here GOTO JOB
With GET PRIOR, EOF means you reached the beginning of the file, not the end—adjust messages and counters accordingly. Skipping the EOF test is the most common beginner GET bug: fields appear blank or stale from the prior successful read.
Choose JOB INPUT for the classic report loop over one master. Choose GET when logic must interleave two files, skip automatic priming, or live in PROGRAM. Choose READ when access is by key rather than pure sequential next.
123456789101112FILE PRIMARY FB(100 1000) * primary fields... FILE LOOKUP FB(40 400) * lookup fields... JOB INPUT PRIMARY NAME JOIN-LIKE GET LOOKUP IF EOF LOOKUP * handle missing secondary stream ELSE * compare keys / PRINT END-IF
Primary advances automatically each JOB iteration; LOOKUP advances only when you GET it. For true key matching at scale, prefer synchronized JOB INPUT with KEY clauses—but GET secondary remains common for simple enrichment and small reference files.
Imagine a stack of flashcards. GET takes the next card and puts it on the table so you can read it. GET PRIOR puts the previous card back on the table instead. If the automatic teacher (JOB INPUT) is already flipping the main stack for you, you are not allowed to flip that same stack yourself—you can only flip a second stack. When there are no cards left, you must notice (EOF) and stop asking for more, or you will stare at an empty table.
1. GET places the next sequential record into:
2. You cannot GET a file that is:
3. GET PRIOR when position is not established returns:
4. STATUS on GET causes:
5. After manual GET you should typically test: