I'm using a copybook that needs records added to it..
Is it possible to move records to the copybook record and then write out the copybook in COBOL? If so, any references on how to do this?
I have this code (based on the answer to this question), which is working correctly, however I was told I don't need TRNREC94-OUT, that I can just write the TRNREC94 copybook. When I tried replacing B700-MOVE-RECORDS with "WRITE REPORT-RECORD FROM TRNREC94." I get an error saying that TRNREC94 was not defined as a data-name and was discarded. Not sure where to go from here..
WORKING-STORAGE SECTION.
COPY TRNREC94.
01 TRNREC94-OUT.
05 REC-94-TYPE-OUT PIC X(2).
05 REC-94-POLICY-NUMBER-OUT PIC X(8).
05 FILLER PIC X(5).
05 REC-94-PARISH-CODE-OUT PIC X(3).
05 FILLER PIC X(1).
05 REC-94-TERRITORY-CODE-OUT PIC X(1).
05 FILLER PIC X(60).
...
...
B700-MOVE-RECORDS.
MOVE REC-94-TYPE TO REC-94-TYPE-OUT
MOVE REC-94-POLICY-NUMBER TO REC-94-POLICY-NUMBER-OUT
MOVE REC-94-PARISH-CODE TO REC-94-PARISH-CODE-OUT
MOVE REC-94-TERRITORY-CODE TO REC-94-TERRITORY-CODE-OUT
WRITE REPORT-RECORD FROM TRNREC94-OUT.
If the output record is already settup in working storage (in the same format required for the output file), you can do
write Output-Record from source-record
But the more likely case is you will have to move fields one by one to the output record:
Move field-1 to output-field-1
Move field-2 to output-field-2
......
Move field-n to output-field-n
Write Output-Record
There is a description of the write statement format here