CPF0001: Error found on command
CPF0001 means an IBM i command was stopped before it ran because the system found errors while checking it. The text reads "Error found on <command> command." The actual problem is described by the diagnostic messages just before it in the job log.
Other names for this code
Also written as MSGCPF0001, CPF0001 error found on command, error found on command AS400, iSeries CPF0001, CPF0001 SBMJOB, CPF0001 function check.
What it means
Before a command runs, IBM i checks it. It checks that the parameter values are valid for their types and lists, and it can call a validity checking program that the command's author wrote. Each problem it finds is sent as a diagnostic message, often a CPD message. When the checking is done and errors were found, the system sends CPF0001 as an escape message, naming the command.
So CPF0001 is a summary, not a cause. It means "this command didn't run". The diagnostics before it say why. IBM's own technote for one case shows CPD0037 (automatic or selective prompting not allowed) followed by CPF0001. A CL program had ?? prompting in a command and was run in batch, where prompting isn't possible.
In a CL program CPF0001 often turns into a function check if nothing monitors for it. In an interactive session it appears on the message line.
Common causes
- A parameter value isn't valid, such as a name with a blank in it, a value that's too long, or a value not in the allowed list. A CL variable built with *BCAT that puts a space into a qualified name is a common example.
- A command with prompting characters (
?or??) was run in a batch job. - A command's own validity checking program rejected the values. These send CPD0006 or their own messages before CPF0001.
- Required parameters are missing, or two parameters can't be used together.
How to find the problem
- Run
DSPJOBLOG, press F10 to show detailed messages, and look at the messages just above CPF0001. They name the parameter and the problem. - Put the cursor on each diagnostic and press F1 for the full cause and recovery text.
- In a batch job, open the job log spooled file with
WRKJOBoption 4, orWRKSPLF. Find CPF0001, then read upwards. - If the command is built in a variable, display the variable's value in debug. The problem is often a stray blank or quote.
How to fix it
- Correct the parameter values named in the diagnostic messages and run the command again.
- Press F4 to prompt the command interactively with the same values. The prompter highlights fields it can't accept.
- Remove
?and??prompting from commands in programs that run in batch, then recompile. - In CL, build qualified names with *CAT or *TCAT rather than *BCAT, and use
MONMSG MSGID(CPF0001)where you want to handle the failure yourself.
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(CPF0001) 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 CPF0001 and CPF0006?
Both mean the command didn't run because of errors found while checking it. CPF0006 is what QCMDEXC and command entry report for errors found while analyzing the command string. CPF0001 names the command that failed. In both cases the earlier messages hold the real cause.
Why does my CL program work interactively but fail with CPF0001 in batch?
A common reason is prompting characters in a command. Selective prompting only works in an interactive job, so in batch it causes CPD0037 and then CPF0001.
Can I monitor for CPF0001?
Yes. MONMSG MSGID(CPF0001) after the command catches it. Retrieve the earlier diagnostics with RCVMSG if you need to know what was wrong.