Monitoring for copy errors

When an error occurs, the escape message CPF2817 is sent to indicate many different error conditions.

Except for the empty from-file member case, which is described later, when this message is sent:
  • A physical file is not created (even if CRTFILE(*YES) was specified on a copy command).
  • No members are added to a to-file that is a physical file.
  • No to-file member is cleared (even if MBROPT(*REPLACE) was specified).
  • The to-file is not opened, so no file is created on a tape volume. If the to-file is spooled, no spooled file is created.
  • No records are copied.

The CPF2817 escape message is always preceded by at least one diagnostic message that indicates the specific error condition. The message identifier of the diagnostic message, which immediately precedes the CPF2817 escape message is used as message replacement data (MSGDTA parameter on the Send Program Message (SNDPGMMSG) command) for the CPF2817 escape message. This enables you to monitor for specific error cases from the CPF2817 escape message by using the CMPDTA parameter on the Monitor Message (MONMSG) command.

For example, message CPF2802 is a diagnostic message. It indicates that the from-file cannot be found. You can monitor for just the from-file not found condition as follows:
PGM
           /* The replacement text of escape
           CPF2817 contains the msg ID
           CPF2802 for the 'from-file not
           found' condition */
CPYF  FROMFILE(NOLIB/NOFILE) TOFILE(D504/KEY) +
  FROMMBR(NOMBR) TOMBR(MBR1) MBROPT(*ADD)
MONMSG MSGID(CPF2817) CMPDTA(CPF2802) +
  EXEC(SNDPGMMSG TOPGMQ(*EXT) +
  MSG('File NOFILE in NOLIB not found'))
ENDPGM

Any error other than from-file not found, including any other error reported with a CPF2817 escape message, causes a check in this program because the MONMSG command applies only to the CPF2817 escape message when it has the compare data from message CPF2802.

If you are running the Copy From Query File (CPYFRMQRYF) command, it does not close the open query file after completing the copy operation. However, if you are running the CPYFRMQRYF command from a command entry line, any error message that occurs after the Open Query File (OPNQRYF) command is successfully run closes the file unless you specified TYPE(*PERM) on the OPNQRYF command. The system automatically runs a Reclaim Resources (RCLRSC) command if an error messages occurs. If the OPNQRYF command specifys TYPE(*PERM), the system does not automatically close the file.

The following messages can be sent as diagnostic messages, followed immediately by a CPF2817 escape message. Some of these messages can also be sent as other message types (such as an informational or escape message). When the message is sent as a diagnostic message type, the message identifier appears in the replacement text of the CPF2817 escape message. You can monitor the condition by using the CMPDTA parameter on the MONMSG command: