TechTip: Using EXTMBR(*ALL) in RPG

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
If you need to navigate through a multiple-member file in RPG, but you don't know the member names ahead of time, then you have a couple of options:

1) Before your program opens the file, specify the Override Database File (OVRDBF) CL command, with overriding member *ALL:

OVRDBF FILE(myfile) MBR(*ALL)


2) Starting with V5R1, you can skip the OVRDBF CL command, and just specify EXTMBR('*ALL') directly on your RPG file specification:

FMYFILE    IF  E            K disk    extmbr('*ALL')


Be sure to include the single quotes in the RPG version. In either case, your program will first open the chronologically first member in the file. To close this member and open the next member in chronological order, code the following:

setll *end MYFILE;
read MYFILE;


To close this member and open the previous member in chronological order, code the following:

setll *start MYFILE;
readp MYFILE;


Be aware that your program moves through members in the chronological order that you added the members to the file. This order may differ from the Work with Members Using PDM (WRKMBRPDM) list order, which is alphabetical order.

The RPG file information data structure subfield position 129-138 contains the name of the current member your program has open. When your program closes one member and opens the chronologically adjacent member, RPG updates this subfield, and OS/400 writes informational message CPI5209 to your job log:

Moved from member ########## to member ##########.


Gene Gaunt is the Director of Information Services for LaHousse-Bartlett Disability Management, dba RehabPlans and ReviewWorks. He lives in Ann Arbor, Michigan. Email him at This email address is being protected from spambots. You need JavaScript enabled to view it..

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$