• 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
    Manta Technologies

    The Leader in IBM i Education!
    Need training on anything i?
    Manta is all you need.

    Spring Sale! Save 20% off any Manta Combination Package, including the complete IBM i Training Library. Now through April 30.

    130 courses and competency exams on:
    · IBM i operations
    · System Management and Security
    · IBM i Programming Tools
    · Programming in RPG, COBOL, CL, Java
    · Web Development
    · SQL, DB2, Query

    Product features:
    · Runs in every popular browser
    · Available 24/7/365
    · Free Student Reference Guides
    · Free Student Administration
    · Concurrent User License
    · Built-In IBM i Simulator

    You can download our 200-page catalog and take sample sessions at MantaTech.com.

    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

  • LANSA Developing Business Intelligence Tool
  • Blazing The Trail For VTL In The Cloud
  • Data De-Dupe Gives VTL Customers More Options
  • Four Hundred Monitor, March 29
  • The Big Spending On IT Security Is Only Going To Get Bigger
  • IBM Tweaks Some Power Systems Prices Down, Others Up
  • Disaster Recovery: From OS/400 V5R3 To IBM i 7.4 In 36 Hours
  • The Disconnect In Modernization Planning And Execution
  • Superior Support: One Of The Reasons You Pay The Power Systems Premium
  • IBM i PTF Guide, Volume 25, Number 13

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 © 2023 IT Jungle