Library in AS400

Introduction to Library in AS400

Library,how to create library,as400 library,library in AS400,QSYS,System library,User Library,Product Library,Current Library,QHLPSYS,QUSRSYS,CHGCURLIB,CHGCURLIB,ASP,Auxiliary storage pool,Library commands,DSPLIBL,QUSRLIBL, CHGSYSLIBL, DSPSYSVAL, Library in AS400, Library in IBMi, library list in as400,how to add library in library list,CRTLIB,Library type,DSPLIB,EDTLIBL,edit library list,ADDLIBLE,add library in library list,WRKLIBPDM,to see all objects in a library
Library in AS400

Introduction

AS/400 system is an object-oriented system which means that everything on AS/400 system is an object. Now the question arises in our mind that where actually these objects reside in the AS/400 system. Any guess?

The answer to your question is the Library. A library is a collection of objects and itself an object of type *LIB.

The library contains database files, programs, etc. Also, It is used as a system directory(*DIR) to keep track of the other objects.

We can move or copy the objects of one library to the other library at any time we want. To locate an object we must qualify that object with its library for example LIB1/OBJECT1. The CL language commands are used to move or copy objects from one library to other.

As we come to know the library is in itself an object and contains other objects of different types except for libraries objects(*LIB) but what about the library where it gets stored?

In simple terms, we say library objects reside in a library whose name is QSYS library. Does It mean a library can store another library?

Oh no! this gonna create confusion among us but don't get confused with this. QSYS is the only library that stores other library objects but no other library can store a library object in itself.

You can every library object that appears to be inside QSYS even the QSYS itself as shown below. So it's a root library where all the system and user-defined, product libraries get created.

QSYS Library

QSYS library, AS400 library concept, IBMi libraries, system library in as400, qsys, root library in AS400
QSYS library

  • Library Objects in QSYS

Therefore, whatever library you create that gets created inside root library QSYS. For example in my case, my library name starts with EASYCLASS* gets created inside the QSYS library as shown below.

Library object inside QSYS, system library in as400, user defined library in as400, QSYS library in AS400, QSYS in IBMi
Library objects inside QSYS

System library

In general, all the libraries created by IBM for OS use begin with the letter 'Q' such as QSYS (System root library), QSYS2 (System library for CPI's, 

QSYS2, QSYS2 library in QSYS library in AS400 IBMi
QSYS2

QGPL (General purpose library)

QGPL library in AS400, general purpose library in AS400
QGPL

QTEMP 

(Job/session-specific temporary library created when the Job/session starts or deleted when the Job/session ends), etc. QTEMP is a TEST library while others are PROD libraries. You will get detailed information about TEST or PROD libraries type in the below blog.

QTEMP,QTEMP library, Temporary Job specific library in AS400, QTEMP library in IBMi
QTEMP

Product library

The product library is supplied with IBM products and gets added to the library list automatically when any IBM product is used internally and removed from the library list when the product Job finished. For example, I am going to use the IBM product Code Coverage explicitly and IBM provided the product library QDEVTOOLS for that purpose so I need to add the QDEVTOOLS library to the library list before using the IBM Code Coverage product in my Job.

Product library, Product library in AS400,Product library in IBMi, QDEVTOOLS
QDEVTOOLS, a product library

User-defined library

Libraries are created by users using the CL command CRTLIB. You need to specify the library name its type and text etc.

CRTLIB command prompt

We can provide the Library Type above as either *PROD or *TEST which is displayed on the above CRTLIB screenshot. Now, what each value means let's discuss them one by one.

  • *PROD

During library creation using CRTLIB command the default value for the Library type is *PROD i.e. production library. If we create a library of type *PROD then it specifies that whether or not database files in a production library can be opened for updating records, or for adding new records, while the job is in DEBUG mode.

If we specify *NO in the update production files (UPDPROD) parameter on the Start Debug (STRDBG) command then Database files in production libraries cannot be updated while the job is in debug mode. Database files can be opened for reading purposes only.

STRDBG parameter UPDPROD, strdbg, update production files in AS400, *PROD library type i as400
STRDBG command, UPDPROD parameter

  • *TEST

All the objects present inside the Test libraries can be updated during testing even if UPDPROD is specified as *NO on the Start Debug (STRDBG) command.

Library List

We heard the term library list in the above blog, so let's discuss the concept of a library list. To find an object we need to provide its path, so here we must qualify an object with the library name for its searching, for example, LIB1/FILE1 which means we are pointing to an object named FILE1 in library LIB1.

What about when we do not qualify the objects with their library name or we do not provide the path where to find that object then how the system decides where to look for that object the answer is an object called a library list (*LIBL) in AS400 which is similar to PATH in Unix and MS-DOS. 

This library list specifies which libraries will get searched and in what order for an object. A default library list is automatically created by the operating system of the AS400 system for each job being started. Your default library i.e. same name as the User profile automatically added to the library list.

Display Library List (DSPLIBL)

CL command DSPLIBL is used to display the library list.
DSPLIBL, Display library list in AS400, Display library list in ibmi, DSPLIBL cl command to display library list
DSPLIBL

What you see above from the DSPLIBL screenshot shows you the type of libraries such as SYS(System library), CUR (Current library), and USR(User library) as part of the library list. 

Warning!
For your information, we can have a maximum of up to 15 system libraries and 250 user libraries in the library list.

Now let's discuss the Types of libraries in brief in the library list.

A Job/session library list consists of four sections namely, SYS, PROD, CUR, and USR.

  • System portion

The system libraries are always present at the top of the library list such as QSYS, QSYS2, QHLPSYS, QUSRSYS as shown in the above DSPLIBL screenshot. There can max 15 System libraries present on the library list.

Please note that the default system libraries portion on the library list is specified in the system value QSYSLIBL.

To see the content of the system value QSYSLIBL use the following command on the command line.

    • DSPSYSVAL/QSYSLIBL

System part of the library list

DSPSYSVAL QSYSLIBL, QSYSLIBL
DSPSYSVAL QSYSLIBL

  • Product portion

When any CL command got executed then the product library for that CL command gets added to the library list and removed once that command ends.

  • Current Library

This is a special library that is associated with the User profile so once users log in this library is added to the library list automatically and there can be only one current library at a time on the library list. In our case, the current library is EASYCLASS1 if you refer above DSPLIBL screenshot.

You can change the current library at any time using the CL command CHGCURLIB on the command line.

CHGCURLIB, change current library in AS400, change current library in IBMi
CHGCURLIB

  • User portion

This comes at the last of the library list that contains all the user-specified application libraries. Some user libraries are QTEMP, QGPL, etc. Users can add the library to the library list, edit the library list, change the library list and remove the library from the library list as follows.

The user portion of the library for any Job can be stored in JOBD (Job Description) so that when a Job starts it will use the library list specified on the JOBD. But Job descriptions can have a value of *SYSVAL which means that library list information must be looked into the system value QUSRLIBL.

    • DSPSYSVAL QUSRLIBL

DSPSYSVAL QUSRLIBL, QUSRLIBL, QUSRLIBL system value in AS400, QUSRLIBL system value in IBMi
DSPSYSVAL QUSRLIBL

ADDLIBLE (Add library list entry) 

Add a user library to the library list at some position on the library list such as *FIRST, *LAST, etc
ADDLIBLE, Add Library list entry, ADDLIBLE in AS400, ADDLIBLE in IBMi
ADDLIBLE

EDTLIBL (Edit Library List)

EDTLIBL, Edit library List, EdTLIBL in AS400, EDTLIBL in IBMi, Edit library list in AS400, Edit library list in IBMi
EDTLIBL

CHGLIBL (Change Library List)

CHGLIBL, CHGLIBL in A00, CHGLIBL in IBMi, Change library List in AS400
CHGLIBL

RMVLIBLE (Remove Library List Entry)

RMVLIBLE, Remove library list entry, as400, ibmi
RMVLIBLE

Related Post

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain