Reputation: 624
In COBOL i want to read a line sequential file. The first line occurs one time. The second and the thirth line can be repeated multiple (unknown) times. I really don't know how to do it.
I think the file description is something like this:
01 DBGEGEVENS PIC X(200).
01 PROJECT. (occurs unknown times)
03 PROJECTCODE PIC X(10).
03 CSVPAD PIC X(200).
Upvotes: 0
Views: 435
Reputation: 11
The code given indicates a VB file - record one is 200 bytes, while the other records are 210 bytes. There should be an indicator on the records that describes what they are and their purpose. Ultimately, you'd be best served by reading them into WORKING-STORAGE - and I'd ask whomever is passing you the file what indicators are available. If, however, you know for a fact that record one is the only 200 byte record in the file, that would be treated as a header read - read once into its definition - while the remaining 210 byte records (and I want to emphasize the definition provided describes 210 bytes) would be read into a WORKING-STORAGE area fitting their definition.
Upvotes: 0
Reputation: 10543
It depends on the file format
Do you want a VB file format ???? then
FILE-CONTROL.
SELECT In-File ASSIGN .....
DATA DIVISION.
FILE SECTION.
FD Comp-File.
01 DBGEGEVENS PIC X(200).
01 PROJECT.
03 PROJECTCODE PIC X(10).
03 CSVPAD PIC X(200).
with
Read In-File
Read In-File
Read In-File
You would use DBGEGEVENS for the first record and project for secon or subsquent records
For Fixed width file format
FILE-CONTROL.
SELECT Comp-File ASSIGN .....
DATA DIVISION.
FILE SECTION.
FD Comp-File.
01 input-record.
WORKING-STORAGE SECTION.
01 DBGEGEVENS PIC X(200).
01 PROJECT.
03 PROJECTCODE PIC X(10).
03 CSVPAD PIC X(200).
with
Read In-File into DBGEGEVENS
Read In-File into PROJECT.
Read In-File into PROJECT.
Either should work, depending on which file format you use
Upvotes: 2