Midrange News for the IBM i Community


Save Library List Published by: Bob Cozzi on 17 May 2012 view comments

SAVLIBL (Save "PUSH" Library List)

The SAVLIBL command saves or "pushes" the current job's library list entries from the SYSLIBL, PRODLIBL, CURLIB, and USRLIBL portions of the library list. The library list entries (i.e., the library list names) are added to a save area. The library list may be restored to the job using the RSTLIBL.

The purpose of SAVLIBL is to allow a job to save or push the library list entries (names only) into a storage location (typically in QTEMP) and then later retrieve the saved library list entries in order to restore the library list in the job

For example, assume you have a user's library list set up perfectly, but when they select a menu option to enter another application, that application alters their CURLIB and adds additional libraries to their library list, or changes the order of library names on the USRLIBL (user portion) of the library list.

Upon exiting that application, the library list remains as it was, still altered by the application. This can cause all kinds of issues, especially.

Before the misbehaving application is called, run the SAVLIBL command to make a copy of the entire library list. The call the misbehaving application. Upon returning to your own environment, run the RSTLIBL (restore library) command and your library list is restored to what it was when you ran the SAVLIBL command.

Each time the SAVLIBL is run for the job, the library list is added to the library list save area. This allows you to run successive SAVLIBL commands and have several library lists "stacked up" in the save area. Each RSTLIBL commands will remove one saved library list from the save area and update the job's library list. This works similar to the "PUSH" and "POP" techniques used when programming in Assembly in the early days of computer programming.

Parameters

LIBL - The name given to the object used to as the library list save area. By default a temporary library list save area is created in QTEMP. It is automatically deleted when the job ends. You may specify a permanent library list save area in a user library. The library list save area is automatically created if it does not exist at the time the SAVLIBL is run. When the *USER is specified for this parameter, a library list save area with the same name as the user profile running the SAVLIBL command is created in the specified library.

The Library List Save Area is a *USRSPC (user space) object with an extended object attribute of 'LIBL'. Take this into consideration when creating a permanent library list save area object.

CLEAR - If *YES is specified, the library list save area is cleared before the library list is copied into the save area. Any library list entries saved to the library list save area specified on the LIBL parameter will no longer be accessible via the RSTLIBL command. The library list being saved is inserted as the top (first) entry into the save area. The default value for this parameter is *NO.

Examples:

The basic use for SAVLIBL and RSTLIBL is pretty simple. Issue one RSTLIBL for each SAVLIBL performed. For example:

SAVLIBL   /* Saves library list */
ADDLIBLE COZTOOLS

SAVLIBL   /* Saves a 2nd library list */
CHGCURLIB QGPL

SAVLIBL   /* Saves a 3rd library list */
RMVLIBLE QTEMP

RSTLIBL /* Restores 3rd library list, restoring QTEMP to the library list */
RSTLIBL /* Restores 2nd library list, changing the current library back to what it was before it was QGPL  */
RSTLIBL /* Restores 1st library list, restoring it to before the COZTOOLS library was added */

Tutorial

Requirements:

  • IBM i v5.4 or later

The SAVLIBL command is part of the COZTOOLS software package available from COZZI PRODUCTIONS, INC. at www.cozTools.com

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

COMMENTS