Read a record from a file.
READ reads a record from a file on a local or a remote system.
For both UPDATE and non-UPDATE commands, you must identify the record to be retrieved by the record identification field specified in the RIDFLD option. Immediately upon completion of a READ UPDATE command, the RIDFLD data area is available for reuse by the application program. Data table considerations
When the READ command reads a CICS-maintained data table, a READ request with UPDATE or RBA is always satisfied by a call to VSAM. A full key read that is neither a generic read nor a READ UPDATE, is satisfied by a reference to the data table if possible. If the record is not found in the table, the source data set is accessed, unless the table is known to be complete, that is, all records in the source are also present in the table (which is the case if loading is finished and none has been rejected by a user exit).
If you carry out a generic read (using the GENERIC option) on a CICS-maintained data table, and CICS returns a NOTFND condition because the record is not found in the table, CICS clears the INTO() and RIDFLD() areas to ensure that an incorrect record is not returned. This behavior optimizes performance, but it differs from the behavior for a generic read of a VSAM file, when the INTO() and RIDFLD() areas are left unchanged in the event of a NOTFND condition. When you convert a VSAM file to a CICS-maintained data table, ensure that any applications that carry out generic reads of the data take appropriate action if a NOTFND condition is returned and the INTO() and RIDFLD() areas are cleared.
When the READ command reads a user-maintained data table, only the data table is accessed once loading is complete; the VSAM file is not changed in any way.
When the READ command reads a coupling-facility data table, only the data table is accessed, even if the table is initially loaded from a VSAM source data set.
If a file that refers to a user-maintained or coupling facility data table is defined with RLSACCESS(YES), the RLS-specific API options CONSISTENT, NOSUSPEND, and REPEATABLE are not supported.
The following example shows you how to read a record from a file named MASTER into a specified data area:
EXEC CICS READ INTO(RECORD) FILE('MASTER') RIDFLD(ACCTNO)
The following example shows you how to read a record for update from a VSAM file using a generic key and specifying a greater-or-equal key search.
EXEC CICS READ INTO(RECORD) LENGTH(RECLEN) FILE('MASTVSAM') RIDFLD(ACCTNO) KEYLENGTH(4) GENERIC GTEQ UPDATE
Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!