. . . for OPEN, but would it be possible to allow file name for all
opcodes . . .
If I can weigh in with my 0.02
I find it more convenient to use Record-Format-Names throughout the
RPG source - as opposed to File-Names.
I find it preferable to define the File-Name once in the File Specs,
and then use the Rcd-Format-Name elsewhere in all other RPGLE source
lines. My Reasons:
(1)
When Refactoring code, I often change the logical-file currently in use
to a different logical-file, one that now omits certain new types of
data-records that are now being placed in the underlying file. In
theory, these simpler refactorings of programs which use
Record-Format-Name exclusively will then only need their "F" spec
changed. (This assumes the common practice of Select-Omit-Logicals and
Alternate-Indexes re-using the Record-Format-Name of the underlying
Physical.)
When "FileName" is used in RPG op-codes, several source lines which are
buried in the RPG codebase (and possibly Copybooks) must be changed.
Their change-dates on the source lines also change, so our
Change-Mgmt-System reports these lines as changes even though
program-logic is unchanged. The alternative - using OVRDBF which
eliminates RPG code changes - is often confusing and error-prone,
especially with RPG invoking RPG.
(2)
In my shell programs for simple CRUD functions, I define the "F" Spec
and a couple of "D" specs with a format name of "Database". Thereafter,
throughout the RPG code, the RPG opcodes always refer to Read, Write,
Update, Delete "Database". The Shell programs for CRUD are identical
except for the lines near the top of the program.
FCUPRBCNPK UF A E K DISK
F RENAME( CURRBCNPK : Database )
FCUDRBCNP CF E WORKSTN
F SFILE(SFL02:rrn02)
F INFDS(Screen_Infds)
D DataDS E DS Extname( CUPRBCNPK )
D SaveDS E DS Extname( CUPRBCNPK )
D Prefix('S')
D KeysDS DS LikeRec(Database : *KEY )
But then when canceling an Update operation, unfortunately I have to
swing back into using the Actual File Name . . .
Unlock CUPRBCNPK ;
(3)
In the "D" specs, the newer LikeDS and LikeFile keywords seem to be
referring to Rcd-Format-Names (and their cousins data structures) and
not so much File-Names. It is my guess that the direction the
compiler-writers going onward will be more Rcd-Format-Name driven. This
does make more sense - Files are containers (System-Objects), but
Formats are collections (mappings) of Fields.
- John Voris
As an Amazon Associate we earn from qualifying purchases.