• 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
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Join us for this webinar where we’ll showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch Now

    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

Volume 4, Number 30 -- September 8, 2004
THIS ISSUE
SPONSORED BY:

COMMON
iTera
Guild Companies

Table of Contents

  • Sifting Through the Java Quagmire
  • Define Compile-Time Array Data in D-Specs
  • CRTDUPOBJ and Logical Files

Content archive

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

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

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