The i5/OS has a unique way to locate objects in the system: the library list. The library list is, as the name implies, a list of library names. When you manipulate an object with any command, but do not tell the system which library it resides in, the system uses the library list to find an object with a matching name.
The library list can have a maximum of 265 names and is always scanned from top to bottom. As soon as the system finds the object it is looking for in one of the libraries in the list, it searches no further. Therefore, the scanning process always stops at the first match.
The library list consists of two parts: the system portion and the user portion. In addition, up to two product libraries and the current library can sit in between. The setup is shown in Figure 19.3.
Figure 19.3: The system scans the library list in this order.
The system portion of the library list must always exist, and must always contain at least QSYS. The system portion never can be empty, nor can it contain more than 15 names.
A product library becomes part of the library list on a temporary basis, while the system runs a command that uses a product library or by displaying a menu (using the GO command) that uses a product library. The product library is removed from the library list as soon as the command ends, or as soon as the user exits the menu. The library list may contain a maximum of two product libraries.
The current library also can become part of the library list, but it can be a permanent part of it. The current library can be set with the CURLIB parameter of the user profile, job description, or by executing the Change Current Library (CHGCURLIB) command.
Many commands point to the current library with the special value *CURLIB instead of a library name. If your library list has a current library, that library name is substituted. If you do not have a current library, the system uses QGPL.
The user portion of the library list can contain as few as zero and as many as 250 names.
The system portion of the library list is maintained by changing system value QSYSLIBL. The system portion of the library list doesn't exist anywhere else, and it is a system-wide setting that cannot be customized by user profile, work-station, or job description.
You should keep the system portion of the library list as shortas possible. Place only the libraries that all your users need access to in it.
Another good use for the system portion of the library list is to keep objects duplicated from QSYS (that later may have been changed), so that the system uses your versions of the objects instead of those in QSYS. This is done by creating a library (which can be named ALTQSYS) and placing it above QSYS in the system portion of the library list.
Remember that the change you make in system value QSYSLIBL doesn't affect jobs that are already running. The change only affects new jobs initiated from that moment on.
The user portion of the library list should be used for libraries that depend on the nature of the job being performed. Each user can have a different set of libraries in the user portion of the library list. If you want to provide a system-wide default set, use system value QUSRLIBL.
For example, you could create job descriptions for different people and provide a different set of libraries in the INLLIBL parameter, which lists the user portion of the library list only. The INLLIBL parameter can have special value *SYSVAL. In this case, the system uses the default set in system value QUSRLIBL for INLLIBL.
At any time during the life of a job, the library list can be changed using the Change Library List (CHGLIBL) or Edit Library List (EDTLIBL) command. These commands replace the whole set of the user portion of the library list in a single stroke.
For subtler changes (such as adding or removing a library), use the Add Library List Entry (ADDLIBLE) or Remove Library List Entry (RMVLIBLE) command. The ADDLIBLE command lets you indicate where within the list you want to add the library.
You also can alter your job's copy of the system portion of the library list by using the Change System Library List (CHGSYSLBL) command. When you execute this command, only your job is affected. All the others remain intact. The CHGSYSLIBL command lets you add a library at the very top of the system portion of the library list, or remove a library from it. You cannot control where in the system portion you are adding the library. The library always goes to the top.
When you manipulate objects, you must tell the system which library contains the object you are manipulating. For example, suppose you want to delete a data area named COMPANY. The system could have any number of data areas all named COMPANY, located in different libraries. How would the system know which one to delete?
You can send the system to the right data area in two ways: by qualifying its name with the name of the library where it resides, or by qualifying it with *LIBL, as follows:
In the first case, the system expects to find data area COMPANY in library MYLIB. If COMPANY is not there, the DLTDTAARA command ends in error.
In the second instance, the system scans the libraries in the library list for the job, from top to bottom, until it finds a data area named COMPANY. When the system finds the job, it deletes the data area and stops the scan. If the system runs out of libraries without finding COMPANY in the library list, the DLTDTAARA command ends in error.
You also can use *CURLIB, if you want to manipulate an object you know is in the current library, as follows:
Finally, you can omit the library qualifier altogether, as follows:
This is equivalent to using *LIBL, because the library name defaults to *LIBL in the DLTDTAARA command. Some commands default to *CURLIB. You should always make sure you know what the default value is before you use it.