30.06.2013 Views

File Management - IBM

File Management - IBM

File Management - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

80 <strong>File</strong> <strong>Management</strong> V4R5<br />

from-file members are copied because no existing data will be destroyed. Each<br />

member that is copied is identified by a normal copy completion message. If the<br />

to-file is spooled, an empty spooled file is produced for each empty from-file<br />

member. If the PRINT parameter on the CPYF command specifies *COPIED,<br />

*EXCLD, or *ERROR, the empty members are shown in the lists, and no records<br />

are printed.<br />

Except for the CPYFRMQRYF command, an empty from-file member is never<br />

copied to a diskette or tape file, or to a physical file when MBROPT(*REPLACE) is<br />

specified. Empty from-file members are skipped for these types of to-files, and a<br />

CPF2869 message is sent (as either an informational or diagnostic message) to<br />

identify each empty member. The empty members are skipped to avoid destroying<br />

existing data. When an empty from-file member is skipped, the following<br />

considerations apply:<br />

v A tape or diskette file is not produced on the output volume. If the diskette file<br />

is spooled, no spool output file is created.<br />

v An existing to-file physical file member is not cleared.<br />

v If the to-file does not exist and you specified CRTFILE(*YES) on a copy<br />

command, a physical file is created.<br />

v If the to-file is a physical file and the to-file member does not exist, a member is<br />

added to the file.<br />

v If the PRINT parameter on the CPYF command specifies *COPIED, *EXCLD, or<br />

*ERROR, the empty members are not shown in the lists.<br />

When the copy command specifies a generic name or *ALL for the FROMMBR<br />

parameter, each empty from-file member skipped is identified by message<br />

CPF2869, sent as an informational message. If all the from-file members are<br />

skipped, a CPF2870 diagnostic message is sent after all the CPF2869 informational<br />

messages, followed by a CPF2817 escape message.<br />

When the copy command specifies a single member name or FROMMBR(*FIRST),<br />

or when there is an override for the from-file that forces a single member to be<br />

processed, an empty member that is skipped is identified by the diagnostic<br />

message CPF2869. The CPF2869 diagnostic message is followed by a CPF2817<br />

escape message.<br />

In the following example, the from-file and to-file are both database files, and<br />

EMPTY1 and EMPTY2 are empty members in the from-file.<br />

PGM<br />

/* No need to monitor for zero records<br />

when MBROPT(*ADD) specified */<br />

CPYF FROMFILE(D504/GEORGE) TOFILE(D504/KEN) +<br />

FROMMBR(EMPTY1) TOMBR(MBR1) MBROPT(*ADD)<br />

CPYF FROMFILE(D504/GEORGE) TOFILE(D504/KEN) +<br />

FROMMBR(EMPTY2) TOMBR(MBR2) MBROPT(*REPLACE)<br />

MONMSG MSGID(CPF2817) CMPDTA(CPF2869) +<br />

EXEC(CLRPFM FILE(D504/KEN) MBR(MBR2))<br />

/* Monitor for zero records and<br />

send a message when all members<br />

to copy are empty */<br />

CPYF FROMFILE(D504/GEORGE) +<br />

TOFILE(D504/NEWFILE) FROMMBR(EMPTY*) +<br />

TOMBR(NEWMBR) MBROPT(*REPLACE)<br />

MONMSG MSGID(CPF2817) CMPDTA(CPF2870) +<br />

EXEC(SNDPGMMSG TOPGMQ(*EXT) +<br />

MSG('All members to copy are empty'))<br />

ENDPGM

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!