如何快速取得 Library 中有多少物件及 Library 的 size?(利用 System API QLIRLIBD)
要取得Library 中有多少物件及 Library 的 size,可利用
System API "Retrieve library Description" API, QLIRLIBD。
File : QCLSRC
Member: RTVLAPI
Type : CLP
Usage : CRTCLPGM RTVLAPI
CAll RTVLAPI library-name
/*******************************************************************/
/* */
/* 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
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期三, 11月 01, 2023
2002-05-25 如何快速取得 Library 中有多少物件及 Library 的 size?(利用 System API QLIRLIBD)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言