DUPLICATE_OBJECT

Use the DUPLICATE_OBJECT script function to create a duplicate of an object.

Syntax

DUPLICATE_OBJECT (Object Name, Template [, Folder])

Parameters

Parameter Description Format Allowed Values Default Value
Object Name Name of the target object Script literal or script variable n.a n.a
Template Name of the source object that should be duplicated. Script literal or script variable n.a n.a
Folder Path of the folder to which you want to duplicate the object. Script literal or script variable n.a n.a

Important Considerations

Key considerations include:

  • Important: A runtime error occurs if you use an :ON_ERROR statement with the ABEND parameter, but the object or the folder does not exist. The object remains in its original folder if the folder does not exist. For more information, see :ON_ERROR.
  • You need write access (W) to the object and the target folder, as a runtime error will occur otherwise. For more information, see Granting Automation Engine Authorizations.
  • This script function writes all open transactions of the script to the AE database. For more information, see Script Processing.

Return Codes

The DUPLICATE_OBJECT function returns the following return codes:

Return Value Condition
0 The object was successfully duplicated.
10000 The source object does not exist.
20644 An object with the target name already exists.
20657 The target folder does not exist.

Examples

The following example duplicates the SCRI.SOURCE Script object and names it TARGET.


:
 SET &target_object# = "SCRI.TARGET_&$PHYS_DATE_YYYY_MM_DD_p#_&$_PHYS_TIME_HHMMSS#"

: SET &retcode# = DUPLICATE_OBJECT (&target_object#SCRI.SOURCE,"\DUPLICATE_OBJECT\TEST")

: PRINT &retcode#

The duplicated object now shows the name SCRI.TARGET_2023_10_17_155414.

See also: