Created On:  11 January 2013

Problem:

Customer is converting from RM COBOL to Visual COBOL and would like an example of how to configure the file handler to use the RM file handler so that he can access existing ISAM files.  Customer is using Visual COBOL 2.1.

Resolution:

Customer is using Visual COBOL 2.1 which has some new features for easier configuration of the target file handler than previous releases of Visual COBOL.
There is a simple demo attached to this article.

Download and unzip this to your C:\drive retaining the folder structure in the zip file as some of the file assignments are dependant upon this structure.

*----------------------------------------------------------------*
*                          ISAMDemoNativeRM 
*
* This example program demonstrates how to setup indexed file
* handling in a native Visual COBOL handling so that the RM/ACU
* file handlers will be accessed instead of the default Visual
* COBOL file handler.
*
* The following new IDXFORMAT filetypes have been introduced
* in Visual COBOL 2.1:
* IDXFORMAT"17": ACU Vision file handler
* IDXFORMAT"21": RM file handler
*
* In addition a new file handler configuration option INTEROP has
* been added allowing you to specify the options ACU or RM to in-
* dicate which file handler should be used for all files.
* Example:
* [XFH-DEFAULT]
* [FOLDER:C:\\files\\acufiles]
* INTEROP=ACU
* [FOLDER:C:\\files\\rmfiles]
* INTEROP=RM
*
* The IDXFORMAT can be set either in the file handler configura-
* tion file or as a compiler directive either set directly in
* the source code above the file to which it applies or at the
* top of the source where it applies to all indexed files.
*
* This demo project sets IDXFORMAT"21" using a extfh.cfg file.
* Note that the file assign points to a full path in the DATA
* subdirectory of the project folder.
* In the program you will see a comment where you could also set
* IDXFORMAT"21" as a compiler directive instead of using an
* EXTFH.CFG file.
*
* The current EXTFH.CFG file looks like:
* [XFH-DEFAULT]
* BASENAME=ON
* [testfile.dat]
* IDXFORMAT=21
*
* The BASENAME=ON option is necessary so that we can specify the
* file tag without using a full path to the filename.
* We could have also set this to the folder name so that all
* files in that folder would be IDXFORMAT"21" by using the
* following:
* [FOLDER:C:\\ISAMDemoNativeRM\\ISAMDemoNativeRM\\DATA]
* IDXFORMAT=21
*
* The EXTFH environment variable is set to point to the extfh.cfg
* file in the Application.config file which is part of the pro-
* ject.
*----------------------------------------------------------------*

 identification division.
 program-id. ISAMDemoNativeRM.
 environment division.
 configuration section.
*$SET IDXFORMAT"21" *> this could be used instead of the extfh.cfg
* to set test-file to idxformat"21"
     select test-file assign to
      "C:\ISAMDemoNativeRM\ISAMDemoNativeRM\DATA\testfile.dat"
                      organization is indexed
                      access is dynamic
                      record key is prime-key
                      alternate record key is contact
                         with duplicates
                      file status is file-status.
 data division.
 file section.
 fd test-file.
 01 test-record.
    05 prime-key pic 9(5).
    05 contact pic x(30).
    05 company pic x(30).
 working-storage section.
 01 file-status pic x(2) value spaces.
 01 any-key pic x.
 procedure division.
     display "create file"
     open output test-file
     display "open status = " file-status
     move 1 to prime-key
     move "Chris Glazier" to contact
     move "Micro Focus" to company
     perform 100-write-record
     move 2 to prime-key
     move "Bill Smith" to contact
     move "My Software Inc." to company
     perform 100-write-record
     close test-file
     display "read file"
     open i-o test-file
     display "open status = " file-status
     perform 110-read-records
     close test-file
     goback.
*----------------------------------------------------------------*
 100-write-record.
     write test-record
        invalid key
           display "write error = " file-status
           accept any-key
           stop run
     end-write.
*----------------------------------------------------------------*
 110-read-records.
     perform until exit
        read test-file next record
           at end
              exit perform
           not at end
              display "prime-key = " prime-key
        end-read
     end-perform.
*----------------------------------------------------------------*