Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Is there a way to find out number of objects in each library of the system?
Hi SF,
Interactively you'd run a DSPLIB on each library. This command will give you the count of objects in the specified library.
As it maybe a but tedious to perform this task manually, IBM has invented an API for this very purpose - QLIRLIBD. You can find its specifics at the link below (for version 5.4). No doubt there's a bunch of examples on how to use it in RPG out on the big ole web, check with our friends at google.
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapifinder%2Ffinder.htm
Good luck,
Paulster
Didn't know about that one. I would have called QUSLOBJ or done DSPOBJD to *OUTFILE. Without actually testing, I'm going to test that QLIRLIBD is probably faster.
Just curious, why would you want to know the number of objects in a library? Can't recall that ever having been a useful bit of information.
Hi Paulster & DaleB,
Thanks for your suggestions. I will try QLIRLIBD.
We are trying to migrate from V5R3 to V5R4 and the current number of libraries in production environment is 3500 and development environment is 4500. Trying to find out possible libraries that can be moved off line.
Regards,
SF.
Not sure how number of objects in each library would help with that. I should think object lists would be more useful, primarily by checking the last used date.
Don't know if this would help, but my last round of cleanups was to save each candidate to SAVF named OFFLOAD/libname, then delete the library. SAVF with compression should free up some disk space immediately. Keeping them in SAVF for a while allowed for quick restore in case the library shouldn't have been deleted. Eventually the SAVF were migrated to tape.
In my upcoming "Cozzi Utilities 2012" library, there's a DSPLIBSIZE or something like that. It returns the library size and object count using the above mentioned API. Here's the code:
.....H NOMAIN BNDDIR('QC2LE') OPTION(*SRCSTMT:*NODEBUGIO) ** (c) Copyright 2003 by Robert Cozzi, Jr. D GetLibSize PR 20I 0 D libName 10A Const D rtnLibSize 20I 0 Options(*NOPASS : *OMIT) D rtnObjCount 20I 0 Options(*NOPASS) /COPY QSYSINC/QRPGLESRC,QUSEC D libInfoKeys_T DS Qualified Inz D count 10I 0 D key 10I 0 Dim(8) D libKeys DS LikeDS(libInfoKeys_T) Inz ** Retrieve Library De!--script--ion D QLIRLIBD PR EXTPGM('QLIRLIBD') D szLibInfo 256A Options(*VARSIZE) D nLibInfoLen 10I 0 Const D szLibrary 10A Const D Keys LikeDS(libInfoKeys_T) D api_error LikeDS(QUSEC) OPTIONS(*VARSIZE) D keyLibSize C Const(6) D keyObjCount C Const(7) D libSize S 20I 0 D objCount S 20I 0 ** ------------------------------------------ ** G E T L I B S I Z E -- (Get Library Size) ** Retrieve library size and object count ** ------------------------------------------ P GetLibSize B Export D GetLibSize PI 20I 0 D libName 10A Const D rtnLibSize 20I 0 Options(*NOPASS : *OMIT) D rtnObjCount 20I 0 Options(*NOPASS) ** Inz(%offset(rtvData.szData)) D nOffset S 10I 0 Inz(17) D rtvData DS Qualified Inz D bytesRtn 10I 0 D bytesAvail 10I 0 D nRecCnt 10I 0 D nRecAvail 10I 0 D szData 256A D varRec DS Qualified Inz D rtnLen 10I 0 D key 10I 0 D size 10I 0 D data 32A D myAPIError DS LikeDS(QUSEC) Inz(*LIKEDS) D ObjCount DS Qualified Inz D count 10I 0 D LibSize DS Qualified Inz D scale 10I 0 D Multiplier 10I 0 D bStatus 1A D szReserv3 3A C Clear libkeys C eval libkeys.key(1) = keyLIBSIZE C eval libKeys.count = 1 C eval libKeys.key(2) = keyObjCount C eval libKeys.count += 1 C CallP QLIRLIBD(rtvData : %size(rtvData) : C libName : libKeys : myApiError) C DO libKeys.count C eval varRec = %Subst(rtvData : nOffset) C eval nOffset += varRec.rtnLen C Select C When varrec.Key = keyLIBSIZE C eval LibSize = %Subst(varrec.data:1:varRec.size) C eval rtnLibSize=libsize.Scale * libSize.multiplier C When varrec.Key = keyObjCount C eval ObjCount = %SubSt(varrec.data:1:varrec.size) C eval rtnObjCount = objcount.count C endsl C enddo C return rtnLibSize P GetLibSize E
I used QLIRLIBD and it is quite good as it also indicates if all objects in a library could be accessed or not to calculate the size of library. Some objects may not be included due to lack of authority.
Definitely last used date will be used to identify things that have not been used for a long time. However I am trying to see if number of objects can be used to identify libraries that should not be there at all even if they are used very recently.