What are the possible reasons for CPF4131 to be appearing on a file in a program.
And how do we go about resolving this?
Message . . . . : Error message CPF4131 appeared during OPEN for file
TEST (C S D F).
Cause . . . . . : RPG procedure TEST2 in program TESTLIB/TEST2
received the message CPF4131 while performing an implicit OPEN operation on
file SOURCE. The actual file is SOURCE.
It's a record format level check. This means that the record format in the file you are opening does not have the same format level ID that was found when the program was compiled. In other words there is something different in the layout of the fields in the record. Perhaps you the file layout has been changed, if so, then you probably will want to recompile your RPG program.
The ID is computed as hash of the number & order of all fields in a record, with their names, and any attributes that could affect how fields are stored or retrieved from the record buffer by a program. So field name, data type, length, field position are examples of what can affect the ID, but column headings or field text do not.
In general, you will want to learn how to look at your job log to look at prior messages to see what has caused a problem. DSPJOB or WRKJOB is perhaps the most common method, selecting option 10, then pressing F10 to see low level messages, & F18 (shift F6) to go to the end of the list, and page back up.