Question

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. 
Was it helpful?

Solution

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.

OTHER TIPS

Imagine a workstation file named ARINQDSP and an RPG program named ARINQ. If you edit ARINQDSP, say to add a new field to the display, and compile it, you will have a new record format (as explained by @WarrenT. If you CALL ARINQ, the OS will compare the record format stored in the program against the actual record format stored in the file. They are different, so CPF4131 is issued. Recompiling the RPG program will store the current record format ID in the program object (along with the current buffer layout!) and CALL ARINQ will now execute as expected. This is the most common cause of a level check error.

There is another reason this occurs: library list mismatch. Imagine the same sequence of events as above, only this time imagine doing the work in the development library. You've changed ARINQDSP and recompiled both the file and program. You have DEVELOPMENT at the top of your library list. Now you do this: CALL PRODUCTION/ARINQ. The OS will call the original program in the production library, but because of the library list, it will try to open ARINQDSP from the DEVELOPMENT library. The record format ID stored in the production program does not match the record format level ID stored in the development library's workstation file and boom: level check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top