CPF9801: Object not found
CPF9801 means IBM i looked for an object and couldn't find it. Either it isn't in the library the command named, or, when the library is *LIBL, it isn't in any library on the job's library list.
Other names for this code
Also written as CPF9801 object not found, MSGID CPF9801, CPF9801 *LIBL, object in library not found, MONMSG CPF9801.
What it means
CPF9801 is an escape message from the IBM i message file QCPFMSG. Its text reads "Object &2 in library &3 not found", with the object name and library filled in. Commands that look up an object send it when the lookup fails. CHKOBJ is the best-known one, but many commands and system APIs use it too.
The library in the text tells you how the system searched. If it shows a real library name, the system looked in that one library only. If it shows *LIBL, the system went through every library on the job's library list in order and found nothing of that name and type.
The message says nothing about whether the object exists somewhere else. Very often it does, in a library that isn't on this job's list. A missing library gives CPF9810 instead, and a library you aren't allowed to use gives CPF9820.
CPF9801 isn't always a problem. Many CL programs run CHKOBJ followed by MONMSG MSGID(CPF9801) on purpose, to test whether an object exists before they create it. If the program monitored the message, it shows in the job log but nothing failed. It only matters when it is followed by a function check (CPF9999) or the job ends abnormally.
Common causes
- The library that holds the object isn't on the job's library list. This is the most common cause, and it hits batch jobs most, because they take their library list from the job description or the SBMJOB command rather than from the user's interactive session.
- The object or library name is misspelled, or the command names the wrong library, such as a test library in a production job.
- The object was deleted, renamed or moved, or the step that creates it never ran. Work files in QTEMP are a classic case, because QTEMP belongs to one job and is empty in every new job.
- An object of that name exists, but it is a different type from the one the command asked for (OBJTYPE).
- The object lives in an independent ASP, and the job isn't using that ASP group, so the library isn't visible to it.
How to find the problem
- Run DSPJOBLOG (or press F10 on the message display to show all messages). Put the cursor on CPF9801 and press F1. The help shows the object and library, and F9 shows the program and statement that received it.
- Run
WRKOBJ OBJ(*ALL/PAYMAST)to list every library on the system that holds an object of that name, with its type. - Run DSPLIBL in the same kind of job that failed and compare its list with the library WRKOBJ found. For a batch job, look at the library list in its job log, or check the job description with DSPJOBD and the INLLIBL value on the SBMJOB command.
- If you want IBM's full wording,
DSPMSGD RANGE(CPF9801) MSGF(QSYS/shows the message description on your own system.QCPFMSG)
How to fix it
- Add the missing library for the job with
ADDLIBLE LIB(ACCTLIB), or change the order with EDTLIBL. To make it last, change the job description's initial library list with CHGJOBD, or ask your administrator about the QUSRLIBL system value, which affects every job that uses it. - Qualify the name with the right library in the command or program, instead of relying on *LIBL.
- Create or restore the object if it really is gone, and check that any earlier step that builds it ran in the same job.
- If the program is meant to test for the object, monitor for the message right after the command, for example
MONMSG MSGID(CPF9801) EXEC(GOTO CREATE). - For an independent ASP, make sure it is available, then set the job's ASP group with SETASPGRP.
What it looks like
Object PAYMAST in library *LIBL not found. Object 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(CPF9801) 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 CPF9801 and CPF9810?
CPF9810 means the library itself doesn't exist. CPF9801 means the library was fine but the object wasn't in it, or wasn't in any library on the library list.
Why does my program find the object interactively but get CPF9801 in batch?
Because the two jobs have different library lists. A batch job gets its list from its job description or from SBMJOB, so a library you added in your own session isn't there unless the submit passes it on.
Is CPF9801 in a job log always an error?
No. If a program monitored it with MONMSG, it was expected and handled. Look for a CPF9999 function check or an abnormal end after it before treating it as the cause.