DUPLICATE_OBJECT

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

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.

Syntax

DUPLICATE_OBJECT (Object Name,Template,[Folder])

Parameters

  • DUPLICATE_OBJECT
    Duplicates an object to a folder
  • Object Name
    Name of the target object
    Format: script literal or script variable
  • Template
    Name of the source object that should be duplicated.
    Format: script literal or script variable
  • (Optional) Folder
    Path of the folder to which you want to duplicate the object.
    Format: script literal or script variable

Return codes

The script function returns the following codes:

  • 0
    The object was successfully duplicated.
  • 20645
    This object does not exist.
  • 20657
    The target folder does not exist.

Example

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: