Sometimes an ILE RPG program needs to operate on several different files serially (e.g., a print utility that processes...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
all the data members of a particular file object), opening and closing each file in succession. In these cases, you often want to avoid the overhead of program initiation and instead just open each file in turn within the program. But to do so, you must override the database file using the OVRDBF command, which normally requires the existing CL program.
You can, however, execute the OVRDBF command within the RPGLE program using the QCMDEXC API. In either case we are taking the help of another program to override the file.
Can't we do this with out using any program or even without using the OVRDBF command? The answer is yes; we can achieve this in V5R1 using EXTFILE and EXTMBR operation codes.
Let us consider a file FILE1, which is having three members say MBR1, MBR2 and MBR3. Now I want to process all members' data in a single program with out using OVRDBF, how we can do? See the following sample code.
FFile1 if e Disk Extfile(FilNam) ExtMbr(MbrNam) F UsrOpn * D FilNam s 10a Inz D MbrNam s 10a Inz * * Process first member data. * C Eval FilNam = 'FILE1' C Eval MbrNam = 'MBR1' * C Open File1 C Read File1 * C DoW Not %Eof(File1) C C C C EndDo C Close File1 * * Process second member data. * C Eval FilNam = 'FILE1' C Eval MbrNam = 'MBR2' * C Open File1 C Read File1 * C DoW Not %Eof(File1) C C C C EndDo C Close File1 * * Process Third member data. * C Eval FilNam = 'FILE1' C Eval MbrNam = 'MBR3' * C Open File1 C Read File1 * C DoW Not %Eof(File1) C C C C EndDo C Close File1
With this code we can override the files without using the OVRDBF command and QCMDEXC API.
All these are BIG changes in RPG Land!
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.