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
 

 

retrieval of data using alternate key fails

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: retrieval of data using alternate key fails
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Dec 25, 2008 11:03 pm    Post subject:
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    Post subject: retrieval of data using alternate key fails
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Dec 26, 2008 6:09 pm    Post subject:
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    Post subject:
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Dec 26, 2008 6:31 pm    Post subject:
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    Post subject:
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Sat Dec 27, 2008 8:57 pm    Post subject:
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Sat Dec 27, 2008 9:16 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid 2 commands instream work. In ... descann Compuware & Other Tools 2 Tue May 16, 2017 3:31 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


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