2

When I compile an RPG program, I get the error shown below :

*RNF7408 30      1 The length of the input field does not match the definition of the field; specification is ignored.

The field mentioned as part of this error was EXITAX which is of size 15.2 in WR654F and 9.2 in DA595F. I was under assumption that this is due to two files(WR654F and DA595F) having one field with the same name (EXITAX) but different sizes declared in the F specs:

FWR654F    IF   E             DISK
FDA595F    O  A E           K DISK

But when I created another program with just the above two specs and *inlr = *on for sake of compilation, it worked fine and compiled successfully. So I don't understand why the original program is not compiling?

jmarkmurphy
  • 11,030
  • 31
  • 59

3 Answers3

3

I was able to reproduce the error, and the successful compile. You are correct in your assertion that the error is due to the field being defined differently in the two files. But it does not appear when you compile with just the file definitions and a return or *INLR = *ON. The RPG compiler apparently does not attempt to generate O specs for DA595F unless you actually write to the file. so in your test you need to add a write operation to the output record. Then you will see the error.

Just in case your next question is, "How do I fix it?" One way would be to read into and write from a data structure. Like this:

   dcl-ds file1ds        LikeRec(file1r: *input) Inz;
   dcl-ds file2ds        LikeRec(file2r: *output) Inz;

   read file1 file1ds;
   eval-corr file2ds = file1ds;
   write file2r file2ds;
jmarkmurphy
  • 11,030
  • 31
  • 59
  • Oh I see.. I just added the write and the error came up. Thanks for being very helpful as always, Mark! –  Jan 23 '17 at 16:53
  • Simply declaring a normal Datastructure works (or is this an externally described DS. Apologies for my lack of understanding on Fully free RPG)? I was under the impression that only an externally described DS or an I Spec would work. –  Jan 24 '17 at 04:26
  • You should really be using free format RPG. Free format became available in the 1990's, and makes you programs easier to read and code. No need for I or O specs. These data structures are based on the record format of a file defined in the `dcl-f` statement. I put in the second parameter which is required for data structures used in IO operations. – jmarkmurphy Jan 24 '17 at 12:43
  • Yes. Will definitely aim towards learning Fully free format RPG!. So far I have only used the flavor where only Calculations are written in Free format. –  Jan 24 '17 at 13:05
  • 1
    The data structures defined with LIKEREC are basically externally-described data structures. – Barbara Morris Jan 24 '17 at 15:00
  • Just to clarify some terminology and time frames: RPG IV became available in the 1990s. However, it initially did not have free format anything. It did have "extended factor 2". Free format C specs were introduced in 2001 with V5R1. The incarnation that is usually called "fully free RPG" was only available since late 2013, as part of an update to the 7.1 release. Further, despite the name, not everything is available in free format. However, as alluded to, the things that cannot be entered in free format are things that most programs can easily do without. – John Y Jan 24 '17 at 23:04
2

To prevent RPG from generating the I and O specs, add the QUALIFIED keyword to the files. That will also cause the record formats to be qualified by the file name. So instead of writing to DA595FMT, you would write to DA595F.DA595FMT.

Barbara Morris
  • 3,195
  • 8
  • 10
-1

QUALIFIED approach is better to avoid structural conflicts and saving resources from unnecessary data structure declarations.