CRTDUPOBJ using *LIBL
Language(s):I-Series - CLP
Category(s):Utilities

A limitation of the CRTDUPOBJ command is that it doesn't allow *LIBL as a parameter. This program shows how to get around this.

/* +
   *************************************************************** +
   ** - Source Member: GCRTDUPOBJ                                  +
   *************************************************************** +
   ** - CL Example - Using *LIBL with the CRTDUPOBJ command        +
   ** - to create files.                                           +
   **                                                              +
   ** - Jon Vote 09/2002                                           +
   ** - www.idioma-software.com                                    +
   *************************************************************** +
   **                                                              +
   ** - 'Thought shalt not qualify' is a worthy commandment        +
   ** - but creating duplicate objects is a problem because the    +
   ** - CRTDUPOBJ command does not allow *LIBL as the library      +
   ** - parameter. This program shows you how to work around this. +
   ** - This allows your test and production systems to be         +
   ** - identical, while using different libraries for CRTUPOBJ    +
   ** - functions. +
*/
pgm parm(&FromObj &ToObj)
  dcl &FromObj *char 10
  dcl &ToObj *char 10
  dcl &Lib *char 10 /* This will store the library */
/* +
 ** - This code will create the object in the same library as +
 ** - the source object. +
 ** - First of all, get the library containing the from object:    +
*/
  rtvmbrd file(*libl/&FromObj) rtnlib(&Lib)

/* +
 ** - Now create the new object in this library +
*/
  crtdupobj obj(&FromObj) fromlib(*libl) tolib(&Lib) objtype(*file) +
       newobj(&ToObj)

endpgm

This article has been viewed 4596 times.
The examples on this page are presented "as is". They may be used in code as long as credit is given to the original author. Contents of this page may not be reproduced or published in any other manner what so ever without written permission from Idioma Software Inc.