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
 

 

Having more than one field as VSAM key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 12:45 pm    Post subject: Having more than one field as VSAM key
Reply with quote

Hi,,

I have file with more than one field contributing for the primary key and alternate keys. Say I have Key1 and Key2 as primary key and at the same I have key2, key3 and key4 as alternate key. I would like to know how I can declare in the 'Select ... Assign' statement of the cobol program.
For eg,
file-control.
select stu-file assign to disk
organization is indexed
access mode is random
record key is rno -- how do i specify in my case
alternate record key is name --how do i specify this in my case.

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

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Nov 04, 2008 12:47 pm    Post subject:
Reply with quote

Does it not give any examples in the fine manuals ?

Have you tried google ?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Nov 04, 2008 12:48 pm    Post subject: Reply to: Having more than one field as VSAM key
Reply with quote

since the vsam key must be is a contiguous string of bytes
the subdivision in fields is arbitrary and depends only on the program specification..
You can map/divide the vsam key in more than one field, but that' s not a vsam concern ( and they must be contiguous )
Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 12:51 pm    Post subject:
Reply with quote

I tried in the google and could find any example. icon_sad.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Nov 04, 2008 12:57 pm    Post subject:
Reply with quote

amitha wrote:
I tried in the google and could find any example. icon_sad.gif


Really ? You DO surprise me

And here was I, only 10 seconds on google and came up with THIS topic which was not only on google but on this very forum too.

Along with thousands of other examples and leads from google.
Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 1:00 pm    Post subject:
Reply with quote

Thank enrico..

So in my case, i am confused how can I have it as continuous, since a single feild is being part of both primary and alternate key??

Do we have different format of 'RECORD KEY IS ' and 'ALTERNATE KEY IS'?

Please guys, help me with this doubt.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Nov 04, 2008 1:01 pm    Post subject: Reply to: Having more than one field as VSAM key
Reply with quote

it would be better to review Your understanding of VSAM KSDS organization...

what do You see for the key when You define a vsam ksds...
quoting for the help from define
Quote:
))KEYS('LENGTH' 'OFFSET')
- Specifies that information about the key field for
key-sequenced data follows.
'LENGTH' - Length of the key.
'OFFSET' - Offset of the key.
REQUIRED - 'LENGTH' and 'OFFSET'


/repeat on
so Your program/application might consider the vsam key as composed of
two parts, but that' s strictly application logic not VSAM

I do not speak CObOLESE but the applroach could be

some_level KEY
some_level+1 part_one_of_the_key
some_level+1 part_two_of_the_key

and in the file stuff COBOL/VSAM expect You to refer only to the KEY
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Nov 04, 2008 1:05 pm    Post subject: Reply to: Having more than one field as VSAM key
Reply with quote

why don' t You use a bit of imagination

let' s suppose that all the key components are 5 bytes long

primary key token1,2
altern key token2,3,4

the token should be contiguos in the file layout
and the definition would be
PRIMARY ==> KEYS(10,0)
ALTERNAT ==> KEYS(15,5)
simple isn' t it
Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 1:12 pm    Post subject:
Reply with quote

Hey guys,

I got your point. Let me dig more on this and I will come back on this.

Thanks a lot guys for your valuable inputs.
Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 2:06 pm    Post subject:
Reply with quote

I am not sure how can we declare the file structure for the above case.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Nov 04, 2008 2:20 pm    Post subject: Reply to: Having more than one field as VSAM key
Reply with quote

again... I DO NOT SPEAK COBOLESE but ....

something like for the record layout

Code:
01    RECORD.
  05  KEY_PART_1 PIC X(5).
  05  KEY_PART_2 PIC X(5).
  05  KEY_PART_3 PIC X(5).
  05  KEY_PART_4 PIC X(5).
  05  ... the rest of the record

something like for the keys for direct access

Code:
xx    PRIMARY_KEY .
  yy  KEY_PART_1 PIC X(5).
  yy  KEY_PART_2 PIC X(5).

xx    ALTERNAT_KEY.
  yy  KEY_PART_2 PIC X(5).
  yy  KEY_PART_3 PIC X(5).
  yy  KEY_PART_4 PIC X(5).

Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Tue Nov 04, 2008 2:36 pm    Post subject: Reply to: Having more than one field as VSAM key
Reply with quote

Hey cool!!

Someone can help with VSAM embedded in COBOL program.

I suppose the keys neeed to be declared under file section of the data division in COBOL.
When I say
RECORD KEY IS <primary-key>
ALTERNATE KEY IS <alternate-key> , will COBOL not expect the <primary-key> and <alternate-key> to be defined in the File Section? If I declare it as mentioned in the above reply under file section, the field (which is part of both primary and alternate) will be repeated which may make file inconsistent.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Nov 04, 2008 6:16 pm    Post subject:
Reply with quote

What prevents you from declaring
Code:
          SELECT VSAM-FILE            ASSIGN TO VSAMFILE
                                      RECORD KEY VR-KEY
                                      ALTERNATE RECORD KEY VR-ALT-KEY
                                      ORGANIZATION INDEXED
                                      ACCESS DYNAMIC
                                      FILE STATUS IS VSAM-FILE-FS
                                                     VSAM-FILE-FULL
                                      .
and then
Code:
      FILE SECTION.
      FD  VSAM-FILE.
      01  VSAM-RECORD-01.
          05  VR-KEY                  PIC X(08).
          05  FILLER                  PIC X(72).

      01  VSAM-RECORD-02.
          05  FILLER                  PIC X(04).
          05  VR-ALT-KEY              PIC X(08).
          05  FILLER                  PIC X(68).

      WORKING-STORAGE SECTION.
      01  WS-VARIABLES.
          05  VSAM-FILE-FS            PIC 9(02).
          05  VSAM-FILE-FULL.
              10  VF-RETURN           PIC S9(04) COMP.
              10  VF-FUNCTION         PIC S9(04) COMP.
              10  VF-FEEDBACK         PIC S9(04) COMP.
As far as I know, there is no requirement that the RECORD KEY and ALTERNATE RECORD KEY clauses reside in the same 01 under the FD. As long as both are defined in the FD, they can be placed however you need them.

And yes I tested this code -- got 00 file status on open of the file.
Back to top
View user's profile Send private message
amitha

New User


Joined: 04 Nov 2008
Posts: 8
Location: Banglore

PostPosted: Wed Nov 05, 2008 8:42 am    Post subject:
Reply with quote

Thanks Buddy, for your patience in trying out and helping me. I have used something similar with the use of 'REDEFINES' statements. And that too worked. Since it was too late , i could not reply it here...

Thanks a lot for all of you for sharing the valuable ideas..

Happy Posting!!
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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