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
 

 

Retrieving the exact record with a partial key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
normaltusker

New User


Joined: 29 May 2007
Posts: 3
Location: Bangalore

PostPosted: Fri Sep 24, 2010 4:48 pm    Post subject: Retrieving the exact record with a partial key
Reply with quote

I am aware that there are several topics on the forum which have addressed the issue of using partial keys in order to fetch records from a VSAM file. I tried using most of the approaches that were possible for me to use yet I am not able to get the desired results. This is the reason I am requesting help on this much debated topic again.
I have a KSDS VSAM with multiple records and a key length of 150 characters. It has records of variable record length ranging from 250 characters to 900 characters.
The VSAM has no AIX defined.

In my program, the select has been coded as:

Code:
 
SELECT INOUT-MASTER-FILE              ASSIGN TO VXVSAMMF
ORGANIZATION INDEXED
ACCESS DYNAMIC
RECORD KEY IS VSAM-KEY
ALTERNATE RECORD KEY IS VSAM-AK1
ALTERNATE RECORD KEY IS VSAM-AK2
FILE STATUS INOUT-FILE-STATUS.
         


I read on the forums that the leftmost part of the key must necessarily be filled before the partial key may be used. My program is taking care of filling up that part since it tries to retrieve records from the same file earlier in the program.
The records present in the file are identified by different record types each having a different meaning to it. Each record has a similar key except for a difference in the record type and few other fields.

My File structure for the select has been defined as below:
Code:
 
01  VSAM-REC.                                                   
    02  VSAM-KEY.                                               
        10  INOUT1-FILE-ID               PIC X(20).               
        10  INOUT1-FILE-SUFFIX           PIC X(15).               
        10  INOUT1-RECORD-SEQ            PIC 9(01).               
        10  INOUT1-IN-TYPE-ALT           PIC 9(02).               
        10  VSAM-AK1.                                           
            15  VSAM-AK1-BANK-CODE       PIC X(05).               
            15  VSAM-AK1-CHECK-NBR       PIC 9(10).               
            15  VSAM-AK1-SEQ             PIC X(01).               
            15  VSAM-AK1-COUNTER         PIC 9(07) COMP-3.       
            15  VSAM-AK1-33COUNT         PIC 9(04) COMP-3.       
                88  VSAM-OUT-LINE-ACTIVITY     VALUE 1 THRU 9999.
        10  VSAM-RECORD-TYPE             PIC 9(02).               
            88  VSAM-FILE-HEADER         VALUE 10.
            88  VSAM-FILE-NA             VALUE 11.
            88  VSAM-FILE-DETAIL         VALUE 12.
            88  VSAM-IN-HEADER           VALUE 20.
            88  VSAM-IN-NAME-ADDRESS     VALUE 21.
            88  VSAM-IN-ACTIVITY-DETAIL  VALUE 22.
            88  VSAM-OUT-CHECK-HEADER    VALUE 30.
            88  VSAM-OUT-NAME-ADDRESS    VALUE 31.
            88  VSAM-OUT-LINE-SUMMINY    VALUE 32.
        10  VSAM-FILLER2                 PIC X(25).               
        10  VSAM-AK2.                                           
            15  VSAM-AK2-FILE            PIC X(20).               
            15  VSAM-AK2-IDNBR-CLM       PIC X(25).               
            15  VSAM-AK2-IN-TYPE         PIC 9(02).               
            15  VSAM-AK2-RECTYPE         PIC 9(02).               
            15  VSAM-AK2-YYDDD           PIC 9(05).               
            15  VSAM-AK2-COUNTER         PIC 9(08) COMP-3.       
            15  VSAM-AK2-COUNTER33       PIC 9(04) COMP-3.       
    02  VSAM-LRECL                       PIC 9(04).               
    02  VSAM-DATA                        PIC X(01)               
        OCCURS 096 TO 0746 DEPENDING ON VSAM-LRECL.             


Further down in the program, after successfully retrieving a record of the first type, it is imperative to fetch a record of the second type. For this i populate data into the VSAM-AK2 field and try a start browse.
Code:
 
START INOUT-MASTER-FILE KEY NOT < VSAM-KEY INVALID KEY
    MOVE 'N' TO WS-MATCHED-FOUND-SW                   

This is followed by a read next.

The data that is present in the file has the value xxxxx nn in the field VSAM-AK2-IDNBR-CLM where as we are populating just xxxxx in the field before the start browse.

i tried using this query in file aid and found that the data is being fetched alright.

My problem is, although the start browse commands have been coded similarly, my file still does not read the record that is present in the file and instead reads the last record possible and fails.

please help me rectify this as i have lost many person hours of effort on this already.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Sep 24, 2010 5:00 pm    Post subject:
Reply with quote

Quote:
The VSAM has no AIX defined.
conflicts with
Code:
ALTERNATE RECORD KEY IS VSAM-AK1
ALTERNATE RECORD KEY IS VSAM-AK2
so we already know you're not being truthful -- so how much help do you think we can provide?

And this is utter garbage:
Quote:
For this i populate data into the VSAM-AK2 field and try a start browse.
Code:

START INOUT-MASTER-FILE KEY NOT < VSAM-KEY INVALID KEY
MOVE 'N' TO WS-MATCHED-FOUND-SW
if you move data to VSAM-AK2, then start browsing on the primary key, you have completely wiped out anything in VSAM-AK2 since the primary key will control the browse. You would need to start your browse based on VSAM-AK2 if that's what you're trying to read.

Furthermore, if I'm needing to access a VSAM file at two different records in one program, I always create two SELECT statements, two OPEN statements, and so forth so I can retain the record pointer for one as I'm bouncing around the file with the other variable.
Back to top
View user's profile Send private message
normaltusker

New User


Joined: 29 May 2007
Posts: 3
Location: Bangalore

PostPosted: Fri Sep 24, 2010 5:18 pm    Post subject:
Reply with quote

I am building the AIX now.

For the other part where the browsing is concerned, i shall fix it once i have the aix up and running.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2435
Location: Netherlands, Amstelveen

PostPosted: Fri Sep 24, 2010 6:22 pm    Post subject:
Reply with quote

Quote:
as I'm bouncing


Robert,

you have a job on the side as a bouncer? icon_eek.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Sep 24, 2010 6:43 pm    Post subject:
Reply with quote

Peter, I could use one a bouncer, stationed right next to my cubicle ... it's been one L-O-N-G week so far and I've got 6 hours to get beat up on left!
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2435
Location: Netherlands, Amstelveen

PostPosted: Fri Sep 24, 2010 6:51 pm    Post subject:
Reply with quote

Robert,

im sorry to hear that. Hope that after those 6 hours you still have
some boozing time left.

Anyway, have a nice week-end.

Cheers
Back to top
View user's profile Send private message
normaltusker

New User


Joined: 29 May 2007
Posts: 3
Location: Bangalore

PostPosted: Fri Sep 24, 2010 8:31 pm    Post subject: Reply to: Retrieving the exact record with a partial key
Reply with quote

Guys,
This was my mistake - while creating the files using the pre-populate feature of the file-aid, i did not realize that the file-aid did not create the aix files on its own. when Robert pointed out that the AIX files must be present for the sake of the 2 extra keys to work, I cross checked the production files and found that the AIX files actually existed but were not replicated at my end.
I recreated the 2 AIX files and resubmitted the job leading to a good EOJ.

Thanks for pointing my mistake out Rob, was a little rough but helped me none the less! icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Sep 24, 2010 8:45 pm    Post subject:
Reply with quote

Glad to hear you got it working!
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 Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm


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