× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Jerry,

As Scott says, use a program-described file.

Assuming you have 3 files called File1, File2 and File3:

FDATAFILE UF A F 5000 disk UsrOpn InfDS(FilDS)

D DTARCD e ds qualified extname(File1)
D FilDS DS qualified
D RcdFmt 261 270A

sFile = '*LIBL/' + parmFileName;
open(e) DATAFILE;
read(e) DATAFILE DTARCD;
select;
when FilDS.RcdFmt = 'RCD1';
// We're reading File1
when FilDS.RcdFmt = 'RCD2';
// We're reading File2
...

Just make sure that the record length in the F-spec line (where I have 5000
in my example) is the same as the actual record length and you'll be fine.

Rory

On Fri, Sep 17, 2010 at 10:53 AM, Jerry Adams <Jerry@xxxxxxxxxxxxxxx> wrote:

I have three tables that have exactly the same fields (by both name and
attribute); the only difference is the name of the record format, which
causes each one to have a unique record format identifier.

Without realizing this (or even thinking about it), I wrote a program to
process each table - but only defining one table in the program using the
USROPN and EXTFILE keywords. The subprocedure was being passed the name of
the "real" table I wanted for each pass and then OPENing it based upon the
EXTFILE(FileName) value. During testing is when it hit me (like a ton of
bricks) that each table had a different record format id.

I know that I can use OVRDBF with LVLCHK(*NO), but that doesn't work for
USROPN tables. I could not find a File Level keyword in the RPG IV manual
that would prevent this and MONITORing for the error would simply result in
the table not being opened.

The only alternatives that I have come up with are to either:

1. Define each table in the program and create three subprocedures

2. Rebuild the tables with the same record format name.

I don't like the latter, obviously, because it would affect other programs
already in production. I thought of using QCMDEXC in the program to
actually issue an OVRDBF, but I don't think this would work because I still
could not use a RENAME on the File spec.

So am I stuck with option #1? Or is there an alternative that I have
overlooked?

Thanks.

Jerry C. Adams
IBM System i Programmer/Analyst
To assert that the earth revolves around the sun is as erroneous as to
claim that Jesus was not born of a virgin. -Cardinal Bellarmine during the
trial of Galileo
--
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.