| Simplify Processing Files with Multiple Members |
|
|
| Written by Admin (Chamara) | ||
| May 05, 2009 at 01:06 PM | ||
|
Stop using OVRDBF commands.
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: FSource if e disk extmbr('*ALL')
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. c *hival setgt Source
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 *loval setll Source
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. |
||
| <Previous | Next> |
|---|