RSTLIBL (Restore "POP" Library List)

The RSTLIBL command changes the job's current library list to that which was previously saved using SAVLIBL. The Current Library, Product Library(s) and User Portion (USRLIBL) of the library list are modified to what they were when the prior SAVLIBL was performed. The system-portion of the library list is not altered by the RSTLIBL although it is saved by the SAVLIBL command.

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.

Before the misbehaving application is called, run the SAVLIBL command to make a copy of the entire library list and then call the misbehaving application. Upon returning to your own environment, run the RSTLIBL (restore library) command and the 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 a 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 entry 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 as the library list save area. The library list save area must exist and must have been created by the SAVLIBL command.

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.

SYSLIBL - *NO Indicates if the System Portion of the library list is restored. Note: The System Portion may not be restored by RSTLIBL.

PRODLIBL - *YES Indicates if the product library(s) (up to two of them can exist) are restored by the command.

CURLIB - *YES Indicates if the current library will be replaced by the RSTLIBL command.

USRLIBL - *YES Indicates if the user portion of the job's library list is replaced with that which was saved by the SAVLIBL command.

RMV - *YES Indicates whether or not the saved library list is removed from the library list save area once it is restored. Specify RMV(*NO) if you want to restore the same saved library list multiple times or keep the library list in the save area. This is useful when creating "named library list save areas" and you recall them to setup your library list to perform certain tasks.

Examples:

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

Alternatively you can create user-specified library list save areas and save a library list for future use and then apply that library list to your job anytime. Be sure to use the RMV(*NO) parameter when you want to keep the library list in the save area.

SAVLIBL LIBL(MYLIB/DEVLIBL) /* Save active library list to DEVLIB in MYLIB.
/* Sign off and then log onto another session at a later date */
/* Next restore the active library to what is currently saved in the DEVLIBL save area */
RSTLIBL LIBL(MYLIB/DEVLIBL) RMV(*NO)

At this point, the library list that was saved when the SAVLIBL was run, has be restored to your job and your job is running under that saved library list. use DSPLIBL to view the current/active library list for your job.

Tutorial

Requirements:

IBM i v5.4 or later

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