Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indexed file with multi-key question

Status
Not open for further replies.

butler

MIS
Oct 12, 1998
88
US
Hi all,

Can anyone shed some light on the follow from my COBOL manual?

'An Alternate key data-name cannot reference an item whose leftmost character position corresponds to the leftmost character position of the item referenced by the primary key or by another alternate key for the same file'.

I have tested the following and it seem to work great, but also seem to break the above rule?

SELECT AUXIPD-FILE
ASSIGN TO "WIPDBUTLER"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
LOCK MODE IS MANUAL
FILE STATUS IS AUXIPD-DISK-ERR
RECORD KEY IS AUXIPD-KEY-ITEM =
AUXIPD-ITEM
AUXIPD-WARE
AUXIPD-ORDER
AUXIPD-REL
AUXIPD-SEQ
AUXIPD-LINE
ALTERNATE RECORD KEY IS AUXIPD-KEY-ITEM-DATE =
AUXIPD-ITEM
AUXIPD-WARE
AUXIPD-INV-DATE
WITH DUPLICATES.

Any thoughts?

Thanks,
bill


 
Hi,

The field AUXIPD-ITEM is defined twice... Why? It seems that this does not fit the restrictions in the manual but everything works fine you say... so... why bother? :)

By reading your code I was astonished because in the standard COBOL you have the syntax for an idexed file:

RECORD KEY IS data-name-1

which means that you can only define one key area which can contain of course several other fields.

On the other hand, the syntax you use:

AUXIPD-KEY-ITEM = AUXIPD-ITEM .....

seems to create an apart key field which probably will be held in a separate index containing file or something like that. So in that case, they are not on the same place. I guess that all the fields you define as being the key, are copied into that separate key area.

Nice to read this code!

With what compiler do you work?

 
Thanks for responding,

The AUXIPD-KEY-ITEM = AUXIPD-ITEM in place of RECORD KEY IS data-name-1 is a Microfocus only extension.

Now you have me thinking! My FD looks like this...

FD AUXIPD-FILE.
01 AUXIPD-REC.
05 AUXIPD-ITEM PIC X(18).
05 AUXIPD-WARE PIC 99 COMP.
05 AUXIPD-KEY-ORDER.
10 AUXIPD-ORDER PIC 9(7) COMP.
10 AUXIPD-REL PIC 9(2) COMP.
10 AUXIPD-SEQ PIC 9(2) COMP.
05 AUXIPD-LINE PIC 9(3) COMP.
05 AUXIPD-CUST PIC 9(6) COMP.
05 AUXIPD-INV-DATE PIC 9(8) COMP.
05 AUXIPD-TYPE PIC X.
05 AUXIPD-LINE-TYPE PIC 9(2) COMP.
05 AUXIPD-PROD PIC 9(4) COMP.
05 AUXIPD-ITYPE PIC X.

so I was expecting problems because AUXIPD-ITEM is the left most item in both keys. But everything compiled clean and I check a few things and all seems OK. Is this because I define split keys, and AUXIPD-ITEM is written more than once to disk? I was trying to avoid this! As this is a large file and disk space is an issue.

I was thinking that because AUXIPD-ITEM is defined only once in the FD that it would only be written to disk once. This is going to be a large file, so size is an issue. Do you have any recommendations as far as saving disk space? It's just that a lot is riding on this code and I don't want any mistakes!!!!

Thanks again,
bill
 
Hi,

You can just experiment with this. Take a small file to try it out and you know what the best solution is. You can see the result of the definition when writing something. You will find out how many separate files are going to exist.

About the primary key I think you can define a

AUXIPD-KEY-AREA like here:

    FD AUXIPD-FILE.
    01 AUXIPD-REC.
03 AUXIPD-KEY-AREA.
       05 AUXIPD-ITEM          PIC X(18).
       05 AUXIPD-WARE          PIC 99      COMP.
       05 AUXIPD-KEY-ORDER.
          10 AUXIPD-ORDER         PIC 9(7)    COMP.
          10 AUXIPD-REL           PIC 9(2)    COMP.
          10 AUXIPD-SEQ           PIC 9(2)    COMP.
       05 AUXIPD-LINE          PIC 9(3)    COMP.
03 AUXIPD-DATA-AREA.
     05 AUXIPD-CUST          PIC 9(6)    COMP.
       05 AUXIPD-INV-DATE      PIC 9(8)    COMP.
       05 AUXIPD-TYPE          PIC X.
       05 AUXIPD-LINE-TYPE     PIC 9(2)    COMP.
       05 AUXIPD-PROD          PIC 9(4)    COMP.
       05 AUXIPD-ITYPE         PIC X.

I would also try to define some contiguous area for the alternate key but that seems not possible here.

I hope that you'll let us hear about how many files you get depending on the definition you are using.

Greetings,

Crox
 
Thanks,

I took a closer look at a small group of records, with COMP removed to make it easer to view the results. No matter how may alternate keys I make I only get 2 output files. 'WIPDBUTLER' with my records in it. And 'WIPDBUTLER.idx' with my keys in it. The AUXIPD-ITEM and AUXIPD-WARE appear once in WIPDBUTLER, and twice (once for each key) in WIPDBUTLER.idx.

I don't see how I can avoid this...so I guess I'll move forward.

Thanks again for your support. I'm all alone here with no one to bounce ideas off of!! You've been a big help!!

bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top