AS/400 Chapter 3: Libraries

You can use a library in AS/400 just as you would use a folder in Windows to organize your files, there are some differences, of course. Let's see how does a library work in AS/400.

A library is similar to a folder in Windows. In AS/400 a library is another object that can contain other objects (executable objects, source files, etc).

Libraries can't contain other libraries. AS/400 is structured as a list, the opposite of Windows which has a tree-like structure.

Creating a library

We're now going to create a library, called DEMO, where we'll place all the files from this tutorial. Type the command:

CRTLIB DEMO

Your library is now created.

Changing the current library (CURLIB)

You can change the current library to work more easily with objects. This way you don't have to specify the library name each time you want to work with a file.

To change the library you are currently in type:

CHGCURLIB DEMO

All the objects you create will be placed on your CURLIB (if you don't explicitly specify the library name). If you want to refer to the library you are currently in you can use it's name or the keyword CURLIB. You can change your default library (the library where you are when you enter the system) so that you don't have to change your current library each time you enter the system:

CHGPRF CURLIB DEMO

Be aware that if you don't change your opening or your current library, you can get some compilation errors. If you have a reference to a file (without it's library name) in your source code the compiler won't find it if it is placed on another library.

Libray Lists

Every command we use is stored in a specific system library. When a command library isn't explicitly identified, the system will search for the command in every library in its library list until the command if found. So, if you have 2 commands with the same name on different libraries, the system will execute the one that is placed on the up most library on the list. You can only have files with the same name in the same library if they are of different types. You can see the library list with the command:

DSPLIBL

You can see in the listing that there are different types of libraries:

  • SYS: System libraries. All the essential objects to the system (commands, applications, compilers, etc).
  • CUR: The library you're currently in.
  • USR: User libraries (can be created by the user or the system manufacturer).

Press F3 to go back to the previous screen.

Dércia Silva
Posted by Dércia Silva on October 26, 2007

Related articles