I have FD
FD CR1
LABEL RECORD IS STANDARD
DATA RECORDS ARE FIRSTSTR, SECONDSTR, THIRDSTR.
and 3 structures
01 FIRSTSTR.
05 FIRSTFIVE PIC X(05).
05 SECONDFIVE PIC X(05).
01 SECONDSTR.
05 FIRSTTWO PIC X(02).
05 SECONDONE PIC X(01).
05 THIRDFOUR PIC X(04).
01 THIRDSTR.
05 FIRSTTHREE PIC X(03).
05 SECONDTHREE PIC X(03).
05 THIRDTHREE PIC X(03).
Can I write all info in file like this:
WRITE FIRSTSTR, SECONDSTR, THIRDSTR.
And read from file in 3 structures like this:
READ CR1 INTO FIRSTSTR, SECONDSTR, THIRDSTR AT END
Yes, you can write more than one type of record to a file, but no, you can't do it the way you want to.
The record-definitions (structures) under the
FD
all occupy the same storage, meaning the all the 01-levels start at the same byte address. The individual records cannot simultaneously contain different data.This is called an "implicit REDEFINES".
The
READ ... INTO ...
is to read and at the same time copy the current record to the INTO item (singular) that you specify. The INTO item would usually be in theWORKING-STORAGE
(although they could also be inLOCAL-STORAGE
). It would be exotic to use theLINKAGE SECTION
and very, very, odd to use something in theFILE SECTION
as a target for aREAD ... INTO...
.You only
READ
one record at a time. Unless you file has a set, fixed-in-stone, sequence of different records, we'd usuallyREAD
the file, identify the record, and then process that particular type of record.You can only specify one receiving item for
READ ... INTO ...
and only one source item forWRITE ... FROM ...
.