View previous topic :: View next topic
|
Author |
Message |
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
So what you're saying is there's no record with NAME = 'pavan' on the file. Add one and try again. |
|
Back to top |
|
|
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
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 |
|
|
Ten
New User
Joined: 26 Dec 2008 Posts: 2 Location: China
|
|
|
|
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 |
|
|
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
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 |
|
|
Ten
New User
Joined: 26 Dec 2008 Posts: 2 Location: China
|
|
|
|
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 |
|
|
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
Hi Robert,
Could please suggest me the correct way doing this. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
pavan krothapalli
New User
Joined: 08 Apr 2008 Posts: 7 Location: india
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|