1

I have the following code for processing an indexed file but I am getting a runtime error, "indexed file system not available" when I run the program. I'm not sure on how to code the index file and the data file though. Am I doing the initialization right? What am doing wrong?

              IDENTIFICATION DIVISION.
   PROGRAM-ID. INDEXFILE.

   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.

       SELECT VENDOR-FILE ASSIGN TO DISK
       ORGANIZATION IS INDEXED
       ACCESS MODE IS RANDOM
       RECORD KEY IS VENDOR-NUMBER.


   DATA DIVISION.
   FILE SECTION.

   FD VENDOR-FILE
      LABEL RECORDS ARE STANDARD
      VALUE OF FILE-ID IS "input.txt"
      DATA RECORD IS VENDOR-RECORD.          

   01 VENDOR-RECORD.
       05 VENDOR-NUMBER   PIC 9(5).
       05 VENDOR-NAME     PIC X(30).

   WORKING-STORAGE SECTION.

   01 VNAME PIC X.

    PROCEDURE DIVISION.
    PARA1.
        OPEN INPUT VENDOR-FILE.
        DISPLAY 'ENTER VENDOR NO: '.
        ACCEPT VENDOR-NUMBER.
        DISPLAY VENDOR-NUMBER.
        READ VENDOR-FILE 
             INVALID KEY DISPLAY 'NO SUCH RECORD'.

        CLOSE  VENDOR-FILE.
        STOP RUN.        
user3211403
  • 169
  • 1
  • 8
  • 1
    Please tell us which compiler you are using and provide the complete text of the error message you are receiving. The error message should include the line number(s) to which it applies. – cschneid Feb 23 '14 at 18:40
  • I am using DSBOX as my compile. I have edited the code and the error shows Runtime error, indexed file system not available. – user3211403 Feb 23 '14 at 23:31
  • What is DSBOX? Do you have more details of it? You should use FILE STATUS for all files (assuming it is available to you) and test for a good status after every type of file access. When you get a non-zero for an OPEN, for instance, the actual FILE STATUS code may give you more information. Are you sure the file you are allocating is an indexed file? Is your .txt file an indexed file? If so, I'd give it a different file-type to save on confusion. – Bill Woodger Feb 23 '14 at 23:54
  • I use "DOSBOX" (sorry I mispelled) as my compiler. I do not have any details of it sorry. How do I know that my file is an indexed file? What should be the contents of an indexed file? – user3211403 Feb 24 '14 at 00:18
  • Why don't you get hold of an up-to-date COBOL compiler? GNU COBOL is open-source and free. Search at the SourceForge. – Bill Woodger Feb 24 '14 at 18:12
  • The main point is _very likely_ that the file was not available as noted be Bill Woodger below. Either do a one time `OPEN OUTPUT` or use `SELECT OPTIONAL` to auto-create the file on first use. – Simon Sobisch Oct 18 '21 at 06:16

2 Answers2

2

DOSBOX emulates an MS-DOS operating system as it would run on an older IBM PC Compatible computer. DOSBOX was developed primarily to support running vintage computer games on newer machines with upgraded operating systems. DOSBOX is not the compiler you are using - it is the operating system. As such we still don't know what "flavour" of COBOL you are trying to use here. All that aside, the message you are getting is: Indexed file system not available and this is hinting that you are missing some of the run time support libraries for the version of COBOL you are using.

Index file systems are not directly supported by the MS-DOS operating system (or any other PC type operating system for that matter). File access, other than simple sequential, requires some type of run-time support and I suspect that you are missing these components in your operating environment. The prospect of getting much further without locating the missing components is low.

NealB
  • 16,670
  • 2
  • 39
  • 60
1

All we really know is that you are running something which allows old software to run as it did some time in the past (DOSBOX).

We don't know which compiler you have. You should try to find a name by looking for any text output produced when you compile your program, or try "switches" like /? /h /help -? -h -help --help added to what you have when you compile a program.

Do you have any documentation for the compiler? Once you find out which compiler it is, you may be able to find some with your favourite search-engine.

To create your first indexed file, write a small program which opens an indexed file for OUTPUT. WRITE the records that you want, then CLOSE the file and stop the program.

That will usually be enough to get an indexed file going. You should then be able to use that file as INPUT or I-O in another program.

It is always a good idea to use FILE STATUS. If you are not sure how to use this, and still don't have a manual, look at the GNU COBOL documentation at SourceForge.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47