Can someone advise how to position a file so the last record in keyed
sequence can be read in Cobol?
I've tried START with a key value higher than the last actual key on file
with teh ntent to READ PRIOR after that, but you get INVALID KEY.
START allows only 'equal to' or 'greater or equal to', there is no 'less
than or equal to' so every attempted START fails with no valid record
position.
I hope it's something stupid I'm missing.
Thanks!
Bob
Bob Lepp schrieb:
> Never had to do this before....
>
> Can someone advise how to position a file so the last record in keyed
> sequence can be read in Cobol?
>
READ PRIOR ....
IF NO-RECORD
READ LAST .....
END-IF
If this is something for just after open of the file, both OVRDBF and
POSDBF can give this. Examples:
> OVRDBF FILE(THEFILE) TOFILE(*FILE) POSITION(*KEYBE) SHARE(*YES)
POSITION(*KEYBE 2 KEYEDFMT 'LARGEST KEY VALUE PLUS THE CHARACTER X')
/* If the key value is replaced by a variable name, it is best declared
one larger than the key length, and have a non-blank as the last byte */
> OVRDBF KEYEDFILE *FILE SHARE(*YES)
> OPNDBF KEYEDFILE *INP ACCPTH(*FILE)
> POSDBF KEYEDFILE *END
The latter method can be used at any time after open, repeatedly using the
POSDBF to establish position, given the shared open.
http://publib.boulder.ibm.com:80/cgi-bin/bookmgr/BOOKS/QB3AG302/6.1.7.7.4#HDRFILEPOS
notes an extension for "dynamic access" using READ LAST. This may accomplish above
for a keyed open.
Regards, Chuck
All comments provided "as is" with no warranties of any kind whatsoever.
Charles R. Pence <crp...@vnet.ibm.com> wrote in message
news:3A6F3674...@vnet.ibm.com...