• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • CRTDUPOBJ and Logical Files

    September 8, 2004 Hey, Ted

    I want to build some test libraries from my production libraries. I am having trouble duplicating logical files that are stored in one library but point to physical files in another library. I thought Create Duplicate Object (CRTDUPOBJ) would create a logical in one test library but point it to another test library if the library list was set correctly. What is the best method to copy logical files and point them to the correct physical files?

    –David

    You have to be careful when using CRTDUPOBJ with logical files. Which physical file the new logical file is based on depends on whether the original physical file and logical file are in the same library or in different libraries. Here are the rules.

    Rule 1: If the logical file being copied and the physical file upon which it is based are in the same library, the new logical file will be based on a physical file in the library in which the new logical is being created.

    Rule 2: If the logical file being copied and the physical file upon which it is based are in different libraries, the new logical will be based on the original physical file.

    The library list doesn’t even enter the picture.

    Maybe an example will make it clearer. Assume four libraries: PROD1, PROD2, TEST1, and TEST2. PROD1 and PROD2 contain the production data. TEST1 and TEST2 are to contain the duplicated objects.

    Assume PROD1 has a physical file, CUSTOMER, which has two logical files. Logical file CUSTOMER1 is in PROD1, but logical file CUSTOMER2 is in PROD2. Your goal is to create physical file CUSTOMER and logical file CUSTOMER1 in TEST1, and to create logical file CUSTOMER2, based on TEST1/CUSTOMER, in TEST2.

    You can use CRTDUPOBJ to create CUSTOMER1 and CUSTOMER2 in TEST1.

    CRTDUPOBJ OBJ(CUSTOMER) FROMLIB(PROD1) +
                 OBJTYPE(*FILE) TOLIB(TEST1)
    CRTDUPOBJ OBJ(CUSTOMER1) FROMLIB(PROD1) +
                 OBJTYPE(*FILE) TOLIB(TEST1)
    

    But if you use CRTDUPOBJ to create TEST2/CUSTOMER2, the system will build the new logical over PROD1/CUSTOMER.

    It would be nice if Change Physical File (CHGPF) would allow you to assign a different physical file to a logical file, but it won’t. You can use Remove Member (RMVM) to remove the member of the new logical file, but Add Logical File Member (ADDLFM) won’t let you specify TEST1/CUSTOMER.

    Here is a roundabout way to make the new logical point to the other test library.

    First, duplicate the “renegade” logical to the same production library where its physical file resides.

    CRTDUPOBJ OBJ(CUSTOMER2) FROMLIB(PROD2) +
                OBJTYPE(*FILE) TOLIB(PROD1)
    

    At this point, PROD1/CUSTOMER has three logical files: PROD1/CUSTOMER1, PROD1/CUSTOMER2, and PROD2/CUSTOMER2.

    Duplicate the logical you just created to the library containing the test copy of the physical.

    CRTDUPOBJ OBJ(CUSTOMER2) FROMLIB(PROD1) +
                OBJTYPE(*FILE) TOLIB(TEST1)
    

    Since the copied logical was in the library that contained its physical file, TEST1/CUSTOMER2 points to TEST1/CUSTOMER.

    Move the test CUSTOMER2 to the second test library.

    MOVOBJ OBJ(TEST1/CUSTOMER2) +
             OBJTYPE(*FILE) TOLIB(TEST2)
    

    TEST2/CUSTOMER2 continues to point to physical file TEST1/CUSTOMER.

    Be sure to delete the copy of the logical file that you made in the production library.

    DLTF FILE(PROD1/CUSTOMER2)
    

    I don’t like roundabout methods. I hope there’s an easier way that I’m overlooking and that someone will tell me about it.

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Rocket Software

    Meet digital age demands while maximizing your IT investment.

    Future-proof your mission-critical applications with Rocket® Solutions for IBM® i that keep your business ahead of the curve.

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Goering Bolsters iExcelGen with Better Automation PeopleSoft Says It’s Working Hard to Make a Better World

    Leave a Reply Cancel reply

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • POWERUp 2025 –Your Source For IBM i 7.6 Information
  • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
  • Guru: Creating An SQL Stored Procedure That Returns A Result Set
  • As I See It: At Any Cost
  • IBM i PTF Guide, Volume 27, Number 19
  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle