Highlighted
Absent Member.
Absent Member.
703 views

Data access in a Visual COBOL website

Jump to solution

How do I include data access in a website developed with Visual COBOL?

I created a new COBOL ASP.NET web site, which works, but as soon as I add SELECT and FD statements for a file access I get compile errors. Maybe the syntax is wrong, or I have to link in some module for data access?

Error 1: Undeclared identifier _MF_LINK_TEST-FILE                C:\Users\Test\AppData\Local\Temp\_cd5836_2\About.aspx.il 

Error 2: COBCH1268 : A static file cannot reference instance items …\Default.aspx.cbl 11 55 Temp1-ASP-NET-WEB = results from the " FILE STATUS IS FS" statement.

The full program is shown below:

       class-id Temp1_ASP_NET_WEB._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

                                      LOCK MODE IS MANUAL.

     *                               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(35).

       working-storage section.

       77 FS                         PIC XX.    

       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.

 

Maybe the data access should be in some other module, such as a web service, but I thought a quick simple start would be to do it all in one program. Any pointers to to how best to separate secure data access from the web page?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

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 XX 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 wouyld not have to define the file status as static.

Thanks.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

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 XX 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 wouyld not have to define the file status as static.

Thanks.

View solution in original post

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.