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

retrieval of data using alternate key fails


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Thu Dec 25, 2008 11:30 am
Reply with quote

Hi,

I'm trying to retrieve data from a ksds file using the alternate key, it is giving me status code of 23.

File-control.

SELECT PFAUTMD ASSIGN TO PFATMD
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS EMPNO
ALTERNATE KEY IS NAME WITH DUPLICATES
FILE STATUS IS W01-RETURN-CODE.


FD PFAUTMD.
01 IN-REC.
03 EMPNO PIC X(4).
03 NAME PIC X(7).
03 FILLER PIC X(1).
03 DEPT PIC X(3).
03 FILLER PIC X(5).


In Procedure division

Move 'pavan' to name.
Read pfautmd.

When i execute this program it gives a status code of 23.

I Have Created the VSAM,AIX datasets of Avg,max Record length of 20.
The keys for VSAM dataset are (0,4).
The keys for AIX dataset are (4,7).

IN JCl i have mentioned the datasets as

//PFATMD DD DSN=A304.PAVAN.KSDS,DISP=SHR
//PFATMD1 DD DSN=A304.PAVAN.KSDS.PATH,DISP=SHR


When i was trying to retrieve Randomly it was giving me status code of 23
But When i read it sequentially it displays all the records correctly.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 25, 2008 11:03 pm
Reply with quote

So what you're saying is there's no record with NAME = 'pavan' on the file. Add one and try again.
Back to top
View user's profile Send private message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Fri Dec 26, 2008 10:34 am
Reply with quote

Hi,

I Have Two records with NAME = "pavan' on the file,

The data on the file is below,

VSAM BASE CLUSTER

---- +----1----+----2
*********************
121 pavan ece
122 gopi eee
123 ramu mec
124 pavan mec
125 gopi mec


PATH FILE DATA,

---- +----1- ---+----2
**********************
122 gopi eee
125 gopi mec
121 pavan ece
124 pavan mec
123 ramu mec


Thanks in advance,
Back to top
View user's profile Send private message
Ten

New User


Joined: 26 Dec 2008
Posts: 2
Location: China

PostPosted: Fri Dec 26, 2008 12:19 pm
Reply with quote

Hi,
you can have a try with "START".It is to make sure you can access file with alternate record.it is to relocate the file.then you can read the file with name.
MOVE SPACE TO NAME
START PFAUTMD KEY NOT < NAME
INVALID KEY SET END-OF-FILE TO TRUE.
Back to top
View user's profile Send private message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Fri Dec 26, 2008 2:06 pm
Reply with quote

Thanks Ten for u r reply.

BUt even when i use start as u suggested it gives me a status code of 46.

''Attempting to read a non-existing record".
Back to top
View user's profile Send private message
Ten

New User


Joined: 26 Dec 2008
Posts: 2
Location: China

PostPosted: Fri Dec 26, 2008 2:37 pm
Reply with quote

Hi,
Sorry,if you read file with random.
how about having a try as below.

Move 'pavan' to name
START PFAUTMD KEY NOT < NAME
INVALID KEY SET END-OF-FILE TO TRUE.
Back to top
View user's profile Send private message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Fri Dec 26, 2008 4:35 pm
Reply with quote

Hi TEN,

I tried reading it sequentially,dynamically,randomly,

When i read it sequentally i was able to retreive all the record well,
but When i try to retreive dynamically it gives a status code of 46,
When t try to retreive randomly it gives a status code 23.

Correct me if gone wrong somewhere,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Dec 26, 2008 6:09 pm
Reply with quote

Code:

Move 'pavan' to name.
Read pfautmd.
This should return a file status 23 in your program. You do not specify to read by the alternate key, so COBOL will read by primary key which is the default. Since you did not set the primary key, your read will not find any such record and will return a 23.

It would be interesting to see your "retrieve dynamically" code but I'm willing to bet that it exhibits the same problem of not doing a valid READ or START before attempting the READ NEXT to pick up a record -- hence the 46 file status.
Back to top
View user's profile Send private message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Fri Dec 26, 2008 6:28 pm
Reply with quote

Hi Robert,

Could please suggest me the correct way doing this.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Dec 26, 2008 6:31 pm
Reply with quote

You should be looking up basic syntax in the Language Reference manual, which can be reached by using the link at the top of the page. However, try this (I haven't tested it but it should work):
Code:
Read pfautmd
     key is name.
Back to top
View user's profile Send private message
pavan krothapalli

New User


Joined: 08 Apr 2008
Posts: 7
Location: india

PostPosted: Sat Dec 27, 2008 12:59 pm
Reply with quote

Hi ,

I have tried the way robert has suggested but still i got file staus code 23,

I have even gone through the manuals,but still i could not get anything.

Could please suggest me if there is any otherway of doing this.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Dec 27, 2008 8:57 pm
Reply with quote

Post the LISTCAT for the base cluster and AIX. I've just created a program that does exactly this, and it returns the records successfully with the expected file status code of 02. Therefore, there's something wrong with your VSAM definition, or your code -- and if you've put KEY IS NAME on your READ statement, it isn't the code.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Dec 27, 2008 9:16 pm
Reply with quote

Quote:
I Have Created the VSAM,AIX datasets of Avg,max Record length of 20.
The keys for VSAM dataset are (0,4).
The keys for AIX dataset are (4,7).
I just noticed this in your original post. The KEYS clause for the AIX should be (7 4) and the base cluster should be (3 0) -- or (4 0) depending on whether you want to index the FILLER byte. The length comes first in the IDCAMS DEFINE, followed by the offset, not offset followed by length. This is another reason the LISTCAT output will be important to review -- because if you reversed these fields, your COBOL program would certainly get a file status 23 (I tried it to make sure).
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top