Resolving conflicts between reserved keywords and data item names

Micro Focus continues to enhance the COBOL language, for example, by expanding the list of reserved COBOL words and adding new keywords to it as part of new levels of the COBOL language. Each Micro Focus release corresponds to a particular level. You can use the MFLEVEL Compiler directive to enable Micro Focus-specific reserved words in your code and change the behavior of certain features to be compatible with a specific level of the language.

If you use Visual COBOL to compile applications created with an older Micro Focus product, and these applications use data names that are now reserved keywords in Visual COBOL, you receive a COBOL syntax error COBCH0666 ("Reserved word used as data name or unknown data description qualifier"). To work around this issue and continue using some of the reserved words as data names in your source code, you can either:

You can set both directives from the command line, in your source code, or in the Additional Directives field in the project's COBOL properties.

Setting directives from the command line

To use REMOVE from a Visual COBOL command prompt, type the following:

cobol myprogram.cbl remove(title) ;

The command above removes TITLE as a keyword from the language so you can use it as an identifier in a COBOL program.

To use the set of reserved words that was used for Net Express v5.1 WrapPack 5, use this command line:

cobol myprogram.cbl mflevel"15" ;

Setting directives in the source code

To set either one of the directives in your source code, type the following starting with $ in the indication area of your COBOL program:

$set remove "ReservedWord"

Or:

$set mflevel"nn"

Setting directives in the IDE

To set either one of the directives in the project's properties:

  1. In the IDE, click Project > Properties > Micro Focus > Project Settings > COBOL.
  2. In the Additional directives field, click , and in the Additional directives dialog box, type MFLEVEL"nn" or REMOVE "ReservedWord", then click OK.
  3. Click Apply and then OK.

MFLEVEL of some Micro Focus product releases and reserved words added for them

These are the keywords that have been added to the reserved words list for some of the more recent Micro Focus products:

  • Visual COBOL R4 (MFLEVEL"16"):
    • ATTRIBUTES
    • ENCODING
    • NAMESPACE
    • NAMESPACE-
    • VALIDATING
    • XML-
    • XML-SCHEMA
  • Net Express and Server Express versions 6.0 WrapPack 2 and 5.1 WrapPack 5 (MFLEVEL "15"):
    • DATA-POINTER
    • OBJECT-REFERENCE
  • Net Express 6.0 and Server Express 6.0 (MFLEVEL "14"):
    • BIT
    • BOOLEAN
    • GROUP-USAGE