What is a Library in AS400? How does it work?

A library in AS/400 (IBM i) is a system-level object that organizes and stores other objects such as programs, files, and data. It functions similarly to a directory or folder in other operating systems but has enhanced security, object-based management, and integrated access control.

How Does a Library Work in AS/400?

1. Structure of Libraries :
  • Libraries are part of the Integrated File System (IFS) in IBM i.
  • Unlike traditional directories, libraries store objects, not just files.
  • Each object type (e.g., programs, physical files, logical files, message queues) has system-defined attributes and cannot be modified like standard files.
2. Library List (LIBL) :
  • IBM i uses a Library List (LIBL) to determine which libraries are searched when executing commands or programs.
  • The library list follows a specific order:
    1. System Libraries (e.g., QSYS, QGPL) – IBM-supplied libraries.
    2. Current Library (CURLIB) – User’s primary working library.
    3. User Libraries – Custom application and data libraries.
    4. Product Libraries – Third-party or IBM-supplied software libraries.
3. Types of Libraries :
Library Type Purpose
QSYS System library containing IBM-supplied objects.
QGPL General purpose library for shared use.
QTEMP Temporary library that exists only for the job duration.
User Libraries Custom libraries created by users to store programs and data.
Product Libraries Contain third-party or IBM software components.
4. Library Security & Authority :
  • IBM i provides object-level security for libraries.
  • Authorities include read, write, execute, delete, and management permissions.
  • Security settings can be assigned at the user, group, or system level.


Commands for Managing Libraries :

Command Function
CRTLIB Create a new library.
WRKLIB Work with libraries (view/manage).
DSPLIB Display library contents.
DLTLIB Delete a library.
CHGLIB Change library attributes.

Example :
To create a library called MYLIB, use :

CRTLIB LIB(MYLIB)

To add MYLIB to the current session’s library list :

ADDLIBL LIB(MYLIB)

 

Advantages of Using Libraries in IBM i :

* Efficient Organization – Stores objects logically for easy access.
* Security & Access Control – Provides granular control over who can access or modify objects.
* Performance Optimization – System searches objects based on the Library List (LIBL), improving efficiency.
* Backward Compatibility – Applications remain functional across system upgrades.