You are probably familiar with using the OVRDBF command to access a specific member in a file with multiple members. Or maybe you use it to access all the members by using the MBR(*ALL) parameter. But did you know that the same functionality is available directly in RPG by using the EXTMBR keyword on your file definition? Here's an example:
The EXTMBR keyword accepts *FIRST, *ALL, or specific member names. By utilizing this functionality, you can get around the need for using the OVRDBF command.
Also, if you are using the EXTMBR('*ALL') option, then you should be aware of how the SETGT and SETLL opcodes function when processing a file with more than one member. Using the SETGT opcode as shown below will read the first record of the next file member in the file.
c Read Source
Conversely, by using the SETLL opcode, you can return to the bottom (last record) of the previous member, as shown below.
c Readp Source
Although using these techniques can make processing files with multiple members much easier, there are a couple of things to keep in mind. For example, you will not be able to use the *hival with SETGT and expect that the next READ will fail (to exit from a loop, for instance). Also, unless you use the file information data structure (INFDS), you will not know which specific member is being processed.
Jeff Olen is a member of the AS/400 development team at Gauss Interprise, a content management software company located in Irvine, California. He can be reached by email at
LATEST COMMENTS
MC Press Online