×
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.
b
On 15/01/2008, at 5:18 AM, James.Hawkins@xxxxxxxxxx wrote:
When performing a Read or Chain operation, is best practices to
reference
the record format name or the file name? Why?
I know what I do. I have seen commercial software do both. I have
seen
individual programmers do both.
The reason I pose the question is I am teaching a class in RPG (/
free, if
you care) at a community college this semester and prefer to teach
best
practices from the start.
Your thoughts?
The COBOL (and therefore standard data processing) view has always
been read the FILE and write the RECORD.
In RPG III I always used to use the RECORD for both reads and writes
based on the simple rationale that display files and printer files
(usually) have multiple record formats therefore you MUST specify
which one you are interested in. Logical files can have multiple
formats which (generally) require the format to be specified thus
leaving only physical files (and single-format logicals) as the only
files where you can CHOOSE to use file or record names. For
consistency I always used the format name for reads and writes and I
taught this rationale in my RPG classes.
This rationale also made the occasional read-from-file (such as when
coding an inactivity time-out) more obvious. The code is reading from
the FILE for a reason--examine it more closely.
However, since the advent of RPG IV and the file BIFs (%EOF, %FOUND, %
ERROR, %STATUS) which require the FILE name (if specified) I find the
code looks very ugly if it reads a FORMAT and then tests %EOF on the
FILE. I have since changed my rational for database tables only and
have gone (back) to the "standard" read FILE write FORMAT pattern.
Display and printer files still require the use of FORMAT. Multi-
format logical files can be processed by FILE but more often use
FORMAT. In my RPG IV classes I explain my new rationale.
I have not resolved the 'confusion' inherent in code that specifies
FILE but uses EXTFILE to specify a different file at run time. The
code references file ABC1234 but the run-time actually uses XYZ6789.
However, this is really no different from using OVRDBF to redirect I/
O so I can live with it.
Since you are TEACHING you should not simply say this is the way to
do it (best practice euphemism) but explain the different methods,
their advantages and disadvantages, point out the 'standard' pattern
and let the students decide which they prefer.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.