user3311539
user3311539

Reputation:

RPG compilation error

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?

Upvotes: 2

Views: 4829

Answers (3)

Syed Ali
Syed Ali

Reputation: 1

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

Upvotes: -1

Barbara Morris
Barbara Morris

Reputation: 3664

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.

Upvotes: 2

jmarkmurphy
jmarkmurphy

Reputation: 11473

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;

Upvotes: 3

Related Questions