251 lines
12 KiB
HTML
251 lines
12 KiB
HTML
|
<?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: Retrieving a list of information" />
|
||
|
<meta name="abstract" content="" />
|
||
|
<meta name="description" content="" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="pcmllist" />
|
||
|
<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: Retrieving a list of information</title>
|
||
|
</head>
|
||
|
<body id="pcmllist"><a name="pcmllist"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: Retrieving a list of information</h1>
|
||
|
<div><p></p>
|
||
|
<div class="section"><p>This example has two parts:</p>
|
||
|
<ul><li> <a href="#pcmllist__pcmlqgyolaus">PCML source for calling QGYOLAUS</a></li>
|
||
|
<li> <a href="#pcmllist__javaqgyolaus">Java™ program source for calling QGYOLAUS</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="section" id="pcmllist__pcmlqgyolaus"><a name="pcmllist__pcmlqgyolaus"><!-- --></a><h4 class="sectiontitle">PCML source for calling QGYOLAUS</h4><pre><pcml version="1.0">
|
||
|
|
||
|
<!-- PCML source for calling "Open List of Authorized Users" (QGYOLAUS) API -->
|
||
|
|
||
|
<!-- Format AUTU0150 - Other formats are available -->
|
||
|
<struct name="autu0150">
|
||
|
<data name="name" type="char" length="10" />
|
||
|
<data name="userOrGroup" type="char" length="1" />
|
||
|
<data name="groupMembers" type="char" length="1" />
|
||
|
<data name="description" type="char" length="50" />
|
||
|
</struct>
|
||
|
|
||
|
<!-- List information structure (common for "Open List" type APIs) -->
|
||
|
<struct name="listInfo">
|
||
|
<data name="totalRcds" type="int" length="4" />
|
||
|
<data name="rcdsReturned" type="int" length="4" />
|
||
|
<data name="rqsHandle" type="byte" length="4" />
|
||
|
<data name="rcdLength" type="int" length="4" />
|
||
|
<data name="infoComplete" type="char" length="1" />
|
||
|
<data name="dateCreated" type="char" length="7" />
|
||
|
<data name="timeCreated" type="char" length="6" />
|
||
|
<data name="listStatus" type="char" length="1" />
|
||
|
<data type="byte" length="1" />
|
||
|
<data name="lengthOfInfo" type="int" length="4" />
|
||
|
<data name="firstRecord" type="int" length="4" />
|
||
|
<data type="byte" length="40" />
|
||
|
</struct>
|
||
|
|
||
|
<!-- Program QGYOLAUS and its parameter list for retrieving AUTU0150 format -->
|
||
|
<program name="qgyolaus" path="/QSYS.lib/QGY.lib/QGYOLAUS.pgm" parseorder="listInfo receiver">
|
||
|
<data name="receiver" type="struct" struct="autu0150" usage="output"
|
||
|
count="listInfo.rcdsReturned" outputsize="receiverLength" />
|
||
|
<data name="receiverLength" type="int" length="4" usage="input" init="16384" />
|
||
|
<data name="listInfo" type="struct" struct="listInfo" usage="output" />
|
||
|
<data name="rcdsToReturn" type="int" length="4" usage="input" init="264" />
|
||
|
<data name="format" type="char" length="10" usage="input" init="AUTU0150" />
|
||
|
<data name="selection" type="char" length="10" usage="input" init="*USER" />
|
||
|
<data name="member" type="char" length="10" usage="input" init="*NONE" />
|
||
|
<data name="errorCode" type="int" length="4" usage="input" init="0" />
|
||
|
|
||
|
</program>
|
||
|
|
||
|
<!-- Program QGYGTLE returned additional "records" from the list
|
||
|
created by QGYOLAUS. -->
|
||
|
<program name="qgygtle" path="/QSYS.lib/QGY.lib/QGYGTLE.pgm" parseorder="listInfo receiver">
|
||
|
<data name="receiver" type="struct" struct="autu0150" usage="output"
|
||
|
count="listInfo.rcdsReturned" outputsize="receiverLength" />
|
||
|
<data name="receiverLength" type="int" length="4" usage="input" init="16384" />
|
||
|
<data name="requestHandle" type="byte" length="4" usage="input" />
|
||
|
<data name="listInfo" type="struct" struct="listInfo" usage="output" />
|
||
|
<data name="rcdsToReturn" type="int" length="4" usage="input" init="264" />
|
||
|
<data name="startingRcd" type="int" length="4" usage="input" />
|
||
|
<data name="errorCode" type="int" length="4" usage="input" init="0" />
|
||
|
</program>
|
||
|
|
||
|
<!-- Program QGYCLST closes the list, freeing resources on the server -->
|
||
|
<program name="qgyclst" path="/QSYS.lib/QGY.lib/QGYCLST.pgm" >
|
||
|
<data name="requestHandle" type="byte" length="4" usage="input" />
|
||
|
<data name="errorCode" type="int" length="4" usage="input" init="0" />
|
||
|
</program>
|
||
|
</pcml></pre>
|
||
|
</div>
|
||
|
<div class="section" id="pcmllist__javaqgyolaus"><a name="pcmllist__javaqgyolaus"><!-- --></a><h4 class="sectiontitle">Java program source for calling QGYOLAUS</h4><pre>import com.ibm.as400.data.ProgramCallDocument;
|
||
|
import com.ibm.as400.data.PcmlException;
|
||
|
import com.ibm.as400.access.AS400;
|
||
|
import com.ibm.as400.access.AS400Message;
|
||
|
|
||
|
// Example program to call "Retrieve List of Authorized Users" (QGYOLAUS) API
|
||
|
public class qgyolaus
|
||
|
{
|
||
|
|
||
|
public static void main(String[] argv)
|
||
|
{
|
||
|
AS400 as400System; // com.ibm.as400.access.AS400
|
||
|
ProgramCallDocument pcml; // com.ibm.as400.data.ProgramCallDocument
|
||
|
boolean rc = false; // Return code from ProgramCallDocument.callProgram()
|
||
|
String msgId, msgText; // Messages returned from the server
|
||
|
Object value; // Return value from ProgramCallDocument.getValue()
|
||
|
|
||
|
int[] indices = new int[1]; // Indices for access array value
|
||
|
int nbrRcds, // Number of records returned from QGYOLAUS and QGYGTLE
|
||
|
nbrUsers; // Total number of users retrieved
|
||
|
String listStatus; // Status of list on the server
|
||
|
byte[] requestHandle = new byte[4];
|
||
|
|
||
|
System.setErr(System.out);
|
||
|
|
||
|
// Construct AS400 without parameters, user will be prompted
|
||
|
as400System = new AS400();
|
||
|
|
||
|
try
|
||
|
{
|
||
|
// Uncomment the following to get debugging information
|
||
|
//com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);
|
||
|
|
||
|
System.out.println("Beginning PCML Example..");
|
||
|
System.out.println(" Constructing ProgramCallDocument for QGYOLAUS API...");
|
||
|
|
||
|
// Construct ProgramCallDocument
|
||
|
// First parameter is system to connect to
|
||
|
// Second parameter is pcml resource name. In this example,
|
||
|
// serialized PCML file "qgyolaus.pcml.ser" or
|
||
|
// PCML source file "qgyolaus.pcml" must be found in the classpath.
|
||
|
pcml = new ProgramCallDocument(as400System, "qgyolaus");
|
||
|
|
||
|
// All input parameters have default values specified in the PCML source.
|
||
|
// Do not need to set them using Java code.
|
||
|
|
||
|
// Request to call the API
|
||
|
// User will be prompted to sign on to the system
|
||
|
System.out.println(" Calling QGYOLAUS API requesting information for the sign-on user.");
|
||
|
rc = pcml.callProgram("qgyolaus");
|
||
|
|
||
|
// If return code is false, we received messages from the server
|
||
|
if(rc == false)
|
||
|
{
|
||
|
// Retrieve list of server messages
|
||
|
AS400Message[] msgs = pcml.getMessageList("qgyolaus");
|
||
|
|
||
|
// Iterate through messages and write them to standard output
|
||
|
for (int m = 0; m < msgs.length; m++)
|
||
|
{
|
||
|
msgId = msgs[m].getID();
|
||
|
msgText = msgs[m].getText();
|
||
|
System.out.println(" " + msgId + " - " + msgText);
|
||
|
}
|
||
|
System.out.println("** Call to QGYOLAUS failed. See messages above **");
|
||
|
System.exit(0);
|
||
|
}
|
||
|
// Return code was true, call to QGYOLAUS succeeded
|
||
|
// Write some of the results to standard output
|
||
|
else
|
||
|
{
|
||
|
boolean doneProcessingList = false;
|
||
|
String programName = "qgyolaus";
|
||
|
nbrUsers = 0;
|
||
|
while (!doneProcessingList)
|
||
|
{
|
||
|
nbrRcds = pcml.getIntValue(programName + ".listInfo.rcdsReturned");
|
||
|
requestHandle = (byte[]) pcml.getValue(programName + ".listInfo.rqsHandle");
|
||
|
|
||
|
// Iterate through list of users
|
||
|
for (indices[0] = 0; indices[0] < nbrRcds; indices[0]++)
|
||
|
{
|
||
|
value = pcml.getValue(programName + ".receiver.name", indices);
|
||
|
System.out.println("User: " + value);
|
||
|
|
||
|
value = pcml.getValue(programName + ".receiver.description", indices);
|
||
|
System.out.println("\t\t" + value);
|
||
|
}
|
||
|
|
||
|
nbrUsers += nbrRcds;
|
||
|
|
||
|
// See if we retrieved all the users.
|
||
|
// If not, subsequent calls to "Get List Entries" (QGYGTLE)
|
||
|
// would need to be made to retrieve the remaining users in the list.
|
||
|
listStatus = (String) pcml.getValue(programName + ".listInfo.listStatus");
|
||
|
if ( listStatus.equals("2") // List is marked as "Complete"
|
||
|
|| listStatus.equals("3") ) // Or list is marked "Error building"
|
||
|
{
|
||
|
doneProcessingList = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
programName = "qgygtle";
|
||
|
|
||
|
// Set input parameters for QGYGTLE
|
||
|
pcml.setValue("qgygtle.requestHandle", requestHandle);
|
||
|
pcml.setIntValue("qgygtle.startingRcd", nbrUsers + 1);
|
||
|
|
||
|
// Call "Get List Entries" (QGYGTLE) to get more users from list
|
||
|
rc = pcml.callProgram("qgygtle");
|
||
|
|
||
|
// If return code is false, we received messages from the server
|
||
|
if(rc == false)
|
||
|
{
|
||
|
// Retrieve list of server messages
|
||
|
AS400Message[] msgs = pcml.getMessageList("qgygtle");
|
||
|
|
||
|
// Iterate through messages and write them to standard output
|
||
|
for (int m = 0; m < msgs.length; m++)
|
||
|
{
|
||
|
msgId = msgs[m].getID();
|
||
|
msgText = msgs[m].getText();
|
||
|
System.out.println(" " + msgId + " - " + msgText);
|
||
|
}
|
||
|
System.out.println("** Call to QGYGTLE failed. See messages above **");
|
||
|
System.exit(0);
|
||
|
}
|
||
|
// Return code was true, call to QGYGTLE succeeded
|
||
|
|
||
|
}
|
||
|
}
|
||
|
System.out.println("Number of users returned: " + nbrUsers);
|
||
|
|
||
|
// Call the "Close List" (QGYCLST) API
|
||
|
pcml.setValue("qgyclst.requestHandle", requestHandle);
|
||
|
rc = pcml.callProgram("qgyclst");
|
||
|
}
|
||
|
}
|
||
|
catch(PcmlException e)
|
||
|
{
|
||
|
System.out.println(e.getLocalizedMessage());
|
||
|
e.printStackTrace();
|
||
|
System.out.println("*** Call to QGYOLAUS failed. ***");
|
||
|
System.exit(0);
|
||
|
}
|
||
|
|
||
|
System.exit(0);
|
||
|
}
|
||
|
}</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|