Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
The SAVE Commands of cozTools
has no ratings.
Published: 09 Aug 2014
Revised: 10 Sep 2018 - 1995 days ago
Last viewed on: 25 Feb 2024 (6971 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

An overview of the SAVxxx command found in Cozzi appTools Published by: Bob Cozzi on 09 Aug 2014 view comments

To enhance the already wide-range of SAVxxx command, Cozzi appTools includes four additional SAVxxx commands that go beyond those shipped with IBM i. If you already have Cozzi appTools installed, and you're not using these commands, you might be able to save some time by integrating them into your workflow. Let's look at them briefly here, but for more information, visit the Cozzi appTools website http://www.cozTools.com

Save Library to Save File

To simplify the process of quickly saving an entire library to a save file, the SAVLIBSAVF command may be used. This command allows you to save any number of libraries to a save file of the same name as the library. Generic library names are supported and up to 300 names may be specified. Here's an example:


This command would save the libraries listed along with COZTOOLS and COZQRYF to save files of the same name into library TEMPSAV. If TEMPSAV does not exist, the CRTLIB(*YES) parameter indicates that it will be created.

The SAVLIBSAVF command includes the OMITLIB (library names to omit) and SAVACT (Save while Active) parameters.

Save Library to a "Rolling" Save File

The need to save versions or archived copies of libraries is always important. You don't what to whipe out an existing save with the current save, just in case you have to go back a generation, or more importantly, if requirements dictate that you must keep N versions of a backup.

The Cozzi appTools SAVROLLING command allows you to save up to 99 versions of a library to individual save files. The number of versions is dependant on the length of library's name. A 9-character library name may only be saved up to 10 times, whereas an 8 or fewer-character library name may be saved up to 99 times. Here's a simple example:


This command would save the COZTOOLS, COZQRYF (Cozzi Query File) and the user's MYTESTLIB to a save file named the same as the library, into library ONLINESAVE. If a save file already exists in ONLINESAVE, then it is rolled down one generation. That is save file MYTESTLIB becomes MYTESTLIB1 and MYTESTLIB1 becomes MYTESTLIB2. This rolling is "down hill" so that the save file whose name is identical to the library name is always the most current save, and the save file with the highest suffix is always the oldest save.

Save and Restoring a Library List for your Job

Often when running someone else's code, they blindly change the library list instead of using PRDLIB or CURLIB to allow their code to be used by the job stream. This can really screw up user apps that expect the library list that they currently have to be the same upon returning to their menu or base application.

The SAVLIBL command allows the programmer to save the existing library list for a job in a save area and then restore from the save area at any time, using the RSTLIBL command. Here's how it would work:

SAVLIBL /* Save library list */
call PKL00D2
RSTLIBL  /* Restore the library list */

In this example, the library list is saved, the miss-behaving program is called, then the library list we had before the misbehaving program was called, is restored.

The library list is saved to a user space that is automatically created in QTEMP. So it goes away when the job ends.  

The Cozzi appTools provide a set of useful CL commands that can be used everyday by all IBM i developers and many users. From simple save/restore enhancements as illustrated here, to complex tasks such as calculating the number of days between two dates within CL programs, the Cozzi appTools is right for you.

Return to midrangenews.com home page.
Sort Ascend | Descend