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
 

 

How to find the last record in VSAM file using specific key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
rashmirgowda

New User


Joined: 18 Jun 2008
Posts: 25
Location: india

PostPosted: Fri Apr 30, 2010 6:34 pm    Post subject: How to find the last record in VSAM file using specific key
Reply with quote

Hi,

I am having a VSAM file with the KEY LENGTH of 18.For EG.,the data looks like below:

NA0000010119000198
NA0000010119000199
NA0000010119000200
NA0000010119000201
NA0000010119000202
NA0000010119000203
NA0000010119000204
NT0000010119000001
NT0000010119000002
NT0000010119000003

The first 7 characters will be USER-ID,next 5 characters will be date which will be in julian format and the next 6 characters will be counter

I want to fetch the last record of userid NA00000 directly.I tried by moving HIGH-VALUES to the remaining of the key and issued STARTBR command and READPREV.But i am getting RESP-CD as 16 with GENERIC option.


Code:
EXEC CICS STARTBR                   
           DATASET   ('SHEETS')     
           RESP      (WS-RESP-CD)   
           RIDFLD    (WS-MSKEY)     
           GENERIC                     
           KEYLENGTH (18)           
      END-EXEC.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 30, 2010 6:42 pm    Post subject:
Reply with quote

why not GTE NA0000099999999999 without the GENERIC?
Back to top
View user's profile Send private message
rashmirgowda

New User


Joined: 18 Jun 2008
Posts: 25
Location: india

PostPosted: Fri Apr 30, 2010 7:07 pm    Post subject: Reply to: How to find the last record in VSAM file using spe
Reply with quote

Hi,

I checked by giving the key as 'NA0000099999999999' in STARTBR and it is successful.But i am getting as Record Not Found error in READPREV inorder to get the last record.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Apr 30, 2010 7:51 pm    Post subject:
Reply with quote

The CICS manual says ( concerning READPREV ):

"A generic key may not be specified, nor may a browse that was started with the GENERIC option include a READPREV command."


Suggest that you issue a READNEXT immediately following the STARTBR, after which you can then issue the READPREV to retrieve the record you seek.
Back to top
View user's profile Send private message
rashmirgowda

New User


Joined: 18 Jun 2008
Posts: 25
Location: india

PostPosted: Fri Apr 30, 2010 8:24 pm    Post subject: Reply to: How to find the last record in VSAM file using spe
Reply with quote

Hi,

I have tried with the Generic option in STARTBR by passing the key as 'NA0000099999999999' but getting RESP-CD as 16.

Also tried with using the same key value with GTEQ option in STARTBR is successful and used READNEXT and READPREV immediately. But it is fetching the next record i.e., NT0000010119000001 instead of NA0000010119000204.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Apr 30, 2010 8:59 pm    Post subject:
Reply with quote

If you do a READNEXT, the READPREV will get that record again. A second READPREV should retrieve the record you want.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Apr 30, 2010 9:08 pm    Post subject:
Reply with quote

rashmirgowda wrote:
I tried by moving HIGH-VALUES to the remaining of the key and issued STARTBR command and READPREV.But i am getting RESP-CD as 16 with GENERIC option.
16 is INVREQ.
Application Programming Reference wrote:
INVREQ
RESP2 values: 25 - The KEYLENGTH and GENERIC options are specified, and the length defined for the data set to which this file specified in the KEYLENGTH option is greater than or equal to the length of a full key.
Try reading the manual.
Application Programming Guide wrote:
To position the browse at the last record in the file, ready for a backward browse, specify a RIDFLD of X'FF' characters. This applies to starting a browse of a KSDS, ESDS, or RRDS. For a standard ESDS, specify the RBA option. For an extended ESDS, specify the XRBA option. For an RRDS, specify the RRN option.
The above seems to imply no generic, no smaller keylength, followed with a readprev.
Back to top
View user's profile Send private message
rashmirgowda

New User


Joined: 18 Jun 2008
Posts: 25
Location: india

PostPosted: Fri Apr 30, 2010 9:26 pm    Post subject: Reply to: How to find the last record in VSAM file using spe
Reply with quote

Thanks All, It worked.I have used GTEQ in STARTBR followed by READNEXT and two READPREV.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Apr 30, 2010 9:47 pm    Post subject: Reply to: How to find the last record in VSAM file using spe
Reply with quote

If you have access to IBM transaction CECI, you can educate yourself regarding CICS commands, options, keywords, etc.

It's hands-on, intuitive (for the most part) and more comprehensive than a manual.

Normally, CECI is only available in non-Production environments.

I would hope this is a true statement in your shop. icon_eek.gif

Check with your CICS Tech Support and/or CICS Sysprog(s) for access and usage.

You can also find documentation in the current version/release of your CICS Supplied Transactions manual.

Bill
Back to top
View user's profile Send private message
Rogerio Ferreira Coelho

New User


Joined: 13 Jun 2007
Posts: 11
Location: Sao Paulo - Brazil

PostPosted: Sat May 01, 2010 12:02 am    Post subject: Reply to: How to find the last record in VSAM file using spe
Reply with quote

Hi,

You don't can user GENERIC, do like this sample:
STARTBR
READNEXT
READPREV
READPREV - HERE ARE THE RECORD YOU WANT: icon_eek.gif

I'm not sure why, but you need do 2 reaprev, after READNEXT

RECORD KEY
SRFA201011601109300070638
SRFA201011601129050070985
SRFA201011601135190071089
SRFA201011601135240071098
SRFA201011601305470071730
SRFA201011601320130072280
SRFA201011601334130072633
SRFA201011601334170072641
SRFA201011601334220072649
SRFA201011800907200009474
SRFA201011801045100010105
SRFA201011801050460010155


STARTBR FILE(SRCSH1) RI(&RI)
STATUS: COMMAND EXECUTION COMPLETE NAME=
EXEC CICS STARTBR
File( 'SRCSH1 ' )
< Sysid() >
RIdfld( 'SRFA2010116011...........' ) The key has completed with x'FF'
< Keylength() < GEneric > >
< REqid( +00000 ) >
< RBa | Xrba | RRn | DEBRec | DEBKey >
< GTeq | Equal >

RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000


READNEXT FILE(SRCSH1) RI(&RI)
STATUS: COMMAND EXECUTION COMPLETE NAME=
EXEC CICS READNext
File( 'SRCSH1 ' )
< SYsid() >
( SEt() | Into( 'SRFA201011601305470071730<CASO><REG001>0010010000' ... ) )
< Length( +11484 ) >
RIdfld( 'SRFA201011601305470071730' ) The next record after
< Keylength() >
< REQid( +00000 ) >
< RBa | Xrba | RRn >
< UNcommitted | Consistent | REPeatable | UPdate Token() >
< Nosuspend >

RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000


READPREV FILE(SRCSH1) RI(&RI)
STATUS: COMMAND EXECUTION COMPLETE NAME=
EXEC CICS READPrev
File( 'SRCSH1 ' )
< SYsid() >
( SEt() | Into( 'SRFA201011601305470071730<CASO><REG001>0010010000' ... )
< Length( +11484 ) >
RIdfld( 'SRFA201011601305470071730' ) The same record
< Keylength() >
< REQid( +00000 ) >
< RBa | Xrba | RRn >
< UNcommitted | Consistent | REPeatable | UPdate Token() >
< Nosuspend >

RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000


READPREV FILE(SRCSH1) RI(&RI)
STATUS: COMMAND EXECUTION COMPLETE NAME=
EXEC CICS READPrev
File( 'SRCSH1 ' )
< SYsid() >
( SEt() | Into( 'SRFA201011601135240071098<CASO><REG001>0010010000' ... )
< Length( +11067 ) >
RIdfld( 'SRFA201011601135240071098' ) And here you have
< Keylength() >
< REQid( +00000 ) >
< RBa | Xrba | RRn >
< UNcommitted | Consistent | REPeatable | UPdate Token() >
< Nosuspend >

RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat May 01, 2010 1:43 am    Post subject:
Reply with quote

Hello,

Quote:
I'm not sure why, but you need do 2 reaprev, after READNEXT
For positioning. It is a feature. . . icon_smile.gif
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 -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


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