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

Problem doing READPREV


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

New User


Joined: 21 Feb 2009
Posts: 36
Location: South Portland, Maine

PostPosted: Tue May 26, 2009 8:44 am
Reply with quote

    I have a partial key say:

    Code:
    10  WS-KEY.
         15    WS-A   PIC 9(06)
         15    WS-B   PIC 9(12)
         15    WS-C  REDEFINES WS-B
                        20  WS-C1    PIC 9(06)
                        20  FILLER   PIC X(06)


    Now i move a value to a ws-a(value found in file). i move "999999999999" to ws-b.

    On doing ,

    STARTBR -> respcode 0
    READPREV -> respcode 13

    Again,
    STARTBR -> respcode 0
    READNEXT -> respcode 0
    READPREV -> respcode 0
    READPREV -> respcode 0

    This fetches the last valid record

    Why is that i able to do READNEXT and not a READPREV with the partial key do fetch the last valid record?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue May 26, 2009 8:54 am
Reply with quote

Hello,

What is in WS-A?

If you do not control the value, your process will be out of control. . .
Back to top
View user's profile Send private message
ganeshprasanna

New User


Joined: 21 Feb 2009
Posts: 36
Location: South Portland, Maine

PostPosted: Tue May 26, 2009 8:59 am
Reply with quote

File VALUES


Code:
WS-A              WS-B
1111            111111111111
1111            222222222222
1234            111111111111
1234            222222222222
1234            333333333333
1234            444444444444
5555            111111111111


Now ,

With WS-A as 1234 and WS-B as "999999999999", Doing a STARTBR(respcode -> 0)
READPREV (respcode ->13)


Why is this so?

Ideally it should have fetched the record

WS-A 1234 WS-B 444444444444

Can you please help me out?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue May 26, 2009 9:19 am
Reply with quote

Hello,

You are showing 4-digit values but the key is 6.

How is the data stored 001234 or 123400.

You are also intermixing character data with numeric fields. Generally a bad practice. Suggest you move true numeric values to numeric fields rather than alpha characters that happen to contain some numbers.

Suggest you repro the vsam file and look at the actual data and make sure that the way you are looking for data is the same as the way it is stored.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 26, 2009 4:54 pm
Reply with quote

what is the actual code of your STARTBR?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue May 26, 2009 4:55 pm
Reply with quote

From the CICS Application Programming Reference:
Quote:
If you include a READPREV command immediately following a STARTBR command, your STARTBR command RIDFLD must specify the key of a record that exists on the data set; otherwise the NOTFND condition will occur.

A READPREV command following a READNEXT, or a STARTBR or RESETBR that did not specify a 'last' key value, is treated as though the RIDFLD value had been modified and results in a reposition (as above).
The manuals are pretty thorough when searched.
Back to top
View user's profile Send private message
ganeshprasanna

New User


Joined: 21 Feb 2009
Posts: 36
Location: South Portland, Maine

PostPosted: Tue May 26, 2009 5:32 pm
Reply with quote

Thank you everyone for your valuable inputs.
Back to top
View user's profile Send private message
ganeshprasanna

New User


Joined: 21 Feb 2009
Posts: 36
Location: South Portland, Maine

PostPosted: Tue May 26, 2009 5:40 pm
Reply with quote

One last query..

if i move HIGH-VALUES to the complete KEY and then,

STARTBR
READPREV


this works fine. How is this possible?

Is it because STARTBR points at the last record from the file and READPREV reads that last record?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue May 26, 2009 5:49 pm
Reply with quote

Was the file loaded with a HIGH-VALUES record initially? If so, then the RIDFLD points to a file record and the READPREV would work perfectly fine per the manual quote I posted above.
Back to top
View user's profile Send private message
ganeshprasanna

New User


Joined: 21 Feb 2009
Posts: 36
Location: South Portland, Maine

PostPosted: Wed May 27, 2009 8:27 am
Reply with quote

Yes the file is loaded initially with HIGH-VALUES.

Thanks for your time.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed May 27, 2009 4:52 pm
Reply with quote

Glad to hear your questions are resolved.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top