Hi Tom,
I have tried with that QLIRLIBD but I didnt got how to use that actually.
So, I'm not getting the result.
Can you please send me a sample program for my understand purpose.
Thanking You
How can I get the size of a Library in AS400
For example in case of a physical file using DSPFD & output (*OUTFILE) we can get the size of that particular physical file that means the number of records present in that particular Physical file.
In the same way can we get the size of a particular library that means the number of objects present in that library by any other process.
Thanking You
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Murph,
By using DSPOBJD I'm getting the size of individual objects only but not the size of the complete Library.
Using that command how can i get the Size of Whole Library ?
And Please tel me this also....How can I get the size of each library present in the server individually that too at a time.
Thanking you
Bsidmis:
First, Murph's answer about using DSPOBJD to an *outfile is the way most people would do this. It's probably the way that you should start. You run DSPOBJD with *ALL objects of *ALL types from the library that you want, to an *outfile. You can put the *outfile in QTEMP. Then you query the *outfile and sum the sizes.
If you want to include the size of the library object, you can run DSPOBJD again for just the *LIB object and *ADD that record to the *outfile. If you do that before you run a query, the size of the library object can be included in the sum.
But it takes as much learning to write a program to handle *outfiles as it does for an API. File handling can be as confusing as anything else. You might as well get some experience with an API.
So, I'm attaching a program that uses the QLIRLIBD API to get the size directly. The program is a little more complicated because I included retrieving the count of objects at the same time. That will give you something to study on how this API works. If you learn this API, many other APIs will be much easier in the future.
One of the first things you might want to do is make a copy and strip out the comments. I didn't take any time to make the comments pretty. They mostly just might help you to compare against the IBM documentation.
Also, I didn't put any error handling in. That's an important part of any program, but one step at a time...
It should have taken only an hour or so to put this together, but I ran into a little V5R4 bug. It's described in APAR SE31456 and it's never going to be fixed (permanent V5R4 restriction). It showed up in the dumps that I included. The DMPCLPGM at the end can be removed -- I put dump commands in CL programs for testing. If you're interested, the APAR is at:
http://www-912.ibm.com/n_d
Anyway, you call the program this way:
==> call yourlib/tstlibsiz 'BSIDMIS'
If the library name you want to size is 'BSIDMIS', then the program will display a message telling how much space the library uses and how many objects are in it. For a library with many objects, it can take a while to run. Files like source files with many members will take more time because each member must be checked. Also, every object must be tested against your authority (and each member is tested.)
The authority and size tests will also take time if you run Murph's suggestion with DSPOBJD, so the two techniques are the same for that. But this method doesn't require creating any new file and the values can be retrieved directly from each library object.
The program reports the size by using the SNDPGMMSG command to send a message out of the program. If you submit it to batch, the message will go into the joblog. If you call the program multiple times, there will be a new message for each library.
I didn't format the message -- I just converted the numbers to characters. The program can be changed to put the values somewhere else. Putting values in a message is one way to see what values are being reported. If you use a SNDMSG command instead, you could have each message go into a message queue that you could look at later.
Use the program to study. See if you can get it into a source file and compile it. Run it a couple times to see how it works.
And ask questions.
Tom
Hi Tom,
I don't kow why you say "But it takes as much learning to write a program to handle *outfiles",
handling an outfile is as much work as any other file, so 1 minute in SQL 10 Minutes in RPG and if a view is created on the outfile then the RPG is even faster or you skip RPG and read the result in CL.
By the view I mean something like:
CREATE VIEW mylibsize AS SELECT libname, sum(size) FROM outfile GROUP BY libname
Regards,
Murph
Murph:
An *outfile from a command needs a record format. This typically requires determining what the format looks like so you can compile over it. And that typically involves locating the IBM model file and setting up overrides to handle the real eventual file I/O. And the eventual I/O typically involves reading multiple records, summation, handling EOF (plus file errors, data types, format changes in future releases), or learning SQL and the execution of it.
IMO, it's just as easy to call an API and grab the values directly. Just opinion, but we might forget how much has gone into the learning we all did over the years for *outfiles.
Tom
Hi Tom,
Maybe you are right, til now I find programming API's a very complex activity, maybe because my experience with RPG that I handle outfiles very fast. and for handling outfiles in CL, you don't need the record format, only the field names you need.
But maybe you are right and I have to investigate more in how to program API's.
Regards,
Murph
Business Accounts
Answer for Membership
by: tliottaPosted on 2009-01-11 at 01:32:03ID: 23347565
Bsidmis:
~tliotta/F iles/Show_ Library_Si ze/ Show_Li brary_Size _README.ht m
A general proc to retrieve library size can be studied here:
http://home.earthlink.net/
In general, the Retrieve Library Description (QLIRLIBD) API is called and the total 'size' of the objects contained in the library is returned. (The example also retrieves the count of objects in the library.)
For a bit more info, the example also uses the RTVOBJD command to retrieve the size of the library object itself. The library object may get quite large as it encapsulates a list of the objects within it among other things.
Details can be discussed as you need them.
Tom