× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 25-May-2010 01:31, Gangasani, Bhargava wrote:

Using CLP I can read a specific RRN/ Key record using below code.

DCLF Z5PFILEP
OVRDBF FILE(Z5PFILEP) TOFILE(Z5PFILEP) +
POSITION(*RRN 4) SHARE(*NO)
RCVF

Question is: I can place my pointer at *END of file as

OVRDBF FILE(Z5PFILEP) TOFILE(Z5PFILEP) +
POSITION(*END) SHARE(*NO)

But How I can read the previous record. That is the Last record
of the file.


If the open can be shared, then write an RPG program that opens a program described file named THELASTROW for input only BLOCK(*NO), positions to *END using SETLL, reads previous twice, then returns without closing the file; also having coded for the special cases of less than three rows, to effect position at *START for one row, and effect read on the first row for when there are two rows. In the CLP:

<code>

dclf Z5PFILEP
ovrdbf Z5PFILEP TOFILE(Z5PFILEP) share(*yes) seqonly(*no) /* +
// POSITION() optional; allow RPG to position */
ovrdbf TheLastRow TOFILE(Z5PFILEP) share(*yes) lvlchk(*no) /* +
// Not an actual file, just a name for RPG to declare */
rcvf /* CL opens shared lets RPG position w/ shared ODP */
monmsg cpf0864 exec(goto nodata) /* handle empty file in CL */
call RPGpgmNm /* RPG shares open, positions, leaves open */
rcvf /* read last record */
dostuff: /* CL has data from last row with the last row */
/* do whatever with data from last row, then optionally: */
rcvf /* get CL to close A; assuming no new rows added */
monmsg cpf0864 exec(rcvmsg pgmq(*same) msgtype(*excp) rmv(*YES))
rclrsc /* Effect RPG close; better: use USROPN in RPG, */
/* and code a special invocation to effect CLOSE */

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.