From: Oliver Wong on
Let's say I have a COBOL program like this:

IDENTIFICATION DIVISION.
PROGRAM-ID. Test.
AUTHOR: Oliver Wong.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FileA ASSIGN "FileA.dat"
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD FileA.
01 RecordA.
88 EndOfFileA VALUE HIGH VALUES.
02 RecordID PIC X(7).
02 Contents PIC X(23)

PROCEDURE DIVISION.
BEGIN
OPEN INPUT FileA
* etc.

I'm assuming the fact that the "FileA" in the SELECT clause of the
FILE-CONTROL paragraph matches the "FileA" in the file description entry in
the FILE section is significant (as opposed to coincidental), and that these
two things are "linked" somehow.

Are either of these things optional? That is to say, would it be
meaningful to have "FileA" mentioned in the file description entry and not
in the SELECT clause, or vice versa? If so, what kind of "defaults" would
the compiler typically assume for such an ommision?

- Oliver


From: HeyBub on
Oliver Wong wrote:
> Let's say I have a COBOL program like this:
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. Test.
> AUTHOR: Oliver Wong.
>
> ENVIRONMENT DIVISION.
> INPUT-OUTPUT SECTION.
> FILE-CONTROL.
> SELECT FileA ASSIGN "FileA.dat"
> ORGANIZATION IS LINE SEQUENTIAL
> ACCESS MODE IS SEQUENTIAL.
>
> DATA DIVISION.
> FILE SECTION.
> FD FileA.
> 01 RecordA.
> 88 EndOfFileA VALUE HIGH VALUES.
> 02 RecordID PIC X(7).
> 02 Contents PIC X(23)
>
> PROCEDURE DIVISION.
> BEGIN
> OPEN INPUT FileA
> * etc.
>
> I'm assuming the fact that the "FileA" in the SELECT clause of the
> FILE-CONTROL paragraph matches the "FileA" in the file description
> entry in the FILE section is significant (as opposed to
> coincidental), and that these two things are "linked" somehow.

Correct.

>
> Are either of these things optional?

No.

> That is to say, would it be
> meaningful to have "FileA" mentioned in the file description entry
> and not in the SELECT clause, or vice versa? If so, what kind of
> "defaults" would the compiler typically assume for such an ommision?

Absent either, the compiler would default to an error message.



From: Chuck Stevens on
"HeyBub" <heybubNOSPAM(a)gmail.com> wrote in message
news:11ufj3eqc24o2a9(a)news.supernews.com...
> Oliver Wong wrote:
>> Let's say I have a COBOL program like this:
>>
>> IDENTIFICATION DIVISION.
>> PROGRAM-ID. Test.
>> AUTHOR: Oliver Wong.
>>
>> ENVIRONMENT DIVISION.
>> INPUT-OUTPUT SECTION.
>> FILE-CONTROL.
>> SELECT FileA ASSIGN "FileA.dat"
>> ORGANIZATION IS LINE SEQUENTIAL
>> ACCESS MODE IS SEQUENTIAL.
>>
>> DATA DIVISION.
>> FILE SECTION.
>> FD FileA.
>> 01 RecordA.
>> 88 EndOfFileA VALUE HIGH VALUES.
>> 02 RecordID PIC X(7).
>> 02 Contents PIC X(23)
>>
>> PROCEDURE DIVISION.
>> BEGIN
>> OPEN INPUT FileA
>> * etc.
>>
>> I'm assuming the fact that the "FileA" in the SELECT clause of the
>> FILE-CONTROL paragraph matches the "FileA" in the file description
>> entry in the FILE section is significant (as opposed to
>> coincidental), and that these two things are "linked" somehow.
>
> Correct.
>
>>
>> Are either of these things optional?
>
> No.
>
>> That is to say, would it be
>> meaningful to have "FileA" mentioned in the file description entry
>> and not in the SELECT clause, or vice versa? If so, what kind of
>> "defaults" would the compiler typically assume for such an ommision?
>
> Absent either, the compiler would default to an error message.

I'd go one step further. Given that "For each file-name specified in a
SELECT clause, there shall be a file description entry or a sort-merge
description entry in the file section of ... the program in which the SELECT
clause is specified" can be found in ISO/IEC 1989:2002, and given that every
standard for COBOL as far back as I can determine has had similar wording, I
would suggest that a compiler that did anything *but* complain loudly if
either SELECT or FD was missing for a given file-name would be violating a
rule that has been fundamental to COBOL for close to half a century, if not
longer.

Stated a different way, there are languages that do not require that there
be both a SELECT and an FD/SD, and that there be a one-to-one correspondence
between each SELECT and one, and only one, FD/SD.

Such languages are not readily-recognizable dialects of what reasonably
might be called "COBOL".

-Chuck Stevens


From: William M. Klein on
I believe (but won't swear to it) that I *have* seen an extension that allows
the Select/Assign (Environment Division) entry to be omitted for an SD (not an
FD). I *know* have seen implementations where the value in the ASSIGN clause of
the Select/Assign statement for an SD is "ignored" (i.e. has no relationship to
any "physical" sort-merge file).

Obviously, I agree with Chuck's statements about what the current, past, and
proposed STANDARDS require.

--
Bill Klein
wmklein <at> ix.netcom.com
"Chuck Stevens" <charles.stevens(a)unisys.com> wrote in message
news:ds8j68$ho$1(a)si05.rsvl.unisys.com...
> "HeyBub" <heybubNOSPAM(a)gmail.com> wrote in message
> news:11ufj3eqc24o2a9(a)news.supernews.com...
>> Oliver Wong wrote:
>>> Let's say I have a COBOL program like this:
>>>
>>> IDENTIFICATION DIVISION.
>>> PROGRAM-ID. Test.
>>> AUTHOR: Oliver Wong.
>>>
>>> ENVIRONMENT DIVISION.
>>> INPUT-OUTPUT SECTION.
>>> FILE-CONTROL.
>>> SELECT FileA ASSIGN "FileA.dat"
>>> ORGANIZATION IS LINE SEQUENTIAL
>>> ACCESS MODE IS SEQUENTIAL.
>>>
>>> DATA DIVISION.
>>> FILE SECTION.
>>> FD FileA.
>>> 01 RecordA.
>>> 88 EndOfFileA VALUE HIGH VALUES.
>>> 02 RecordID PIC X(7).
>>> 02 Contents PIC X(23)
>>>
>>> PROCEDURE DIVISION.
>>> BEGIN
>>> OPEN INPUT FileA
>>> * etc.
>>>
>>> I'm assuming the fact that the "FileA" in the SELECT clause of the
>>> FILE-CONTROL paragraph matches the "FileA" in the file description
>>> entry in the FILE section is significant (as opposed to
>>> coincidental), and that these two things are "linked" somehow.
>>
>> Correct.
>>
>>>
>>> Are either of these things optional?
>>
>> No.
>>
>>> That is to say, would it be
>>> meaningful to have "FileA" mentioned in the file description entry
>>> and not in the SELECT clause, or vice versa? If so, what kind of
>>> "defaults" would the compiler typically assume for such an ommision?
>>
>> Absent either, the compiler would default to an error message.
>
> I'd go one step further. Given that "For each file-name specified in a SELECT
> clause, there shall be a file description entry or a sort-merge description
> entry in the file section of ... the program in which the SELECT clause is
> specified" can be found in ISO/IEC 1989:2002, and given that every standard
> for COBOL as far back as I can determine has had similar wording, I would
> suggest that a compiler that did anything *but* complain loudly if either
> SELECT or FD was missing for a given file-name would be violating a rule that
> has been fundamental to COBOL for close to half a century, if not longer.
>
> Stated a different way, there are languages that do not require that there be
> both a SELECT and an FD/SD, and that there be a one-to-one correspondence
> between each SELECT and one, and only one, FD/SD.
>
> Such languages are not readily-recognizable dialects of what reasonably might
> be called "COBOL".
>
> -Chuck Stevens
>


From: James J. Gavan on
Oliver Wong wrote:
> Let's say I have a COBOL program like this:
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. Test.
> AUTHOR: Oliver Wong.
>
> ENVIRONMENT DIVISION.
> INPUT-OUTPUT SECTION.
> FILE-CONTROL.
> SELECT FileA ASSIGN "FileA.dat"
> ORGANIZATION IS LINE SEQUENTIAL
> ACCESS MODE IS SEQUENTIAL.
>
> DATA DIVISION.
> FILE SECTION.
> FD FileA.
> 01 RecordA.
> 88 EndOfFileA VALUE HIGH VALUES.
> 02 RecordID PIC X(7).
> 02 Contents PIC X(23)
>
> PROCEDURE DIVISION.
> BEGIN
> OPEN INPUT FileA
> * etc.
>
> I'm assuming the fact that the "FileA" in the SELECT clause of the
> FILE-CONTROL paragraph matches the "FileA" in the file description entry in
> the FILE section is significant (as opposed to coincidental), and that these
> two things are "linked" somehow.
>
> Are either of these things optional? That is to say, would it be
> meaningful to have "FileA" mentioned in the file description entry and not
> in the SELECT clause, or vice versa? If so, what kind of "defaults" would
> the compiler typically assume for such an ommision?
>
> - Oliver
>
You've already got your answer. Just to extend it a bit :-

(a) Mainframes - don't know :-) - Presumably they control location of
the storage device via JCL cards ???

(b) As you are primarily thinking PCs, depends upon compiler, but
usually the default directory *should* find your 'FileA.dat'. From day
one in COBOL I always had to contend with different data sets and common
filenames, so :-

Petro Canada Jumping Pound Creek Plant = PECAN44
Amoco Canada Waterton Plant = AMOCO23

SELECT Vessels-File
ASSIGN to ws-filename
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.

Working-Storage Section.

01 ws-Filename pic x(100).

So to the program I might pass lnk-Filename =

"c:\Corrosion-Testing\Data\AMOCO23Vessels.dat".

OK - so I've switched to SQL since the above - but I'm still looking for
different data sets, i.e. AMOCO23.mdb, PECAN44.mdb etc.

-----------------
One thing though, I noticed it looks like you have picked up your EOF
flag technique from U. of Limerick examples (??? :-) ).

It's OK I suppose, but not an approach I'm thrilled about. I prefer as a
separate field :-

01 FileFlag pic 9 value 0.
88 FileFinished value 1.
88 FileNotFinished value 0.

I suppose my observation is - why have a flag/condition in a record when
the flag applies to the file as a whole ? (What happens if he, (Mr.
Coughlin at U of L), has RecordA, RecordB and RecordC for the same file
?). No harm done in his approach - just a question of preference.

Jimmy