CPF2817: Copy command ended because of error
CPF2817 means a copy command such as CPYF stopped because of an error. It doesn't say which error. The real reason is in the diagnostic messages that the command logged just before it.
Other names for this code
Also written as CPF2817 copy command ended, MSGID CPF2817, CPYF CPF2817, MONMSG CPF2817, copy command ended because of error.
What it means
CPF2817 is an escape message from QCPFMSG with the text "Copy command ended because of error". CPYF sends it, along with other IBM i copy commands, as the final word when a copy fails. The copy command first logs one or more diagnostic messages that describe the actual problem, then ends with CPF2817.
So CPF2817 on its own tells you almost nothing. The message to read is the one just above it in the job log. That can be anything from a missing file to a format mismatch, a lock, or bad data in a record.
One common case surprises people. When the from-member is empty, CPYF logs a message that the empty member wasn't copied, and then ends with CPF2817. Programs that copy daily files that may be empty must allow for this. With MBROPT(*REPLACE), the to-member keeps its old records in that case, because nothing was copied over it.
Common causes
- The from-member is empty, so there was nothing to copy.
- The from-file, to-file or a member doesn't exist, or the to-file is missing and CRTFILE(*YES) wasn't specified.
- The record formats of the two files differ and the command didn't say how to handle that with FMTOPT, for example *MAP and *DROP, or *NOCHK.
- Another job has the to-file or member locked, or the user lacks authority to one of the files.
- Records failed during the copy, such as duplicate keys in a unique to-file or data that doesn't fit the to-file's fields, and the number of errors went over the ERRLVL limit.
- A parameter combination isn't allowed, for example TOMBR(*FROMMBR) in a case where it can't be used.
How to find the problem
- Open the job log with DSPJOBLOG, or press F10 on the message screen to show detailed messages. The diagnostic messages just above CPF2817 give the reason.
- Put the cursor on each of those messages and press F1 for the full text, which names the file, member or record involved.
- Check the files with DSPFD and their record formats with DSPFFD if a format mismatch is suspected.
- If a lock is the reason, run WRKOBJLCK on the to-file to see which job holds it.
How to fix it
- Fix the problem the earlier diagnostic message names, then rerun the copy.
- For files that may be empty, decide what an empty file means. A common CL pattern clears the to-member when CPYF fails on an empty from-member. Only do that if an empty file is a valid state, because an empty master file may mean someone cleared it by mistake.
- Use FMTOPT(*MAP *DROP) when the files have different layouts with matching field names, or FMTOPT(*NOCHK) when you really want a byte-for-byte copy.
- Add CRTFILE(*YES) when the to-file may not exist yet.
- Avoid a blanket
MONMSG MSGID(CPF2817)with no action. It hides every kind of copy failure, not only the one you expected.
What it looks like
Copy command ended because of error.
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(CPF2817) MSGF(QSYS/QCPFMSG)
Also inspect the full job log and second-level message text, including substitution values.
Related codes
Questions
Why does CPYF fail when the from-file has no records?
CPYF treats an empty from-member as an error. It logs a diagnostic saying the empty member wasn't copied and then ends with CPF2817.
Where do I find the real reason for CPF2817?
In the job log, just above CPF2817. Press F10 to see detailed messages, then F1 on each one before CPF2817.
Should I monitor for CPF2817 in CL?
Only for cases you understand, such as an empty from-file you expect. Monitoring for it with no action hides real errors such as format mismatches and locks.