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

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: