IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Accessing thru Alternate key in ksds


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
johngeorge

New User


Joined: 03 Aug 2006
Posts: 5

PostPosted: Tue Feb 20, 2007 11:33 am
Reply with quote

i have a ksds cluster, i had created the index file, record key is bookid, alternate record key is authorname. authorname is having duplicates. i want to retrieve the record corresponding to the authorname
say ramu. the author ramu had written two books. i want to retrieve all the details of those two books. how should i use the read statment?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 20, 2007 10:39 pm
Reply with quote

Hello,

I'm not sure i understand your requirement - sorry if i misunderstood.

Do you want to do this using the sort? If so, you can use an INCLUDE. You'll pass the file retrieving only those records that match the value INCLUDed.

If the vsam file is very large, i'd suggest using a cobol program that would "start" at authorname and only process the records for that author.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Wed Feb 21, 2007 11:06 am
Reply with quote

John,
Try to access the KSDS in a Dynamic mode by using Author name as alternate record key an use the start verb , u r functionality would be achieved

Syntax would be
Code:

                   EQUAL TO
START file-name  KEY is   GREATER THAN  dataname
                      NOT LESS THAN
                   NOT >

      [INVALID KEY imperative statement]




Thamilzan.
Back to top
View user's profile Send private message
smiley
Warnings : 1

New User


Joined: 08 Feb 2006
Posts: 27

PostPosted: Wed Feb 21, 2007 1:00 pm
Reply with quote

is the author name a part of your key?? if that is the case u can go for a generic read..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 21, 2007 7:54 pm
Reply with quote

Hello,

Yes, there are several coding solutions, but i'm still not sure if code is ok or TS wants this via sort. This IS the sort forum. . . . icon_confused.gif
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Wed Feb 21, 2007 10:06 pm
Reply with quote

dick scherrer wrote:
Hello,

Yes, there are several coding solutions, but i'm still not sure if code is ok or TS wants this via sort. This IS the sort forum. . . . icon_confused.gif


Dick, not any more. It's moved to cobol icon_wink.gif
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Fri Feb 23, 2007 11:54 am
Reply with quote

Code:
ID DIVISION.
  PROGRAM-ID.  XXX.
  ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.
         SELECT FILE1 ASSIGN TO DD1
          ORGANISATION  IS INDEXED
          ACCESS MODE IS RANDOM
          RKEY IS BOOKID
          ALTERNATE KEY IS AUTONAME WITH DUPLICATE
           FILE STATUS IS FS1.
   DATA DIVISION.
   FILE SECTION.
   01 MASTER
       O2 X PIC X(80).
           
   WORKING-STORAGE SECTION.
    77 FS1 PIC 99.
   PROCEDURE DIVISION
    MAINPARA.
            PERFORM OPENPARA.
            PERFORM READ-PARA.
            PERFORM START-PARA.
            PERFORM CLOSE-PARA.
   OPENPARA.
             OPEN  INPUT FILE1.
  READ-PARA.
             MOVE RAMU TO  AUTONAME.
              IF INVALID KEY DISPLAY "THIS IS INVALID RECORD"
              IN NOT INVALID
 START-PARA.
              START AUTONAME.
               READ FILE1 NEXT
               DISPLAY MASTER.
  CLOSE-PARA.
            CLOSE-FILE1.
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Fri Feb 23, 2007 11:59 am
Reply with quote

AND FOR JCL
//CNEW444C JOB (A1234,345),ZAHIR,MSGLEVEL-= (1,1),PRTY=14,NOTIFY=&SYSUID
//S1 EXEC PGM=IGYWCLG
//SYSPRING DD SYSOUT=*
//DD1 DD DSN=CLUSTERNAME, DISP=SHR
//DD11 DD DSN=PATHNAME
//
AND RUN
FROM SACHIN BORASE
PUNE
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Accessing ABENDCC in JCL JCL & VSAM 6
No new posts VSAM KSDS CREATION AND LOAD WITH RAND... JCL & VSAM 1
No new posts Add column to existing records using ... JCL & VSAM 2
Search our Forums:

Back to Top