Create Duplicate Object (CRTDUPOBJ) command in AS400

Create Duplicate Object (CRTDUPOBJ) command in AS400
Create Duplicate Object (CRTDUPOBJ) command in AS400, CRTDUPOBJ, Create duplicate of logical file LF
Create Duplicate Object (CRTDUPOBJ) command in AS400

Introduction

The CRTDUPOBJ command allows us to copy an exact replica of an object from one library to the other. We can copy a single or the group of objects using this CRTDUPOBJ command. Please note that the new object must be renamed if it is going to be created in the same library in which the original object resides.

You can copy a group of objects by specifying generic names or by names starting with some letter let's say TEST* or you can specify *ALL or specify more than one object type.

CRTDUPOBJ command parameters

                       Create Duplicate Object (CRTDUPOBJ)  
                                                            
 Type choices, press Enter.                                 
                                                            
 From object  . . . . . . . . . . OBJ                       
 From library . . . . . . . . . . FROMLIB                   
 Object type  . . . . . . . . . . OBJTYPE                   
                           + for more values                
 To library . . . . . . . . . . . TOLIB          *FROMLIB   
 New object . . . . . . . . . . . NEWOBJ         *OBJ       
 From ASP device  . . . . . . . . ASPDEV         *          
 To ASP device  . . . . . . . . . TOASPDEV       *ASPDEV    
 Duplicate data . . . . . . . . . DATA           *NO        
 Duplicate constraints  . . . . . CST            *YES       
 Duplicate triggers . . . . . . . TRG            *YES       
 Duplicate file identifiers . . . FILEID         *NO        
 Duplicate access control . . . . ACCCTL         *ALL       
  • You can specify whether data in a physical file or savefile to be copied or not using the below parameter whose default value is set as *NO. You can change it to *YES to copy data as well.
  •  Duplicate data . . . . . . . . . DATA           *NO 
  • You can also specify whether constraints, triggers, row access control, column access control, or member level identifiers are to be copied or not.
  • CRTDUPOBJ command on Logical File

    There are two cases possible when copying a logical file from one library to the other.

    CASE1

  • If both the logical file and its based on physical file is present in the same library then first you must create the duplicate of PF in the TOLIB and then duplicate the LF in the TOLIB using the CRTDUPOBJ command. Once the PF and LF are duplicated to the new library, the new LF will be based on the PF in the new library.
  • CASE2

  • If the logical file and its based on physical file is present in the different library then even if you first create the duplicate of PF in the TOLIB and then duplicate the LF in the TOLIB using CRTDUPOBJ command then the new LF will be based on the PF in the old library FROMLIB, not on the new library TOLIB.
  • Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain