MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COBOL VSAM-Matching for part of a key

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sinduja
Beginner


Joined: 20 Jun 2005
Posts: 29
Topics: 14

PostPosted: Tue Jul 05, 2005 6:19 am    Post subject: COBOL VSAM-Matching for part of a key Reply with quote

hi all
Thank you kolusu for your previous replies.
Now in a vsam(KSDS) file ..................
is it possible match for a part of a record key.

my file sectiopn is like this

01 fs-rec.
02 fs-key.
03 fs-id1 pic x(2).
03 fs-level-id pic x(4).
03 fs-cif-id pic x(3).
02 fs-.........
...............


now i want to fetch all records that have fs-level-id = '1608'
and fs-cif-id = '03'

if i move 1608 to fs-level-id and 03 to fs-cif-id and
try to fetch using

read ... invalid key
not invalid key

statement ,i get file status of 23,i.e no matching records inspite of having matching records.

can anyone please tell me what is the solution. (I cannot set an alternate index, and using sequential access is inefficient bcos the file is a large one and the matchin records r goin to be really few.)

thank you.

regards,
sinduja.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 05, 2005 6:36 am    Post subject: Reply with quote

sinduja,

You are matching only a part of the key and that too the contents in the middle. Unless you read the entire file you will not be able to read the records directly. you need to read every record and then check starting from the 3rd byte for a length of 6 has '160803'.

If your intention is just to filter out the records then you can simply use SORT utility to get the desired results.

ex:
Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD DSN=YOUR VSAM CLUSTER,   
//            DISP=SHR                               
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                   
  INCLUDE COND=(3,6,CH,EQ,C'160803')                 
/*                                                   


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sinduja
Beginner


Joined: 20 Jun 2005
Posts: 29
Topics: 14

PostPosted: Tue Jul 05, 2005 7:00 am    Post subject: Reply with quote

hi ,

thank you for your prompt reply

is it possible to get the records, if the part of the key is the 1st field?
how do i do it?

thank you

regrds,
sinduja
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 05, 2005 7:34 am    Post subject: Reply with quote

Quote:

is it possible to get the records, if the part of the key is the 1st field?
how do i do it?


sinduja,

yes it is possible to get the records if you know the first field.

Code:

01 fs-rec.
   02 fs-key.
      03 fs-id1       pic x(2).
      03 fs-level-id  pic x(4).
      03 fs-cif-id    pic x(3).
  02 fs-.........


Now let us say you want to select all the records which has the FS-ID of '15'

Code:


   MOVE '15'       TO FS-ID1
   MOVE LOW-VALUES TO FS-LEVEL-ID
                      FS-CIF-ID


Now use the START statement to position your record at the first record of 15

Code:

START VSAM-CLUSTER
  KEY IS GREATER THAN FS-KEY


and now read sequentially all the records.

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sinduja
Beginner


Joined: 20 Jun 2005
Posts: 29
Topics: 14

PostPosted: Tue Jul 05, 2005 7:41 am    Post subject: Reply with quote

THANK YOU
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group