Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Error: A static file cannot reference instance items occurs on file defined in an ASP.NET application

Error: A static file cannot reference instance items occurs on file defined in an ASP.NET application

Problem:

Customer is trying to define an ISAM file within a class program within an ASP.NET Web Application.
The compiler is flagging an error that points to the file status data-item that is defined in the select clause.

The error is as follows:

COBCH1268 : A static file cannot reference instance items …\Default.aspx.cbl

The program is shown below:

       class-id mywebsite_Default is partial   
              inherits type System.Web.UI.Page public.
       input-output section.
       file-control.
            select test-file assign to "C:\TEST.DAT"
                                   organization is indexed
                                    access is dynamic
                                    record key is test-refno
                                    file status is FS.
       data division.
       file section.
       fd test-file is external.
       01 test-record.
          03 test-refno            pic 9(8).
          03 test-name            pic x(20).
       working-storage section.
       77 FS                         pic x(2).   
       method-id Page_Load protected.
       local-storage section.
       procedure division using by value sender as object by value e as type EventArgs.

          goback.         

       end method.
       end class.

Resolution:

This error occurs because you have your file defined as EXTERNAL in your FD.

When you define a file as external then the compiler will automatically generate the file as being static so that it is accessible to all instances of the class.

This means that the file status data item defined for the file needs to also be defined as static.

You can do this as follows:

77 FS   PIC X(2) STATIC.

The alternative would be to remove the external clause from the file description and then the file would belong to the instance and not to the class and you would not have to define the file status as static.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-10-25 17:27
Updated by:
 
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.