172 lines
9.0 KiB
HTML
172 lines
9.0 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: Simple example of retrieving data" />
|
|
<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="pcmldata" />
|
|
<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: Simple example of retrieving data</title>
|
|
</head>
|
|
<body id="pcmldata"><a name="pcmldata"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Simple example of retrieving data</h1>
|
|
<div><p></p>
|
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
|
example disclaimer</a> for important legal information.</div>
|
|
<p>This simple
|
|
example has two parts:</p>
|
|
<ul><li> <a href="#pcmldata__pcmlqsyrusri">PCML source for calling QSYRUSRI</a></li>
|
|
<li> <a href="#pcmldata__javaqsyrusri">Java™ program source for calling QSYRUSRI</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="pcmldata__pcmlqsyrusri"><a name="pcmldata__pcmlqsyrusri"><!-- --></a><h4 class="sectiontitle">PCML source for calling QSYRUSRI</h4><pre><pcml version="1.0">
|
|
|
|
<!-- PCML source for calling "Retrieve user Information" (QSYRUSRI) API -->
|
|
|
|
<!-- Format USRI0150 - Other formats are available -->
|
|
<struct name="usri0100">
|
|
<data name="bytesReturned" type="int" length="4" usage="output"/>
|
|
<data name="bytesAvailable" type="int" length="4" usage="output"/>
|
|
<data name="userProfile" type="char" length="10" usage="output"/>
|
|
<data name="previousSignonDate" type="char" length="7" usage="output"/>
|
|
<data name="previousSignonTime" type="char" length="6" usage="output"/>
|
|
<data type="byte" length="1" usage="output"/>
|
|
<data name="badSignonAttempts" type="int" length="4" usage="output"/>
|
|
<data name="status" type="char" length="10" usage="output"/>
|
|
<data name="passwordChangeDate" type="byte" length="8" usage="output"/>
|
|
<data name="noPassword" type="char" length="1" usage="output"/>
|
|
<data type="byte" length="1" usage="output"/>
|
|
<data name="passwordExpirationInterval" type="int" length="4" usage="output"/>
|
|
<data name="datePasswordExpires" type="byte" length="8" usage="output"/>
|
|
<data name="daysUntilPasswordExpires" type="int" length="4" usage="output"/>
|
|
<data name="setPasswordToExpire" type="char" length="1" usage="output"/>
|
|
<data name="displaySignonInfo" type="char" length="10" usage="output"/>
|
|
</struct>
|
|
|
|
<!-- Program QSYRUSRI and its parameter list for retrieving USRI0100 format -->
|
|
<program name="qsyrusri" path="/QSYS.lib/QSYRUSRI.pgm">
|
|
<data name="receiver" type="struct" struct="usri0100" usage="output"/>
|
|
<data name="receiverLength" type="int" length="4" usage="input" />
|
|
<data name="format" type="char" length="8" usage="input" init="USRI0100"/>
|
|
<data name="profileName" type="char" length="10" usage="input" init="*CURRENT"/>
|
|
<data name="errorCode" type="int" length="4" usage="input" init="0"/>
|
|
</program>
|
|
|
|
</pcml></pre>
|
|
</div>
|
|
<div class="section" id="pcmldata__javaqsyrusri"><a name="pcmldata__javaqsyrusri"><!-- --></a><h4 class="sectiontitle">Java program source for calling QSYRUSRI</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 User Information" (QSYRUSRI) API
|
|
public class qsyrusri {
|
|
|
|
public qsyrusri() {
|
|
}
|
|
|
|
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()
|
|
|
|
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 QSYRUSRI API...");
|
|
|
|
// Construct ProgramCallDocument
|
|
// First parameter is system to connect to
|
|
// Second parameter is pcml resource name. In this example,
|
|
// serialized PCML file "qsyrusri.pcml.ser" or
|
|
// PCML source file "qsyrusri.pcml" must be found in the classpath.
|
|
pcml = new ProgramCallDocument(as400System, "qsyrusri");
|
|
|
|
// Set input parameters. Several parameters have default values
|
|
// specified in the PCML source. Do not need to set them using Java code.
|
|
System.out.println(" Setting input parameters...");
|
|
pcml.setValue("qsyrusri.receiverLength",
|
|
new Integer((pcml.getOutputsize("qsyrusri.receiver"))));
|
|
|
|
// Request to call the API
|
|
// User will be prompted to sign on to the system
|
|
System.out.println(" Calling QSYRUSRI API requesting information for the sign-on user.");
|
|
rc = pcml.callProgram("qsyrusri");
|
|
|
|
// If return code is false, we received messages from the server
|
|
if(rc == false)
|
|
{
|
|
// Retrieve list of server messages
|
|
AS400Message[] msgs = pcml.getMessageList("qsyrusri");
|
|
|
|
// 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 QSYRUSRI failed. See messages above **");
|
|
System.exit(0);
|
|
}
|
|
// Return code was true, call to QSYRUSRI succeeded
|
|
// Write some of the results to standard output
|
|
else
|
|
{
|
|
value = pcml.getValue("qsyrusri.receiver.bytesReturned");
|
|
System.out.println(" Bytes returned: " + value);
|
|
value = pcml.getValue("qsyrusri.receiver.bytesAvailable");
|
|
System.out.println(" Bytes available: " + value);
|
|
value = pcml.getValue("qsyrusri.receiver.userProfile");
|
|
System.out.println(" Profile name: " + value);
|
|
value = pcml.getValue("qsyrusri.receiver.previousSignonDate");
|
|
System.out.println(" Previous signon date:" + value);
|
|
value = pcml.getValue("qsyrusri.receiver.previousSignonTime");
|
|
System.out.println(" Previous signon time:" + value);
|
|
}
|
|
}
|
|
catch (PcmlException e)
|
|
{
|
|
System.out.println(e.getLocalizedMessage());
|
|
e.printStackTrace();
|
|
System.out.println("*** Call to QSYRUSRI failed. ***");
|
|
System.exit(0);
|
|
}
|
|
|
|
System.exit(0);
|
|
} // End main()
|
|
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |