Save Library List (PUSH LIBL) (SAVLIBL)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Save Library List (PUSH LIBL) (SAVLIBL) command allows you to save the current library list to a save area and then restore the library list using that same save area (via the RSTLIBL command). SAVLIBL copies the names of all portions of the library list to the save area. The save area is actually a user space that the command creates for you. The job can be changed back to a saved library list by running the RSTLIBL command.

SAVLIBL is a stack.

Each time SAVLIBL is run, the library list is copied to the end of the save area (user space). When it is restored, it is restored from the end of the save area and then removed from the save area. SAVLIBL and RSTLIBL work similar to the "PUSH" and "POP" function in computer science. The first SAVLIBL copies the names of the libraries on the library list to the user space. A second SAVLIBL to the save save area adds the current library list to that same user space, retaining the first library list. Thus, a SAVLIBL, SAVLIBL, SAVLIBL, followed by RSTLIBL, RSTLIBL saves the library list 3 times, and restores the two most recently saved versions. The original or first save is not restored since, in this example, only two RSTLIBL commands were issued.

Restrictions:

Top

Parameters

Keyword Description Choices Notes
LIBL Library List save area name Qualified object name Optional, Positional 1
Qualifier 1: Library List save area name Name, *USER, *DFT, *JOB, *JOBNAME, *JOBNBR
Qualifier 2: Library Name, *CURLIB, QTEMP
CLEAR Clear library list save area *YES, *NO Optional, Positional 2
Top

Library List save area name (LIBL)

Specifies the user space where the library list names are saved.

Qualifier 1: Library List save area name

*USER
The user space where the library list names are saved is the same as the user running the command. By default this user space is created in QTEMP.
*DFT
The user space is the default name used by COZTOOLS. As of this writing, the default name is COZSAVLIBL in QTEMP.
*JOB or *JOBNAME
The job name is used as the user space name.
*JOBNBR
The user space name is derived from the job number, as follows: QJOB999999 where 'QJOB' is a constant, and 999999 is the job number.
name
Specify the name of the user space where the library list is saved. NOTE: The data in the user space will be overwritten by the command.
Top

Clear library list save area (CLEAR)

Specifies whether or not to clear the user space (save area) before performing the SAVLIBL command. Doing so clears any existing data from the save area, including previously saved library lists.

*NO
By default the save area (user space) is not cleared.
*YES
The user space is cleared prior to the library list names being saved.
Top

Examples for SAVLIBL

Example 1: Simple Command Example

   SAVLIBL
   CHGCURLIB APLUS
   ADDLIBLE  FIXEDASSET
   CALL PGM0100E
   RSTLIBL

In this example, the initial SAVLIBL command saves the library list to the default save area. Then the library list is modified, and a legacy program is called. Upon returning from that call, the RSTLIBL command is run. It restores the library list to where is was when the original SAVLIBL command had been run.

Example 2: More Complex Command Example

   SAVLIBL  LIBL(QTEMP/THX01) CLEAR(*YES)
   CHGCURLIB APLUS
   ADDLIBLE  FIXEDASSET
   CALL PGM0100E
   COZTOOLS/RSTLIBL  LIBL(QTEMP/THX01)

In this example the same process is performed as in the first example. However, the SAVLIBL and RSTLIBL commands in this example include the LIBL(QTEMP/THX010) parameter. This forces the library list to be saved to the user space named THX01 in library QTEMP. Why do this? If once of the programs being called by PGM0100E also run SAVLIBL, but do not necessarily restore the library list by calling RSTLIBL, then upon returning to this program, the RSTLIBL could restore the incorrect library list. Using a unique save area on the LIBL parameter allows you to control where the library is saved to and restored from.

In addition, we've qualified the RSTLIBL command to the COZTOOLS library. Why do this? Because if the call to PGM0100E changes the library list to the point where the COZTOOLS library is no longer on the library list, the RSTLIBL could fail. By qualifying it we avoid that specific issue.

Top

Error messages

Unknown
Top