ibm-information-center/dist/eclipse/plugins/i5OS.ic.apiref_5.4.0.1/listILECL.htm

259 lines
15 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example in ILE CL: List Object API" />
<meta name="abstract" content="The example program prints a report that shows all objects that adopt owner authority." />
<meta name="description" content="The example program prints a report that shows all objects that adopt owner authority." />
<meta name="DC.Relation" scheme="URI" content="listOverview.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="listILECL" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example in ILE CL: List Object API</title>
</head>
<body id="listILECL"><a name="listILECL"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE CL: List Object API</h1>
<div><p>The example program prints a report that shows all objects that
adopt owner authority.</p>
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important
legal information.</div>
<p>Refer to Example in RPG: List Object API for the
original example.</p>
<pre>/********************************************************************/
/* */
/* Program: List objects which adopt owner authority */
/* */
/* Language: ILE CL */
/* */
/* Description: This program displays all objects that adopt */
/* owner authority. The two parameters passed to */
/* the program are the profile to be checked and */
/* the type of objects to be listed. The parameter */
/* values are the same as those accepted by the */
/* QSYLOBJP API */
/* */
/* APIs Used: QSYLOBJP - List Objects that Adopt Owner Authority */
/* QUSCRTUS - Create User Space */
/* QUSPTRUS - Retrieve Pointer to User Space */
/* QUSROBJD - Retrieve Object Description */
/* */
/********************************************************************/
PGM PARM(&amp;USR_PRF &amp;OBJ_TYPE)
DCL VAR(&amp;USR_PRF) TYPE(*CHAR) LEN(10)
DCL VAR(&amp;OBJ_TYPE) TYPE(*CHAR) LEN(10)
DCL VAR(&amp;ERRCDE) TYPE(*CHAR) LEN(16)
DCL VAR(&amp;BYTPRV) TYPE(*INT) STG(*DEFINED) LEN(4) +
DEFVAR(&amp;ERRCDE)
DCL VAR(&amp;BYTAVL) TYPE(*INT) STG(*DEFINED) LEN(4) +
DEFVAR(&amp;ERRCDE 5)
DCL VAR(&amp;MSGID) TYPE(*CHAR) STG(*DEFINED) LEN(7) +
DEFVAR(&amp;ERRCDE 9)
DCL VAR(&amp;RCVVAR) TYPE(*CHAR) LEN(8)
DCL VAR(&amp;RCVVARSIZ) TYPE(*INT) LEN(4) VALUE(8)
DCL VAR(&amp;SPC_NAME) TYPE(*CHAR) LEN(20) +
VALUE('ADOPTS QTEMP ')
DCL VAR(&amp;SPC_SIZE) TYPE(*INT) LEN(4) VALUE(1)
DCL VAR(&amp;SPC_INIT) TYPE(*CHAR) LEN(1) VALUE(X'00')
DCL VAR(&amp;BLANKS) TYPE(*CHAR) LEN(50)
DCL VAR(&amp;CONTIN_HDL) TYPE(*CHAR) LEN(20)
DCL VAR(&amp;SPCPTR) TYPE(*PTR)
DCL VAR(&amp;LISTHDR) TYPE(*CHAR) STG(*BASED) +
LEN(192) BASPTR(&amp;SPCPTR)
DCL VAR(&amp;LISTSTS) TYPE(*CHAR) STG(*DEFINED) +
LEN(1) DEFVAR(&amp;LISTHDR 104)
DCL VAR(&amp;PARMHDROFS) TYPE(*INT) STG(*DEFINED) +
LEN(4) DEFVAR(&amp;LISTHDR 109)
DCL VAR(&amp;LISTENOFS) TYPE(*INT) STG(*DEFINED) +
DEFVAR(&amp;LISTHDR 125)
DCL VAR(&amp;LISTENTNBR) TYPE(*INT) STG(*DEFINED) +
DEFVAR(&amp;LISTHDR 133)
DCL VAR(&amp;LISTENTSIZ) TYPE(*INT) STG(*DEFINED) +
DEFVAR(&amp;LISTHDR 137)
DCL VAR(&amp;LST_STATUS) TYPE(*CHAR) LEN(1)
DCL VAR(&amp;LSTPTR) TYPE(*PTR)
DCL VAR(&amp;LSTENT) TYPE(*CHAR) STG(*BASED) +
LEN(100) BASPTR(&amp;LSTPTR)
DCL VAR(&amp;OBJECT) TYPE(*CHAR) STG(*DEFINED) +
LEN(10) DEFVAR(&amp;LSTENT 1)
DCL VAR(&amp;CONTIN) TYPE(*CHAR) STG(*DEFINED) +
LEN(20) DEFVAR(&amp;LSTENT 11)
DCL VAR(&amp;CURENT) TYPE(*INT) LEN(4)
CALLSUBR SUBR(INIT)
CALLSUBR SUBR(PROCES)
RETURN
SUBR SUBR(PROCES)
/* */
/* This subroutine processes each entry returned by QSYLOBJP */
/* */
/* Do until the list is complete */
/* */
CHGVAR VAR(&amp;LST_STATUS) VALUE(&amp;LISTSTS)
DOUNTIL COND(&amp;LST_STATUS *EQ 'C')
IF COND((&amp;LISTSTS *EQ 'C') *OR (&amp;LISTSTS *EQ +
'P')) THEN(DO)
/* */
/* And list entries were found */
/* */
IF COND(&amp;LISTENTNBR *GT 0) THEN(DO)
/* */
/* Set &amp;LSTPTR to first byte of the User Space */
/* */
CHGVAR VAR(&amp;LSTPTR) VALUE(&amp;SPCPTR)
/* */
/* Increment &amp;LSTPTR to the first list entry */
/* */
CHGVAR VAR(%OFFSET(&amp;LSTPTR)) VALUE(%OFFSET(&amp;LSTPTR) +
+ &amp;LISTENTOFS)
/* */
/* And process all the entries */
/* */
DOFOR VAR(&amp;CURENT) FROM(1) TO(&amp;LISTENTNBR)
SNDPGMMSG MSG(&amp;OBJECT) TOPGMQ(*EXT)
/* */
/* After each entry, increment &amp;LSTPTR to the next entry */
/* */
CHGVAR VAR(%OFFSET(&amp;LSTPTR)) +
VALUE(%OFFSET(&amp;LSTPTR) + &amp;LISTENTSIZ)
ENDDO
ENDDO
/* */
/* If all entries in this list have been processed, check if */
/* more entries exist than can fit in one User Space */
/* */
IF COND(&amp;LISTSTS *EQ 'P') THEN(DO)
/* */
/* by reseting LSTPTR to the start of the User Space */
/* */
CHGVAR VAR(&amp;LSTPTR) VALUE(&amp;SPCPTR)
/* */
/* and then incrementing &amp;LSTPTR to Input Parameter Header */
/* */
CHGVAR VAR(%OFFSET(&amp;LSTPTR)) VALUE(%OFFSET(&amp;LSTPTR) +
+ &amp;PARMHDROFS)
/* */
/* if the continuation handle is blank then the list is complete */
/* */
IF COND(&amp;CONTIN *EQ ' ') THEN(CHGVAR +
VAR(&amp;LST_STATUS) VALUE('C'))
ELSE CMD(DO)
/* */
/* call QSYLOBP to get more entries */
/* */
CHGVAR VAR(&amp;CONTIN_HDL) VALUE(&amp;CONTIN)
CALLSUBR SUBR(GETLST)
CHGVAR VAR(&amp;LST_STATUS) VALUE(&amp;LISTSTS)
ENDDO
ENDDO
ENDDO
ELSE CMD(DO)
/* */
/* and if unexpected status, log an error */
/* */
SNDPGMMSG MSG('Unexpected status') TOPGMQ(*EXT)
RETURN
ENDDO
ENDDO
ENDSUBR
SUBR SUBR(GETLST)
/* */
/* Call QSYLOBJP to generte a list */
/* The continuation handle is primed by the caller of this */
/* subroutine */
/* */
CALL PGM(QSYLOBJP) PARM(&amp;SPC_NAME 'OBJP0200' +
&amp;USR_PRF &amp;OBJ_TYPE &amp;CONTIN_HDL &amp;ERRCDE)
/* */
/* Check for errors on QSYLOBJP */
/* */
IF COND(&amp;BYTAVL *GT 0) THEN(DO)
SNDPGMMSG MSG('Failure with QSYLOBJP') TOPGMQ(*EXT)
RETURN
ENDDO
ENDSUBR
SUBR SUBR(INIT)
/* */
/* One time initialization code for this program */
/* */
/* Set Error Code structure not to use exceptions */
/* */
CHGVAR VAR(&amp;BYTPRV) VALUE(16)
/* */
/* Check if the User Space was previously created */
/* */
CALL PGM(QUSROBJD) PARM(&amp;RCVVAR &amp;RCVVARSIZ +
'OBJD0100' &amp;SPC_NAME '*USRSPC' &amp;ERRCDE)
/* */
/* Check for errors on QUSROBJD */
/* */
IF COND(&amp;BYTAVL *GT 0) THEN(DO)
/* */
/* If CPF9801, then User Space not found */
/* */
IF COND(&amp;MSGID *EQ 'CPF9801') THEN(DO)
/* */
/* So create a User Space for the list generated by QSYLOBJP */
/* */
CALL PGM(QUSCRTUS) PARM(&amp;SPC_NAME 'QSYLOBJP' +
&amp;SPC_SIZE &amp;SPC_INIT '*ALL' &amp;BLANKS '*YES' +
&amp;ERRCDE '*USER')
/* */
/* Check for errors on QUSCRTUS */
/* */
IF COND(&amp;BYTAVL *GT 0) THEN(DO)
SNDPGMMSG MSG('Failure with QUSCRTUS') TOPGMQ(*EXT)
RETURN
ENDDO
/* */
/* Else an error accessing the User Space */
/* */
ELSE CMD(DO)
SNDPGMMSG MSG('Failure with QUSROBJD') TOPGMQ(*EXT)
RETURN
ENDDO
ENDDO
ENDDO
/* */
/* Set QSYLOBJP (via GETLST) to start a new list */
/* */
CHGVAR VAR(&amp;CONTIN_HDL) VALUE(&amp;BLANKS)
CALLSUBR SUBR(GETLST)
/* */
/* Get a resolved pointer to the User Space */
/* */
CALL PGM(QUSPTRUS) PARM(&amp;SPC_NAME &amp;SPCPTR &amp;ERRCDE)
/* */
/* Check for errors on QUSPTRUS */
/* */
IF COND(&amp;BYTAVL *GT 0) THEN(DO)
SNDPGMMSG MSG('Failure with QUSPTRUS') TOPGMQ(*EXT)
RETURN
ENDDO
ENDSUBR
ENDPGM</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="listOverview.htm" title="List APIs return a list unique to a given API. The section discusses the characteristics of a list API and provides information that you should be aware of when you use list APIs.">List APIs overview</a></div>
</div>
</div>
</body>
</html>