IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reading VSAM file with Alternate Index/Key in CICS


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Thu Apr 02, 2009 11:16 am
Reply with quote

Hi,

I have a VSAM file with record length 80 and first 22 bytes as the primary key. I am using this file to read data and display it on the cics screen.
But now I have a requirement to build an alternate index and read data based on this new index (with duplicates).

The following are few queries:
1. Should I need to define this new PATH file in CICS region with a new CICS logical name.
2. Should I use the following to perform read operation:
New alternative index/key, New Path file name, Record layout of the BASE file, Length of the base file record.

EXEC CICS STARTBR
FILE(new PATH file)
RIDFLD(alternate key)
GTEQ
RESP(WSV-RESP)
END-EXEC

EXEC CICS READPREV
FILE(new PATH file)
INTO((record layout of base file))
LENGTH((record length of base file))
RIDFLD(alternate key)
RESP(WSV-RESP)
END-EXEC

EXEC CICS READNEXT
FILE(new PATH file)
INTO((record layout of base file))
RIDFLD(alternate key)
LENGTH((record length of base file))
RESP(WSV-RESP)
END-EXEC

Please advise.

Regards,
Manmohan
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 02, 2009 4:43 pm
Reply with quote

1. Yes; the PATH needs to have a CICS file definition so you can access it.
2. Sounds good to me -- nothing really unusual about reading by alternate index.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Apr 02, 2009 5:24 pm
Reply with quote

Is your alternate key unique or non-unique?

Regards,
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Thu Apr 02, 2009 6:10 pm
Reply with quote

Hi Bill,

Alternate key is non-unique.

Regards,
Manmohan
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Thu Apr 02, 2009 7:24 pm
Reply with quote

Also please let me know whether the PATH file should be defined in CICS or the ALTERNATE index file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 02, 2009 7:37 pm
Reply with quote

From the CICS System Definition Guide (with my added emphasis):
Quote:
Sometimes you may need to identify and access your records by a secondary or alternate key. With VSAM, you can build one or more alternate indexes over a single base data set, so that you do not need to keep multiple copies of the same information organized in different ways for different applications. Using this method, you create an alternate index path (or paths), that links the alternate index (or indexes) with the base. You can then use the alternate key to access the records by specifying the path as the data set to be accessed, that is by allocating the path data set to a CICS file.

When you create a path you give it a name of up to 44 characters, in the same way as a base data set. A CICS application program does not need to know whether it is accessing your data athrough a path or a base; except that it may be necessary to allow for duplicate keys if the alternate index was specified to have non-unique keys.
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Thu Apr 02, 2009 7:53 pm
Reply with quote

Thanks a ton for your timely and prudent assistance.

Regards,
Manmohan
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Fri Apr 03, 2009 2:30 pm
Reply with quote

Consider the BASE file having the following data:
PKey AKeys
<--> <----------------------------------->
0001 000A
0002 000A
0003 000A
0004 000A
0005 000A
0006 000A
0007 000B
0008 000B

Here 0001 is Primary Key and 000A is alternate Key.

The PATH file will have the following data:

AKey PKeys
<--> <----------------------------------->
000A 0001 0002 0003 0004 0005 0006
000B 0007 0008

In the above(PATH) file '000A' is the Alternate Key and 0001 and 0002 are corresponding primary keys

My CICS screen has only space to show 3 records.

So when I read from the Path file with Alternate key(000A),
I can display records having Primary Key 0001, 0002 and 0003.

How can I display next 3 records?
How CICS will understand that it should start from next record(0004) and display 0004, 0005 and 0006?
Assisting with a syntax code will be helpful.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Apr 03, 2009 2:33 pm
Reply with quote

ask Your support what is the standard method for displaying data in multiple screens

many organization have a standard paging program
( same user interaction standards across the applications )
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Fri Apr 03, 2009 2:43 pm
Reply with quote

Sorry for not writing the query properly.

I am using PF7 and PF8 keys to read previous and read next records. Like the PAGE UP and PAGE DOWN.

Once the user presses PF8 key, How can I tell CICS to read from last record (0004 in the above example).
With the current syntax of the readprev and readnext I can only pass the ALTERNATE KEY.

EXEC CICS READNEXT
FILE(new PATH file)
INTO((record layout of base file))
RIDFLD(alternate key)
LENGTH((record length of base file))
RESP(WSV-RESP)
END-EXEC

Where as in this case I also need to pass last Primary Key (from where it should start reading).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 03, 2009 4:49 pm
Reply with quote

Program logic is required. Pass the primary key you need to start with in the DFHCOMMAREA so you can use it to set the starting position for the next screen. Your program will have to do READNEXT until it finds that key and then proceed from there.

Unless, of course, your site has a standard way of doing this already and you're trying to reinvent the wheel there ...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top