Joined: 15 Apr 2018 Posts: 4 Location: United States
I've declared a sequential file in file section as follows.
LABEL RECORDS ARE STANDARD
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
DATA RECORD TEST1-EXTRACT-RECORD.
05 TRANS-CTL-NUM PIC X(17).
05 RPT-LINE PIC X(26).
Though I didn't declare the variable TEST1-EXTRACT-RECORD anywhere in my program, it compiled successfully without any error Any reason behind this? Or is it a bug in COBOL compile?
Joined: 06 Jun 2008 Posts: 8515 Location: Dubuque, Iowa, USA
From the Enterprise COBOL Language Reference manual:
DATA RECORDS clause
The DATA RECORDS clause is syntax checked but serves only as documentation for the names of data records associated with the file.
The names of record description entries associated with the file.
The data-name need not have an associated 01 level number record description with the same name.
So the behavior you are seeing is normal and expected.
Joined: 31 Oct 2006 Posts: 990 Location: Richmond, Virginia
As a presumably new programmer, at least in COBOL, you're probably wondering why this is so.
COBOL was developed during the 1960's (by a committee actually!), and there have been hundreds of versions and associated compilers. The early ones might have performed stricter syntax checking, and of course had features that have not survived to the present.
Newer compilers (in any language) should try to maintain compatibility where possible so that installations can upgrade without modifying programs. There are COBOL programs that have been running in essentially their original form for decades.
I'm sure others experienced users can give interesting details here, but suffice it to say that, whatever else one may say or think about COBOL, it has been supremely successful in a constantly and rapidly changing technological world.