RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Simplify Processing Files with Multiple Members Print E-mail
User Rating: / 0
PoorBest 
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.

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     *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>