Highlighted
Super Contributor.
Super Contributor.
878 views

Visual COBOL compiler needs to flag "COMP" as an invalid data name

I'm analyzing a survey where I let my client provide names for all her variables (e.g., TAILOR, NETWORK, LIFE, DENTAL).  My program automatically made a file description in a copy book, using her variable names as COBOL data names.

The Visual COBOL compiler correctly barfed when it encountered two of her names -- SEPARATE and EXIT -- saying that these could not be used as variable names because they were reserved COBOL words.   I changed those to SEPAR and EXINT, and everything seemed to work out all right.

Except that it WASN'T all right.  After a certain point into the record, the raw data stopped matching the variable names.  Each raw data item was assigned not to the correct variable name, but to the next variable name to the right.  The Visual COBOL debugger was no help.  I tried everything I could think of, to no avail, for more than two days.  Finally, I found the problem when I put in code that displayed the variable name and the variable value for every one of the 550 variables, with code like this:

DISPLAY 'OTADMIN1 ' OTADMIN1 UPON CONSOLE.
DISPLAY 'OTADMIN2 ' OTADMIN2 UPON CONSOLE.
DISPLAY 'OTADMIN3 ' OTADMIN3 UPON CONSOLE.
DISPLAY 'COMP' COMP UPON CONSOLE.
DISPLAY 'COMPMAX ' COMPMAX  UPON CONSOLE.
DISPLAY 'COMPUN ' COMPUN UPON CONSOLE.
DISPLAY 'COMPPAY ' COMPPAY UPON CONSOLE.
DISPLAY 'BENFIN1 ' BENFIN1 UPON CONSOLE.

This time, the compiler barfed on the statement "DISPLAY 'COMP     ' COMP     UPON CONSOLE." saying that "COMP" was a reserved word.  Finally!

So I changed 'COMP' to 'COMPTIME', and this time everything really did work.

So, the problem is that, while the compiler correctly flags "COMP" as a reserved word when it is used in a statement, it doesn't flag COMP as an invalid when it is used in a file description or working storage.   It just doesn't count as a variable -- throwing every subsequent variable off by one click.

This is a rare problem, but a fix to the compiler would be most welcome.

 

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

What does the data declaration for 'comp' look like in your copy book?
Note that a line like:
03 COMP pic 99.
...is actually legal COBOL, defining a FILLER data item with two numeric digits of type COMP (i.e. binary format). The word FILLER can be omitted since the advent of ANS85 COBOL.
This means that the compiler is unable to give an error for a line like this.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

What does the data declaration for 'comp' look like in your copy book?
Note that a line like:
03 COMP pic 99.
...is actually legal COBOL, defining a FILLER data item with two numeric digits of type COMP (i.e. binary format). The word FILLER can be omitted since the advent of ANS85 COBOL.
This means that the compiler is unable to give an error for a line like this.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

What does the data declaration for 'comp' look like in your copy book?
Note that a line like:
03 COMP pic 99.
...is actually legal COBOL, defining a FILLER data item with two numeric digits of type COMP (i.e. binary format). The word FILLER can be omitted since the advent of ANS85 COBOL.
This means that the compiler is unable to give an error for a line like this.
Highlighted
Absent Member.
Absent Member.

COMP is a reserved word in COBOL that means a binary format in a numeric variable like this sample:

03. SAMPLE PIC 9(18) COMP
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Thank you, Robert. That explains it.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.