Problem solve Get help with specific problems with your technologies, process and projects.

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.

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.