CPF3142: File not found
CPF3142 means a command couldn't find the database file it was given, either in the library named or anywhere on the job's library list. The message names the file and the library.
Other names for this code
Also written as CPF3142 file not found, MSGID CPF3142, file in library not found, CLRPFM CPF3142, MONMSG CPF3142.
What it means
CPF3142 is an escape message with the text "File &1 in library &3 not found." The Clear Physical File Member (CLRPFM) command lists it among its errors, so it turns up most in CL programs that clear work files.
When a command names a file, it either gives the library, as in ACCTLIB/PAYMAST, or leaves it to the job's library list (*LIBL). With a library given, the system looks only there. With *LIBL it searches each library on the list in order and stops at the first match. CPF3142 means neither search found a file with that name.
Many other commands report the same problem with CPF9812, "File &1 in library &2 not found." The meaning is the same. Only the sending command differs. A program that fails to find a file when it opens it gets a third message, CPF4101.
Common causes
- The library that holds the file isn't on the library list of the job that ran the command. Batch jobs are the usual case, because the job description or the SBMJOB command can give them a different list from the interactive session that was tested.
- The file name or library name is mistyped, or a program builds the name and got it wrong.
- The file hasn't been created yet. A job stream that creates a work file in one step and clears it in another fails here when the steps run out of order or the create step was skipped.
- The file was in QTEMP of another job. Each job has its own QTEMP, so a submitted job can't see the QTEMP files of the job that submitted it.
- The file is in an independent ASP and the job isn't using that ASP group, so its libraries are invisible to the job.
- The file was deleted or renamed, or it was a test copy that was removed.
How to find the problem
- Run DSPJOBLOG, put the cursor on CPF3142 and press F1 to see the file and library the command looked for.
- Find every copy of the file:
WRKOBJ OBJ(*ALL/PAYMAST) OBJTYPE(*FILE). If it lists nothing, the file doesn't exist on the system at all. - Compare the result with the job's library list. Run DSPLIBL in the job, or for a batch job look at the library list in its job log or in DSPJOB.
- For batch work, check where the list came from. DSPJOBD shows the INLLIBL of the job description, and the SBMJOB command's INLLIBL parameter decides whether the job takes the caller's list or the job description's.
- If the library sits in an independent ASP, check whether the job ran SETASPGRP, and whether the ASP device is varied on.
How to fix it
- Qualify the name with its library on the command, for example
CLRPFM FILE(ACCTLIB/, when the file always lives in the same place.PAYMAST) - Add the missing library to the job's library list with ADDLIBLE, or correct the INLLIBL of the job description used by the batch job.
- Create the file before the step that uses it, or check for it first with CHKOBJ and create it when CPF9801 comes back.
- If the file is optional for this step, monitor for it:
MONMSG MSGID(CPF3142)right after the command. - For files in an independent ASP, have the job run SETASPGRP before it touches them.
What it looks like
File PAYMAST in library ACCTLIB not found.
IBM documentation
IBM Display Message Descriptions (DSPMSGD). Use the documentation for your installed release.
This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.
Read the installed message description:
DSPMSGD MSGID(CPF3142) MSGF(QSYS/QCPFMSG)
Also inspect the full job log and second-level message text, including substitution values.
Related codes
Questions
What is the difference between CPF3142 and CPF9812?
They mean the same thing. CPF3142 comes from member commands such as CLRPFM, and CPF9812 comes from many other commands. Monitor for the one your command actually sends, which the job log shows.
The command works when I type it but fails in batch. Why?
The batch job has a different library list. Compare DSPLIBL in your session with the library list in the batch job log, and fix the job description or the SBMJOB INLLIBL value.
Does CPF3142 mean the library is missing too?
Not necessarily. Usually the library is fine and the file isn't in it. If the library itself doesn't exist, check it with DSPOBJD OBJ(QSYS/ACCTLIB) OBJTYPE(*LIB).