Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 30 -- September 8, 2004

CRTDUPOBJ and Logical Files

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

Sponsored By
GUILD COMPANIES

Line your pockets with
iSeries knowledge!


For a limited time, you can acquire three of Brian Kelly's popular iSeries Pocket Guides as a bundle with a 20 percent discount off list price.

The bundle includes: The iSeries Pocket Database Guide, The iSeries Pocket Developers' Guide, and The iSeries Pocket Query Guide.


Buy this book bundle from
our online store today.


Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

COMMON
iTera
Guild Companies


BACK ISSUES

TABLE OF
CONTENTS
Sifting Through the Java Quagmire

Define Compile-Time Array Data in D-Specs

CRTDUPOBJ and Logical Files


The Four Hundred
Companies Want Good Enough IT, Not 'Best of Breed'

How i5s Stack Up To Alternatives, Revisited

Forrester Says IT Budgets Will Be Up 7% in 2005

Four Hundred Stuff
Newlook Software Builds Smart Clients from iSeries Apps

Florida Utility Links to 7-Eleven for In-Store Bill Pay

The i5 Is In Demand During the U.S. Open

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement