ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How do I determine the size of a library

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I determine the size of a library

    How do I determine the number of files in a library and the size of the library?

    Thanks,

    DAC

  • #2
    Re: How do I determine the size of a library

    Hi dcutaia:

    Use the following on your library of choice:
    Code:
    DSPOBJD OBJ(MYLIB/*ALL) OBJTYPE(*ALL) OUTPUT(*OUTFILE) OUTFILE(QTEMP/JUNK)
    You now have a file (qtemp/junk) of all objects in mylib. Use your favorite sql/qry program to sum ODOBSZ selecting the object type of interest.

    Hope that helps
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: How do I determine the size of a library

      Code:
      SBMJOB CMD(DSPLIB LIB(YourLib) OUTPUT(*PRINT))
      Then go to the bottom of the generated spool file.

      Comment


      • #4
        Re: How do I determine the size of a library

        You can also use:
        PHP Code:
        DSPLIB LIB(MYLIBOUTPUT(* ) 
        Here you can get the list of all objects in that particular library as well as Total number of objects. No need to count manually.
        Last edited by abhishek_ec002; April 9, 2008, 10:57 PM.
        Thanks,

        Abhishek KUMAR

        Comment


        • #5
          Re: How do I determine the size of a library

          This one is maybe not the must beautiful way to do it, but it works.

          Create the following CL program named for example DSPLIBSIZE



          Code:
          Pgm Parm(&Lib)                                                                          
            dcl  &Lib     *char len(10)                                                           
            dcl  &Size    *dec  len(15)                                                           
            dcl  &MbSize  *dec  len(9 3)                                                          
            dcl  &MbSize_ *char len(9)                                                            
            dcl  &Mega    *dec  len(15) value(1048576)                                            
                                                                                                  
            Dclf  QADSPOBJ                                                                        
                                                                                                  
          * Display Object Description for all objects in the library into "LibSize" in qtemp */  
            DspObjD   Obj(&Lib/*All) ObjType(*All) OutPut(*OutFile) OutFile(Qtemp/LibSize)        
            OvrDbf    File(QADSPOBJ) ToFile(Qtemp/LibSize)                                        
          /* Loop through all the records in the file af add object size to &Size */                           
          Loop:                                                                                                
             Rcvf                                                                                              
             MonMsg (cpf0000) exec(goto eof)                                                                   
             ChgVar &Size (&Size + &OdObSz)                                                                    
             goto loop                                                                                         
                                                                                                               
          Eof:                                                                                                 
                                                                                                               
          /* Calculate mega bytes */                                                                           
             ChgVar &MbSize (&Size / &Mega)                                                                    
                                                                                                               
             ChgVar &MbSize_ &MbSize /* Convert to char */                                                     
             SndPgmMsg MsgId(cpf9898) Msgf(QCPFMSG) MsgDta('Library size in mega bytes :' !> &Lib !> &MbSize_) 
                                                                                                               
          EndPgm

          You can then call the program by

          Call dsplibsize Mylib

          And the program writes a message back to you with the size of the library


          I hope this can help you.


          Regards

          Bent

          Comment


          • #6
            Re: How do I determine the size of a library

            You need to use the Retrieve Library Description (QLIRLIBD) API which is straightforward to get the library size along with the number of objects in library. This API is easy to use.
            Use key 6 to get the size and key 7 to get the count of objects
            Philippe

            Comment


            • #7
              Re: How do I determine the size of a library

              again from my second favorite website...If you ever need an api go here first.


              Code:
              Thanks to Vern Hamberg
              
              Retrieve library description
              It is used in a loop based on DSPOBJD *ALL *LIB OUTPUT(*OUTFILE). 
              It puts the library name, size, and description to your joblog.
              
              	dcl &rtnvar *char 104
              	dcl &rtnlen *char 4 x'00000068'
              	dcl &attrib *char 12 x'000000020000000500000006'
              	dcl &desc *char 50
              	dcl &size *dec (9 0)
              	dcl &mult *dec (9 0)
              	dcl &sizedec *dec (15 0)
              	dcl &sizechar *char 15
              	call qlirlibd (&rtnvar +
              	                &rtnlen +
              	                &odobnm +
              	                &attrib +
              	                x'0000000000000000')
              	chgvar &desc %sst(&rtnvar 29 50)
              	chgvar &size %bin(&rtnvar 93 4)
              	chgvar &mult %bin(&rtnvar 97 4)
              	chgvar &sizedec (&size * &mult)
              	chgvar &sizechar &sizedec
              	sndpgmmsg (&odobnm *cat ' ' *cat &sizechar +
              	                    *cat ' ' *cat &desc)
              found this monster @ IBM itself ... hmmmm



              Code:
                     
              
              IBM Software Technical Document
              __________________________________________________________________ 
               Document Information 
               Document Information 
              Document Number: 17284402  
              Functional Area:  Operating System 
              Subfunctional Area:  Library Lists/Librarian 
              Sub-Subfunctional Area:  General 
              OS/400 Release: V4R5M0; V5R1M0; V5R2M0; V5R3M0; V5R4M0 
              Product:  Operating System/400 - OS/400 WORK MGMT (5769SS1WM)
              OS/400 WORK MGMT (5722SS1WM) 
              Product Release: N/A 
              
              
              __________________________________________________________________
              
              Document Title 
              CL Program to Retrieve Library Size and Number of Objects
              
              Document Description
              This provides the listing of a CL program that can be called from the command line to obtain the number of objects in a library and the size of the library. Assuming the program is creating with program name RTVLAPI, the program can be called. On the operating system command line, type the following:
              
              
              
              
              /*******************************************************************/
              /*                                                                 */
              /*  MODULE NAME:  RTVLAPI                                          */
              /*                                                                 */
              /*  FUNCTION:                                                      */
               /*                This test program uses the "Retrieve Library     */
              /*                Description" API, QLIRLIBD, to return both       */
              /*                the number of objects in the library and the     */
              /*                library size.                                    */
              /*                                                                 */
              /*  INPUT:                                                         */
              /*                                                                 */
              /*    PARAMETER LIST:                                              */
              /*                                                                 */
              /*    #1  LIBNAME   The library name for which information         */
              /*                  is being returned.                             */
               /*                                                                 */
              /*                  No special values such as *CURLIB are          */
              /*                  allowed.                                       */
              /*                                                                 */
              /*  OUTPUT:  The information returned by the QLIRLIBD              */
               /*           is output to the display with several                 */
               /*           messages.  An example of the output for library CAROL:*/
              /*                                                                 */
              /*           Info for library               CAROL                  */
              /*           # of objects in library        000000000000004        */
              /*           Library size                   000000000569344        */
              /*           Library size multiplier        000000000000001        */
              /*           Size of all objects used in library size              */
              /*                                                                 */
              /*           Following is a further description of the output:     */
               /*           - Library size                                        */
              /*             - The size of the library object and all of the     */
              /*               objects in the library in units of the library    */
              /*               size multiplier.                                  */
              /*           - Library size multiplier                             */
              /*             - The value used to multiply the library size by    */
              /*               to get the total library size.  Values returned:  */
              /*               1             The library size is smaller than    */
              /*                             1,000,000,000 bytes.                */
              /*               1024          The library size is between         */
              /*                             1,000,000,000 and                   */
              /*                             1,024,000,000,000 bytes             */
              /*               1048576       The library size is larger than     */
              /*                             1,024,000,000,000 bytes             */
              /*           - Message indicating that "Size of all objects        */
               /*             used in library size".                              */
              /*                                                                 */
              /*             Indicates that there were no objects locked and     */
              /*             the user had some authority to all of the objects.  */
              /*             If some objects were locked or the user didn't      */
              /*             have authority, you would see messages:             */
              /*                                                                 */
              /*             "Some objects locked or not authorized."            */
              /*             "Library size does not include all objects."        */
              /*                                                                 */
              /*******************************************************************/
              PGM PARM(&LIBNAME)
              
              /*  . . . . . . . .   Define Program Variables  . . . . . . . . .   */
              
              /*  Parameters                                                      */
              DCL  VAR(&LIBNAME)   TYPE(*CHAR)  LEN(10)
              
              /*  Message to display to user                                      */
               DCL  VAR(&MSG)        TYPE(*CHAR) LEN(103)
              
              /*  Variables for calling QLIRLIBD API                              */
              DCL  VAR(&BYTESP)    TYPE(*DEC)   LEN(8)   VALUE(0)
              DCL  VAR(&KEY1)      TYPE(*DEC)   LEN(8)
              DCL  VAR(&KEY2)      TYPE(*DEC)   LEN(8)
              DCL  VAR(&LIBSIZ)    TYPE(*DEC)   LEN(15 0)
              DCL  VAR(&LIBSIZM)   TYPE(*DEC)   LEN(15 0)
              DCL  VAR(&LIBCNT)    TYPE(*DEC)   LEN(15 0)
              DCL  VAR(&NBRVARREC) TYPE(*DEC)   LEN(8)
              DCL  VAR(&RCVLD)     TYPE(*DEC)   LEN(8)   VALUE(200)
              DCL  VAR(&ERRCODE)   TYPE(*CHAR)  LEN(4)
              DCL  VAR(&INFSTAT)   TYPE(*CHAR)  LEN(1)
              DCL  VAR(&RCVL)      TYPE(*CHAR)  LEN(4)
              DCL  VAR(&RCVVAR)    TYPE(*CHAR)  LEN(200)
              DCL  VAR(&RTVINFO)   TYPE(*CHAR)  LEN(16)
              
              /*  Variables for decimal to character conversion                   */
              DCL  VAR(&CHARCNV)   TYPE(*CHAR)  LEN(15)
              
              /*  Set up to call the API:                                         */
              /*  Parms                                                           */
              /*  - RCVVAR       Receiver variable to receive the information     */
               /*  - RCVL         Length of the receiver variable                  */
              /*  - LIBNAME      Library name to return info for                  */
              /*  - RTVINFO      Defines attributes of library to retrieve        */
              /*    - NBRVARREC  Number of keys requested.  Two keys              */
               /*                                      are requested               */
              /*    - KEY1       Return info for key 6, library size.             */
              /*    - KEY2       Return info for key 7, number of objects in lib. */
              /*                                                                                                                         */
              CHGVAR VAR(&KEY1)               VALUE(6)
              CHGVAR VAR(&KEY2)               VALUE(7)
              CHGVAR VAR(&NBRVARREC)          VALUE(2)
              CHGVAR VAR(%BIN(&RTVINFO 1 4))  VALUE(&NBRVARREC)
              CHGVAR VAR(%BIN(&RTVINFO 5 4))  VALUE(&KEY1)
              CHGVAR VAR(%BIN(&RTVINFO 9 4))  VALUE(&KEY2)
              CHGVAR VAR(%BIN(&ERRCODE))      VALUE(&BYTESP)
              CHGVAR VAR(%BIN(&RCVL))         VALUE(&RCVLD)
              
              /*  Call the QLIRLIBD API                                           */
              CALL PGM(QLIRLIBD) PARM(&RCVVAR &RCVL &LIBNAME &RTVINFO &ERRCODE)
              
              /*  Process the information returned by the QLIRLIBD API.           */
               /*  Return info about library size, key 6.                          */
              CHGVAR VAR(&KEY1)               VALUE(%BIN(&RCVVAR 21 4))
              CHGVAR VAR(&LIBSIZ)             VALUE(%BIN(&RCVVAR 29 4))
              CHGVAR VAR(&LIBSIZM)            VALUE(%BIN(&RCVVAR 33 4))
              CHGVAR VAR(&INFSTAT)            VALUE(%SST(&RCVVAR 37 1))
              /*  Return info about count of objects, key 7.                      */
              CHGVAR VAR(&KEY2)               VALUE(%BIN(&RCVVAR 45 4))
              CHGVAR VAR(&LIBCNT)             VALUE(%BIN(&RCVVAR 53 4))
              
              /*********************************************************************/
              /* Display info returned from QLIRLIBD API                           */
              /*********************************************************************/
              CHGVAR     VAR(&MSG)       +
                         VALUE('Info for library             ')
              CHGVAR     VAR(%SST(&MSG 32 10)) VALUE(&LIBNAME)
              SNDPGMMSG  MSG(&MSG)
              
              /* Convert the decimal values returned to character values   */
              CHGVAR  VAR(&CHARCNV)   VALUE(&LIBCNT)
              
              CHGVAR     VAR(&MSG)       +
                         VALUE('# of objects in library      ')
               CHGVAR     VAR(%SST(&MSG 32 15)) VALUE(&CHARCNV)
              SNDPGMMSG  MSG(&MSG)
              
              /* Convert the decimal values returned to character values   */
              CHGVAR  VAR(&CHARCNV)   VALUE(&LIBSIZ)
              
              CHGVAR     VAR(&MSG)       +
                         VALUE('Library size                 ')
              CHGVAR     VAR(%SST(&MSG 32 15)) VALUE(&CHARCNV)
              SNDPGMMSG  MSG(&MSG)
              
              /* Convert the decimal values returned to character values   */
              CHGVAR  VAR(&CHARCNV)   VALUE(&LIBSIZM)
              
              CHGVAR     VAR(&MSG)       +
                         VALUE('Library size multiplier      ')
              CHGVAR     VAR(%SST(&MSG 32 15)) VALUE(&CHARCNV)
              SNDPGMMSG  MSG(&MSG)
              
              /* Check if the library size includes all objects in the library.    */
              IF (&INFSTAT = '1') THEN(DO)
                CHGVAR     VAR(&MSG)       +
                           VALUE('Size of all objects used in library size.')
                SNDPGMMSG  MSG(&MSG)
              ENDDO
              ELSE DO
                SNDPGMMSG  MSG('Some objects locked or not authorized.')
                SNDPGMMSG  MSG('Library size does not include all objects.')
              ENDDO
              
              ENDPGM
              and if your into killin mosquitoes with cannons here is a nice
              example downloaded from

              Attached Files
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: How do I determine the size of a library

                Originally posted by jamief View Post
                again from my second favorite website...If you ever need an api go here first.
                Great site!! Thanks for letting me know about it!!
                http://www.linkedin.com/in/chippermiller

                Comment

                Working...
                X