Copy Document (CPYDOC)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Copy Document (CPYDOC) command allows you to copy a document from one folder into another folder or to copy a document that is not in a folder into a folder.

Restrictions:

Top

Parameters

Keyword Description Choices Notes
FROMDOC From document Character value, *SYSOBJNAM Required, Positional 1
FROMFLR From folder Character value, *NONE Optional, Positional 2
TODOC To document Character value, *FROMDOC Optional, Positional 3
TOFLR To folder Character value, *FROMFLR Optional, Positional 4
REPLACE Replace document *NO, *YES Optional
SYSOBJNAM System object name Name Optional
Top

From document (FROMDOC)

Specifies the name of the document being copied.

This is a required parameter.

name
Specify the name of the document that is copied.

If FROMDOC(name) is specified, a folder name must be specified on FROMFLR.

*SYSOBJNAM
A system object name is used to identify the document that is copied.

If FROMDOC(*SYSOBJNAM) is specified, then SYSOBJNAM(name), TODOC(name) and TOFLR(name) must be specified.

Top

From folder (FROMFLR)

Specifies the name of the folder that contains the document that is copied.

*NONE
A folder name is not specified for the document. FROMFLR(*NONE) must be specified if the document is not in a folder. FROMFLR(*NONE) cannot be specified if FROMDOC(name) is specified.
name
Specify the name of the folder that contains the document that is copied.
Top

To document (TODOC)

Specifies the output document name.

*FROMDOC
The output document name is the same as that specified on the From document (FROMDOC) parameter.

If TODOC(*FROMDOC) is specified, then TOFLR(*FROMFLR) cannot be specified.

name
Specify the output document name.

If FROMDOC(*SYSOBJNAME) is specified, then TODOC(name) must be specified.

Top

To folder (TOFLR)

Specifies the folder into which the output document is copied.

*FROMFLR
The folder name is the same as that specified on the From folder (FROMFLR) parameter; the document is copied into the same folder.
name
Specify the name of the folder into which the document is copied.

If FROMDOC(*SYSOBJNAME) is specified, then TOFLR(name) must be specified.

Top

Replace document (REPLACE)

Specifies whether the document specified on TODOC can be replaced.

*NO
The output document is a new document created within the folder specified on the To folder (TOFLR) parameter. If a document with the same name already exists in the folder, no copy is made.
*YES
The output document replaces an existing document with the same name in the folder specified on the TOFLR parameter. If no document with the same name exists in the folder, a new document is created.
Top

System object name (SYSOBJNAM)

Specifies the system object name. This parameter is valid only when DLO(*SYSOBJNAM) is specified.

name
Specify the system object name of the document that is copied. A full ten characters must be specified.
Top

Examples

Example 1: Copying a Document

CPYDOC   FROMDOC(MYDOC)  FROMFLR(MYFLR)
         TODOC(MYDOC2)  TOFLR(MYFLR2)
         REPLACE(*YES)

This command copies document MYDOC located in folder MYFLR to document MYDOC2 located in folder MYFLR2. If document MYDOC2 already exists in MYFLR2, the system replaces it with a copy of document MYDOC; otherwise, MYDOC2 is created in MYFLR2 as a copy of MYDOC in MYFLR.

Example 2: Copying Document and Keeping Source Document Name

CPYDOC   FROMDOC(*SYSOBJNAM)  SYSOBJNAM(AMBT133080)
         TODOC(MYDOC4)  TOFLR(MYFLR)

This command copies a document, identified by the system object name, to document MYDOC4 located in folder MYFLR. The document name will be the same as the name of the source document.

Example 3: Copying Document to Document in Same Folder

CPYDOC   FROMDOC(XYZ)  FROMFLR('MYFLR/TEST')  TODOC(NEW)

This command copies document XYZ located in folder MYFLR/TEST to document NEW in the same folder. If document NEW already exists, an error message is sent.

Top

Error messages

*ESCAPE Messages

CPF8A12
Document &2 in folder &1 not copied.
Top