Capturing the relative record number
In an RPGLE program, while chaining to or reading an externally defined logical file, I would like to capture its relative record number on successful hits. Is it possible to do this? If so, how is this done?
Here is an example of how to do that. In your file definition, you need to specify the name of the file information data structure. In this example, once you do a read from MYFILE, MYRRN is automatically populated with the relative record number. I don't know if it's still true or not, but at one time there was a (bug/quirk/feature) in RPG where if you did not do a SETLL to the file, it could not be guaranteed that the file information data structure would populate correctly. If you're going to do this, it doesn't hurt to always do a SETLL in your program, even if you're just positioning to the beginning of the file.
Pmt SeqNbr FName Type Desig EOF A/U Seq Fmt Lmts RAT Device Keywords FX 0067.00 MYFILE I F E K DISK INFDS(MYDDS) Pmt SeqNbr Name E S/U Type From To/Length DataType DecPos D 0119.00 MYDDS DS D 0120.00 MYRRN 397 400 B 0 Pmt SeqNbr Lvl N01 Factor 1 OpCode&Ext Factor 2 Result C 0154.01 *LOVAL SETLL MYFILE
================================== MORE INFORMATION ON THIS TOPIC ==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.