Functions of using a library list

Using a library list simplifies finding objects on the system.

Each job has a library list associated with it. When a library list is used to find an object, each library in the list is searched in the order of its occurrence in the list until an object of the specified name and type is found. If two or more objects of the same type and name exist in the list, you get the object from the library that appears first in the library list. The following figure shows the searches made for an object both when the library list (*LIBL) is used and when a library name is specified:

Note: Alternatively, use *NLVLIBL instead of *LIBL to qualify any command. Enter the command from a CL program, on a command line, or anywhere you normally enter a command. The system uses *NLVLIBL to determine which libraries to search for the *CMD object. You search only the national language support libraries in the library list by specifying *NLVLIBL.
Using a library list
The following figure shows what happens when two objects of the same name but different types are in the library list. The system will search for CUSTINQ *FILE in the library list by specifying:

DSPOBJD OBJ(*LIBL/CUSTINQ) OBJTYPE(*FILE)

Generally, a library list is more flexible and easier to use than qualified names. More important than the advantage of not entering the library name, is the advantage of performing functions in an application on different data by using a different library list without having to change the application. For example, a CL program PGMA updates a data area CHKNBR. If the library name is not specified, the program can update the data area named CHKNBR in different libraries depending on the use of the library list. For example, assume that JOBA and JOBB both call PGMA as shown in the following illustration.

A library list is more flexible and easier to use than qualified names.

However, the use of a qualified name is advantageous in any of the following situations:

  • When the object you are using is not in the library list for the job
  • When there is more than one object of the same name in the library list and you want one in a specific library
  • When you want to ensure that a specific library is used for security reasons.

If, however, you call a program using a qualified name and the program attempts to open files whose names are not qualified, the files are not opened if they are not in the library list, as shown in the following example.

The call to PGMA is successful because the program name is qualified on the CALL command. However, when the program attempts to open file ORDENTP, the open operation fails because the file is not in one of the libraries in the library list, and its name is not qualified. If library DISTLIB2 was added to the library list or a qualified file name was used, the program could open the file. Some high-level languages do not allow a qualified file name to be specified. By using an Override (OVRxxx) command, a qualified name can be specified.