Stop using OVRDBF commands.
We are familiar with using the OVRDBF command to access a specific member in a file with multiple members. Or maybe we use it to access all the members by using the MBR(*ALL) parameter. But the same functionality is available directly in RPG by using the EXTMBR keyword on the 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, we can get around the need for using the OVRDBF command.
Also, if we are using the EXTMBR('*ALL') option, then we 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 *hival setgt Source
c Read Source
Conversely, by using the SETLL opcode, we 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, we 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 we use the file information data structure (INFDS), we will not know which specific member is being processed.
Subscribe to:
Post Comments (Atom)
2 comments:
Very Helpful detail... Thanx...
can you proviede the example for this
Post a Comment