FREAD numfile,string[,KEY=key,KEYLEN=key-length,
RECLEN=rec-length,UPDATE=NO]
This statement read a record from the file numfile; string will contain this record and its length must be greater or equal than record length
numfile is a numeric constant (from 1 to 20) used in FOPEN statement to handle the file.
key is the variable containing the read-key if the file is a KSDS or a RRDS
key-length is the length of this key
rec-length is the maximum record length: if a record is greater, the value in string is truncatedLet's summarize now how to use this instruction:
For a VSAM file (MVS/TSO/DOS/CICS):
- for a direct access (fetch only one record) specify only KEY= (without KEYLEN=); KEY is a string variable for a KSDS, an integer meaning slot number for a RRDS and an integer meaning a record-RBA for a ESDS (if you know the correct RBA)
- for a start browse (fetch for a partial key or full key) specify both KEY= and KEYLEN= and then fetch next records using a sequential read without KEY; you can use FSTARTBR statement to do the same thing, but STARTBR don't actually read any record
- for a sequential access don't use any KEY parameter
- use UPDATE=YES if the read record should be updated or deleted in the next
For a sequential (SAM) file (MVS/TSO/DOS):
- for a sequential access (the only allowed access method) don't use any KEY parameter
For a CMS file (CMS):
- for a sequential access don't use any KEY parameter and the read is from the first record
- for a direct access (fetch only one record) specify KEY= ; KEY is a integer variable containing the record number; use FSTARTBR statement to do a Start Browse access on a CMS file
RECLEN= is an optional parameter that simply overrides the length of string.
The only Return code filled in every environment are $EOF (End Of File, that can be 'F' false or 'T' true) and $RCFILE; $RCVSAM is filled only managing VSAM files.
Parameter Name Mode Type coding Remark 1 numfile Input numeric constant from 1 to 20 2 string Output String C or X Read record KEY= Input String C or X If file is a KSDS KEY= Input Integer F If file is a RRDS or a CMS file KEYLEN= Input Integer F or H for a partial key RECLEN= Input Integer F or H or const. overrides the length of string UPDATE=NO/YES fixed string YES only for a following FDELETE