Read vsam using the alternate index



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Read vsam using the alternate index

Postby macnano » Fri Mar 01, 2013 5:18 am

I need to read a vsam file with alternate index. Both the base file and alternate index file have DDs in the JCL.
1. do I need a select statement for the alternate aix file or just the base file and indicate the alternate key?
2. If I need to have a select statement for the alternate aix file, should the START statement on the alternate aix > alternate key?
3. If #1 is no, should the START statement on the base file where key > alternate key which is defined in the select statement?
4. Should the READ NEXT be the base file or the alternate aix file?

Thank you.
macnano
 
Posts: 9
Joined: Wed Feb 06, 2013 3:07 am
Has thanked: 1 time
Been thanked: 0 time

Re: Read vsam using the alternate index

Postby Robert Sample » Fri Mar 01, 2013 6:31 am

You have the base VSAM file for one DD statement, and the PATH (not the alternate index) specified for the second DD statement, right?

SELECT VSAM-FILE ASSIGN TO DDA
    ORGANIZATION INDEXED
    ACCESS RANDOM
    RECORD KEY IS VF-KEY
    ALTERNATE RECORD KEY IS VF-ALT-KEY
    FILE STATUS IS VF-STAT
followed by
READ VSAM-FILE
    KEY IS VF-ALT-KEY
or
READ VSAM-FILE
    KEY IS VF-KEY
and
READ VSAM-FILE NEXT
VF-KEY and VF-ALT-KEY must be defined in an 01 under the FD; there are some other restrictions which you can read in the COBOL Language Reference manual (link at the top of the page).
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post