Ask the Expert

Getting the RRN value to decrease by one

I'm accessing a keyed PF using RRN (RECNO). Suppose the PF has initially 9 records. I am adding a record in this PF after using the INZPFM command, since you can't add records in a PF accessed by RRN unless the RRN already exists in the PF. Now the value of the RRN is 10.

When I delete a record, the number of records in the PF is 9, but the value of RRN is still 10. What I need is this: When I delete a record in this PF, the RRN value should get decremented by 1, i.e. equal to the number of record in the PF. This is not happening right now. The RRN does not get decremented. I would appreciate it a lot if someone could help me in achieving this.

You must change your physical file to reuse deleted records value to *YES and Force Ratio to 1. Beware that if you delete record 4 and there are 9 records in the file, it is possible that the next record could be 4 and equally possible that the record number could be 10 depending on how the operating system handles the file. You should check the language reference (RPG/Cobol/C) and read about record blocking and the FEOD opcode to force the records to disk.

This was first published in April 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: