Identical Field Names

In COBOL you distinguish fields with identical names by qualification. For example, there are two fields named MONTH in the following code, but they can be qualified by their group items. Thus, you would reference MONTH OF LAST_VISIT and MONTH OF LAST_PAYMENT in your program:

10  last_visit.
    15  month               pic 99.
    15  day                 pic 99.
    15  year                pic 99.
10  last_payment.            
    15  month               pic 99.
    15  day                 pic 99.
    15  year                pic 99.

However, database systems consider duplicate names an error. Thus, if more than one field in a particular file has the same name, you receive a compile warning, and an .xfd file is not generated.

The solution in this situation is to add a NAME directive that associates an alternate name with one or both of the conflicting fields.