View previous topic :: View next topic
|
Author |
Message |
Jeevitha_mainframe
New User
Joined: 17 May 2010 Posts: 4 Location: chennai
|
|
|
|
Hi,
I am having requirement to find the last record in the KSDS VSAM file. Below is my requirement.
In KSDS VSAM file, having the key value of 18 as (USERID(7), DATE(5) COUNT(6))
below is my input.
Code: |
ABCD00110137000001
ABCD00110137000002
ABCD00110137000003
ABCD00110137000004
ABCD00110137000005
ABCD00210137000001
ABCD00210137000002
ABCD00210137000003
ABCD00210137000004
ABCD00310137000001
ABCD00310137000002
ABCD00310137000003
|
From this input i want to insert the record with the next count by all user ids.
Eg:
Code: |
ABCD00110137000001
ABCD00110137000002
ABCD00110137000003
ABCD00110137000004
ABCD00110137000005
ABCD00110137000006 -- New One
ABCD00210137000001
ABCD00210137000002
ABCD00210137000003
ABCD00210137000004
ABCD00210137000005 -- New One
ABCD00210137000006 -- New One
ABCD00210137000007 -- New One
ABCD00310137000001
ABCD00310137000002
ABCD00310137000003
ABCD00310137000004 -- New One
ABCD00310137000005 -- New One
|
I want to fetch the last record count of the each user id. now i am able to fetch only for the first two user ids. but not able fetch the last count of the last user id coz of the end of file.
Please help me out and let me know for any queries.
Thanks,
Jeevitha |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
but not able fetch the last count of the last user id coz of the end of file. |
what is the problem you you facing?
Show the logic you are using? |
|
Back to top |
|
|
Jeevitha_mainframe
New User
Joined: 17 May 2010 Posts: 4 Location: chennai
|
|
|
|
Hi,
To fetch the last count i have used the below logic.
For EG: i want to fetch the last record of ABCD001 this userid. So i have used
MOVE USER-ID TO WS-USERID.
MOVE 99999999999 TO WS-KEY(8:11).
EXEC CICS STARTBR
DATASET ('VSAM FILE')
RESP (WS-CD)
RIDFLD (WS-KEY)
KEYLENGTH (18)
GTEQ
END-EXEC.
(It will point the last record of the ABCD001 user id. After that i readnext the VSAM file until for the next userid)
EXEC CICS READNEXT
DATASET ('VSAM FILE')
INTO (WS-MAX)
RIDFLD (WS-KEY)
END-EXEC.
it will read the first record of the next user id. So i have done read prev two times for fetching the last record.
The problem is:
It working fine for the user first two userid in the above example. its not working for the third user because of the endof file.
once eof has reached its trying to read the next record. So getting the responsible code as 13(record not found).
How to find the last record count for the last user id? Please help me out.
Thanks,
Jeevitha |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You could (1) write a HIGH-VALUES record to your KSDS file to prevent end of file on data records (which could have other impacts if programs are not expecting this record), or (2) use the response (not responsible) code in your READNEXT command and when you get end-of-file then you have the count you need. |
|
Back to top |
|
|
Jeevitha_mainframe
New User
Joined: 17 May 2010 Posts: 4 Location: chennai
|
|
|
|
Hi,
I am facing the problem in STARTBR itself, already i have moved 99999999999 to the key values. So when i tried to do the STARTBR in the endof file, getting responsible code as 13(record not found).
i have used the below logic for the endof file record
When the record is not found, i have moved the 00000000000 to the key and start to read the file until highvalues. So when i get responsible code 20(ENDFILE) moving the record count and adding 1 to count. its working fine.
But unneccesarily we need to read all the records until reach the high values. Please let me know any other way without reading all the records to reach end of file.
Thanks,
Jeevitha |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Is your STARTBR using GE? If not, you must have a key that matches your all '9's value to not get the 13 response code. With a HIGH-VALUES record in the file, and GE specified, the HIGH-VALUES record will be returned for the STARTBR and a READNEXT - READPREV - READPREV sequence will return the last actual record in the file.
Note that I specified a record with key of HIGH-VALUES; your post mentions a record of all '9's. These are very different records, in case you are not aware of the difference. |
|
Back to top |
|
|
Jeevitha_mainframe
New User
Joined: 17 May 2010 Posts: 4 Location: chennai
|
|
|
|
Hi,
I am using GE in STARTBR. if i have used move high-values to the key with GE specified, and READNEXT - READPREV - READPREV sequence will not return the last actual record in the file. thats why i have moved '99999999999' nd READNEXT - READPREV - READPREV sequence will return the last actual record in the file.
Thanks,
Jeevitha |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, because you have an all 9's record. . .
If the 9's record is removed, your code will have the same result as the non-existent high-values execution. . . |
|
Back to top |
|
|
|