support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets
 

Veryant Knowledge Base
Home > All Categories > Data Access > Managing the order of the alternate keys in an indexed file
Question Title Managing the order of the alternate keys in an indexed file

Sometimes when a user accesses a file migrated from Acucobol or RM/COBOL to either Jisam or c-tree file systems, the order of the alternate keys can change from the previous COBOL dialect used.
In these cases or even when we created a brand new file, it's important to use the appropriate compiler options for handling alternate keys.

When migrating from ACU to Jisam or c-tree or accessing an original file by using Visionj file connector, make sure you compile the program with '-cko' option.
This compiler option lists keys in offset order. Without this option keys are listed following the order they're declared in the FILE-CONTROL paragraph.

There is a similar compiler option, '-crko', specific to RM/COBOL data files. Just like '-cko', without this option keys are listed following the order they're declared in the FILE-CONTROL paragraph. But '-crko' handles split keys with multiple segments differently.
The -crko will evaluate all segments of the key for the offset, while -cko only evaluates the first segment for the offset.

Note that the -cko and -crko options change the order in which keys are registered in the physical file (you can verify this with file management utilities such as jutil and ctutil). As a consequence, this option affects XML/ISS dictionaries as well as the I$IO and file interfaces where keys are indicated by ordinal number.

Here's an example. The attached program, create-file.cbl, will create a file called "songs" with three alternae keys. The keys are declared in the file-control paragraph this way:

    select songs assign to "songs"
           organization is indexed
           access is dynamic
           record key is sr-key
           alternate record key is key2 = sr-artist sr-genre sr-album duplicates
           alternate record key is key3 = sr-artist sr-album sr-genre duplicates
           alternate record key is sr-title duplicates
           file status is file-status.

And the order of the items in the FD is:
    fd songs.
    01 songs-record.
       05 sr-key.
          10 sr-id          pic 9(5).
       05 sr-data.
          10 sr-title       pic x(30).
          10 sr-length      pic x(5).
          10 sr-artist      pic x(20).
          10 sr-album       pic x(30).
          10 sr-genre       pic x(15).
          10 sr-label       pic x(30).
          10 sr-year        pic 9(4).
          10 sr-authors     occurs 5.
             15 sr-author   pic x(20). 
Attached is a sample program that can be used to see the results of using the two different compiler options or none of them.
  • When compiled without any option, the order of the keys would be: sr-key, key2, key3, sr-title.
  • With -cko, the order is changed to follow the order of the fields in the FD: sr-key, sr-title, key2, key3.
  • With -crko, the order is changed to follow the order of the fields in the FD also for segments: sr-key, sr-title, key2, key2.

To see this in detail, compile the program with -cko or -crko and without any option, run it to create the file songs, and look at the file with jutil, using the -x option to display the offsets:

   jutil -info songs -x 
The structure of the physical file including all the alternate keys with the length and the offset of each alternate key are:

With no compiler options:
Key  Dups Segments
  1    N      1      Seg.   Offset    Size
                      1         0       5
  2    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        90      15
                      3        60      30
  3    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        60      30
                      3        90      15
  4    Y      1      Seg.   Offset    Size
                      1         5      30 
With -cko:
Key  Dups Segments
  1    N      1      Seg.   Offset    Size
                      1         0       5
  2    Y      1      Seg.   Offset    Size
                      1         5      30
  3    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        90      15
                      3        60      30
  4    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        60      30
                      3        90      15
With -crko:
Key  Dups Segments
  1    N      1      Seg.   Offset    Size
                      1         0       5
  2    Y      1      Seg.   Offset    Size
                      1         5      30
  3    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        60      30
                      3        90      15
  4    Y      3      Seg.   Offset    Size
                      1        40      20
                      2        90      15
                      3        60      30

Authored by: Veryant Support This question has been viewed 393 times so far.
Click Here to View all the questions in Data Access category.
File Attachments File Attachments
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. File Types Comparison : isCOBOL - Micro Focus COBOL - ACUCOBOL-GT - RM/COBOL
  2. How do I interpret file status 9? and other EXFS extended file status codes (e.g. 9i,105)?
  3. What format does isCOBOL use for ORGANIZATION RELATIVE files?
  4. What is 9l,10 error and why is it happening?
  5. Does isCOBOL support Data General file status codes?
  6. Can I install the UDBC 32 bit on my 64 bit computer in order to have the Veryant * driver for ODBC32 bits Administrator?
  7. Can I call a stored procedure from an isCobol program?
  8. Are Veryant's isCOBOL JISAM data format the same as Faircom's c-treeRTG?
  9. Why do I get 'ct_init ERROR 19:133:0' ?
  10. Did you know you can use an alias to map a different disk file name to an existing "assign to" clause of the select statement without source code changes?
  11. Did you know you can encrypt an indexed file?
  12. Handling the extension on indexed data files
  13. How to hide the user and password used to connect to an RDBMS
  14. Can we use Micro Focus format data and indexed files directly or do they need some form of conversion?
  15. How to access files on a different server
  16. How to create, write, and read to files without a program
Article Information Additional Information
Article Number: 341
Created: 2023-12-11 7:56 AM
Rating: No Rating
 
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
 
Search Knowledge Base Search Knowledge Base



 
 

© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.