CPF1240: Job ended abnormally
CPF1240 is the completion message IBM i sends when a submitted job ends abnormally. The text reads "Job
Other names for this code
Also written as MSGCPF1240, CPF1240 job ended abnormally, job ended abnormally AS400, iSeries CPF1240, CPF1240 QBATCH, CPF1240 CPF1241.
What it means
When a batch job finishes, IBM i sends a completion message to the message queue named for the job. On SBMJOB this is the MSGQ parameter, which by default is the message queue of the user who submitted the job. If the job ended normally, the message is CPF1241. If it ended abnormally, the message is CPF1240.
CPF1240 is a completion message with severity 50. Its help text gives the date and time the job ended and the subsystem it ran in, such as QBATCH, and points you to the job log. That's all it knows. The actual failure happened inside the job, so the cause is in that job's log, along with the end code in CPF1164.
Common causes
- A program in the job hit an error that wasn't monitored, leading to a function check (CPF9999) and the job ending.
- An inquiry message in the job, such as CPA0701, was answered with C or D. That cancels the program and usually ends the job.
- The job was ended from outside, for example by an operator using ENDJOB, or because its subsystem or the system ended.
How to find the problem
- Note the full job name from CPF1240. It's in the form number/user/name, such as 123456/
PAYUSER/ PAYRUN01. - Open that job's log with
WRKJOB JOB(123456/and option 4 to see its spooled files, then display QPJOBLOG. If the job log is pending,PAYUSER/ PAYRUN01) DSPJOBLOG JOB(123456/can show it.PAYUSER/ PAYRUN01) - In the job log, find the first escape message or CPF9999 function check. That's usually the real error. CPF1164 at the bottom gives the end code.
- If the job log is missing or too short, look in QHST with
DSPLOG LOG(QHST) JOB(123456/, and in QSYSOPR for inquiry messages the job sent.PAYUSER/ PAYRUN01)
How to fix it
- Fix the error found in the job log and resubmit the job.
- Make sure batch jobs keep a useful job log. A job description with
LOG(4 00 *SECLVL)andLOGCLPGM(*YES)records the CL commands and full message text. - Add MONMSG handling in CL programs for errors you expect, so they're handled cleanly instead of ending the job.
- If operators are ending jobs, agree a procedure so jobs are ended in a controlled way when possible.
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(CPF1240) 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 CPF1240 and CPF1241?
CPF1241 means the submitted job completed normally. CPF1240 means it ended abnormally.
Where is CPF1240 sent?
To the message queue named on the job's submit command (the MSGQ parameter of SBMJOB). By default that is the message queue of the user who submitted it.
CPF1240 doesn't tell me anything useful. Where's the real error?
In the job log of the job it names. Look for the first escape message or function check above CPF1164.