Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

[Solved]READING VSAM FILE USING ALTERNATE INDEX
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Tue Jul 19, 2005 2:19 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

HI,

Hi,

I have the following two questions:

1.How to define the record size in alternate cluster definition, should it be the same as in the base cluster.(Is there any other criteria)

2.Is it possible to read a vsam file using alternate index. if so plz tell me how to declare alternate key in file control area and use it in the procedure division.

waiting for Ur replies........

Thank u.
icon_smile.gif icon_smile.gif
Back to top
View user's profile Send private message

thanooz

New User


Joined: 28 Jun 2005
Posts: 99

PostPosted: Tue Jul 19, 2005 2:32 pm    Post subject:
Reply with quote

hi kaushik


1) as per my concern it is same as in base cluster

if any wrong correct me

2) ALTERNATE KEY is keyfeild

that cane use as likeas key feild but in alternate key duplicate records can be possible

thanks
thanooz
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Tue Jul 19, 2005 2:51 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi thanooz,


Can u give me some sample Cobol code. Ur first answer cleared my doubt but my second question remains unanswered.

Bye,
icon_smile.gif
Back to top
View user's profile Send private message
thanooz

New User


Joined: 28 Jun 2005
Posts: 99

PostPosted: Tue Jul 19, 2005 8:03 pm    Post subject:
Reply with quote

hi

select file1 assign to dd1
organiztion is indexed
access is dynamic
record key is key field
alternate key is alternate key field
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Wed Jul 20, 2005 9:58 am    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi,
What should be assigned to dd1 in jcl:
Path name or base cluster name or the alternate index cluster name.


Bye.
icon_rolleyes.gif icon_rolleyes.gif
Back to top
View user's profile Send private message
Mutthu_talluri

New User


Joined: 16 Jun 2005
Posts: 9

PostPosted: Wed Jul 20, 2005 10:36 am    Post subject:
Reply with quote

Hi,

Its Path name....

//DDname DD DSN=Pathname,disp=()

Automatically path will open Base cluster and Alternate index cluster..

Corrections are welocome..
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Jul 20, 2005 10:53 am    Post subject: Re: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

dd1 is the name of Data Definition(DD name) in JCL which is the connector name

DD1 - INDEX FILE CONNECTOR
DD2 - PATH

EMP IS INDEX FILE (VSAM DATASET)
AIPATH IS ALTERNATH INDEX PATH

example:
In jcl

DD1 DD DSN=TSORSAM.TRG.EMP,DISP=SHR
DD2 DD DSN=TSORSAM.TRG.AIPATH,DISP=SHR
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Wed Jul 20, 2005 10:59 am    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi,
I have a problem in opening the file when using the path name.

But I am able to read without any error while reading from the base cluster without using alternate key.

Is there any particular syntax for opening the file and reading it while using alternate key.

Can U send me the syntax for opening and reading. I am using the following to open and read:

OPEN INPUT INP-FILE.
IF WS-FSTATUS = "00"
DISPLAY "OPENED"
DISPLAY WS-FSTATUS
PERFORM COMPUTE-PARA
ELSE
DISPLAY "ERROR"
DISPLAY WS-FSTATUS
STOP RUN.

COMPUTE-PARA.
MOVE "RAM" TO STUD-NAME. (STUD-NAME IS THE ALTERNATE KEY)
READ INP-FILE
END-READ.
MOVE STUDENT-REC TO WS-INP-REC.
DISPLAY WS-INP-REC.
.
.
.
.
.
.
.
.


Bye icon_rolleyes.gif icon_rolleyes.gif
Back to top
View user's profile Send private message
gsnvsr

New User


Joined: 06 Jul 2005
Posts: 40

PostPosted: Wed Jul 20, 2005 2:06 pm    Post subject: Re: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

When you want to read a VSAM - KSDS with a Key, use 'KEY IS' clause along with the Read statement as in :

READ <File-name> KEY IS <Primary/Alternate key>

Hope this helps!

Best regards!
Prasad
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Jul 20, 2005 2:25 pm    Post subject: Sample Code
Reply with quote

Note
===
dd1 is DD name for ksds
Don't use path dd name in cobol pgm

CODE
====
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM3.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO DD1
ACCESS MODE IS DYNAMIC
ORGANIZATION IS INDEXED
RECORD KEY IS STU-ID
ALTERNATE RECORD KEY IS NAME.
DATA DIVISION.
FILE SECTION.
FD IN-FILE.
01 S-RECORD.
02 STU-ID PIC 9(5).
02 NAME PIC X(10).
02 AGE PIC 9(2).
02 FILLER PIC X(63).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT IN-FILE.
MOVE 'RAMESH' TO NAME.
PERFORM READ-PARA.
CLOSE IN-FILE.
STOP RUN.
READ-PARA.
READ IN-FILE RECORD KEY IS NAME
INVALID KEY GO TO ERROR-PARA.
DISPLAY STU-ID.
DISPLAY NAME.
DISPLAY AGE.
ERROR-PARA.
DISPLAY 'ERROR SEARCHING KEY ITEM'.
CLOSE IN-FILE.
STOP RUN.

This would give you a clear picture
icon_cool.gif
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Wed Jul 20, 2005 2:26 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi Prasad,

Sorry I did not mention that but I used that approach to. But I still find ERROR in opening the File.

Here is the Code.

IDENTIFICATION DIVISION.
PROGRAM-ID. FILEREAD.


ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT INP-FILE ASSIGN TO DD1
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS STUD-ID
ALTERNATE KEY IS STUD-NAME
FILE STATUS IS WS-FSTATUS.


DATA DIVISION.
FILE SECTION.
FD INP-FILE.
01 STUDENT-REC.
05 STUD-ID PIC X(4).
05 STUD-NAME PIC X(10).
05 STUD-DEPT PIC A(10).
05 FILLER PIC X(56).
WORKING-STORAGE SECTION.
01 WS-FSTATUS PIC X(2).
01 WS-INP-REC.
05 WS-STUD-ID PIC X(4).
05 WS-STUD-NAME PIC X(10).
05 WS-STUD-DEPT PIC A(10).
05 WS-FILLER PIC X(56).
01 WS-SSTUD-NAME PIC X(7).


PROCEDURE DIVISION.
OPEN-PARA.
OPEN INPUT INP-FILE.
IF WS-FSTATUS = "00"
DISPLAY "OPENED"
DISPLAY WS-FSTATUS
PERFORM COMPUTE-PARA
ELSE
DISPLAY "ERROR"
DISPLAY WS-FSTATUS
STOP RUN.

COMPUTE-PARA.
MOVE "SESHATHRI" TO WS-SSTUD-NAME.
MOVE WS-SSTUD-NAME TO STUD-NAME.
READ INP-FILE KEY IS STUD-NAME
END-READ.
MOVE STUDENT-REC TO WS-INP-REC.

DISPLAY-PARA.
DISPLAY WS-STUD-NAME.
DISPLAY WS-STUD-DEPT.
CLOSE-PARA.
CLOSE INP-FILE.
STOP RUN.

BYE. icon_rolleyes.gif
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Jul 20, 2005 2:34 pm    Post subject:
Reply with quote

CAN YOU TELL ME THE ERROR clearly ? [error msg]
you also didn't specify where the control should go after performing compute-para.
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Wed Jul 20, 2005 2:42 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi,

The problem is not in the COMPUTE-PARA. Cobol follows a top down approach while running , in this case after the IF CONDITION RETURNS TRUE the control goes to COMPUTE-PARA. When the execution of that PARA is finished the Control is transfered next to the DISPLAY-PARA.

But the problem is not in that, it's in the FILE OPENING . I get a ERROR of 35 in FILE STATUS [WS-FSTATUS ].

Any Clue????

BYE icon_rolleyes.gif .
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Jul 20, 2005 2:47 pm    Post subject: Error code- 35 details
Reply with quote

Result
=====

ATEEMPTING TO OPEN AN EMPTY FILE IN INPUT OR I/O MODE. DD NAME IS MISSING OR WRONGLY GIVEN.
Explanation
-------------

An OPEN statement with the INPUT, I-O, or EXTEND phrase was attempted on a non-optional file that was not present.
Back to top
View user's profile Send private message
KAUSHIK RANGARAJAN

New User


Joined: 19 Jul 2005
Posts: 22
Location: chennai

PostPosted: Wed Jul 20, 2005 4:40 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi Rameshs,

I got Ur point regarding return of Control after Compute-para and Corrected It. Thanks.

Thanks for the Error Description, but I know this detail already. The problem is that the File exists, I can read from the Base Cluster when I am not using Alternate index approach, that is I use Primary Key. But as soon as change the Key to a Alternate key I get error 35. DDNAME is correct and everything else looks fine.


Help ???


Bye. icon_rolleyes.gif
Back to top
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Wed Jul 20, 2005 4:56 pm    Post subject:
Reply with quote

Did you follow these steps while creating Alternate index

1. create Alternate index file
2. Populate the index (build index)
3. create path
4. In Runjcl specify dd for path
Back to top
View user's profile Send private message
alamelu

New User


Joined: 18 Jul 2005
Posts: 15

PostPosted: Wed Jul 20, 2005 5:38 pm    Post subject: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

Hi ,
The Open Error may be due the Incorrect Alternate key position when u defined the Alternate Cluster .
For Ex: when the Key Postion is from 11 column to 10 Bytes , then while defining it , should be Keys(10 10) not (10 11) .

Thanks,
Alamelu
Back to top
View user's profile Send private message
gsnvsr

New User


Joined: 06 Jul 2005
Posts: 40

PostPosted: Thu Jul 21, 2005 9:36 am    Post subject: Re: READING VSAM FILE USING ALTERNATE INDEX
Reply with quote

I believe the alternate index has not been created properly then. Pls check.

Best regards,
Prasad
Back to top
View user's profile Send private message
shobam

New User


Joined: 18 Jul 2005
Posts: 34
Location: CN

PostPosted: Thu Jul 21, 2005 10:06 am    Post subject: alternate index has not been created properly
Reply with quote

When the PATH name is not mentioned correctly or not specified in the JCL we will get this error. Please check the PATH name in the JCL or try creating it again.

Thanks@Regards
Shobam
Back to top
View user's profile Send private message
thanooz

New User


Joined: 28 Jun 2005
Posts: 99

PostPosted: Thu Jul 21, 2005 12:30 pm    Post subject:
Reply with quote

hi

in dd1 you give your actuval vsam ksds
dd11 you give ksds path file









thanooz
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us