The following example shows how you can construct an XPCML ProgramCallDocument, call an iSeries™ program, and retrieve the results of the program call as XPCML. The example supposes the following components:
Notice how array data is specified in the original and the generated XPCML. The element qgyolaus.receiver, an output parameter, is an XPCML arrayOfStructParm with an attribute that sets the count to listInfo.rcdsReturned. The following example code includes only part of the QGYOLAUS output. If the example included all the output, the code might list 89 users under the <arrayOfStructParm> XPCML tag.
For arrays of structs, XPCML uses the <struct_i> XPCML tag to delimit each structParm element. Each <struct_i> tag indicates that the data enclosed within it is one element of type autu0150 struct. The index attribute of the <struct_i> tag specifies the element of the array for the struct.
For arrays of simple types, such as arrayOfStringParm, arrayOfIntParm, and so on, the <i> XPCML tag lists array elements.
<xpcml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xpcml.xsd" version="4.0"> <!-- XPCML source for calling "Open List of Authorized Users" --> <!-- (QGYOLAUS) API --> <!-- Format AUTU0150 - Other formats are available --> <struct name="autu0150"> <stringParm name="name" length="10"/> <stringParm name="userOrGroup" length="1"/> <stringParm name="groupMembers" length="1"/> <stringParm name="description" length="50"/> </struct> <!-- List information structure (common for "Open List" type APIs) --> <struct name="listInfo"> <intParm name="totalRcds"/> <intParm name="rcdsReturned">0</rcdsReturned> <hexBinaryParm name="rqsHandle" totalBytes="4"/> <intParm name="rcdLength"/> <stringParm name="infoComplete" length="1"/> <stringParm name="dateCreated" length="7"/> <stringParm name="timeCreated" length="6"/> <stringParm name="listStatus" length="1"/> <hexBinaryParm totalBytes="1"/> <unsignedIntParm name="lengthOfInfo"/> <intParm name="firstRecord"/> <hexBinaryParm totalBytes="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"> <parameterList> // Output values --- array of the autu0150 struct <arrayOfStructParm name="receiver" count="listInfo.rcdsReturned" passDirection="out" outputSize="receiverLength" struct="autu0150"/> // Input values <intParm name="receiverLength" passDirection="in">16384</intParm> <structParm name="listInfo" passDirection="out" struct="listInfo"/> // Input values <intParm name="rcdsToReturn" passDirection="in">264</intParm> <stringParm name="format" passDirection="in" length="10"> AUTU0150</stringParm> <stringParm name="selection" passDirection="in" length="10"> *USER</stringParm> <stringParm name="member" passDirection="in" length="10"> *NONE</stringParm> <intParm name="errorCode" passDirection="in">0</intParm> </parameterList> </program>
system = new AS400(); // Create a ProgramCallDocument into which to parse the file. ProgramCallDocument xpcmlDoc = new ProgramCallDocument(system, "QGYOLAUS.xpcml"); // Call QGYOLAUS boolean rc = xpcmlDoc.callProgram("QGYOLAUS"); // Obtain program call results as XPCML and store them // in file XPCMLOut.xpcml if (rc) // Program was successful xpcmlDoc.generateXPCML("QGYOLAUS","XPCMLOut.xpcml");
<?xml version="1.0" ?> <xpcml version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='xpcml.xsd' > <program name="QGYOLAUS" path="/QSYS.lib/QGY.lib/QGYOLAUS.pgm" parseOrder="listInfo receiver"> <parameterList> <arrayOfStructParm name="receiver" passDirection="out" count="listInfo.rcdsReturned" outputSize="receiverLength" struct="autu0150"> <struct_i index="0"> <stringParm name="name" length="10">JANEDOW</stringParm> <stringParm name="userOrGroup" length="1">0</stringParm> <stringParm name="groupMembers" length="1">0</stringParm> <stringParm name="description" length="50"> Jane Doe</stringParm> </struct_i> <struct_i index="1"> <stringParm name="name" length="10">BOBS</stringParm> <stringParm name="userOrGroup" length="1">0</stringParm> <stringParm name="groupMembers" length="1">0</stringParm> <stringParm name="description" length="50"> Bob Smith</stringParm> </struct_i> <!-- More records here depending on how many users output. --> <!-- In this case 89 user records are listed here. --> </arrayOfStructParm> <!-- End of user array --> <intParm name="receiverLength" passDirection="in"> 16384</intParm> <structParm name="listInfo" passDirection="out" struct="listInfo"> <intParm name="totalRcds">89</intParm> <intParm name="rcdsReturned">89</intParm> <hexBinaryParm name="rqsHandle" totalBytes="4"> 00000001==</hexBinaryParm> <intParm name="rcdLength">62</intParm> <stringParm name="infoComplete" length="1">C</stringParm> <stringParm name="dateCreated" length="7"> 1030321</stringParm> <stringParm name="timeCreated" length="6"> 120927</stringParm> <stringParm name="listStatus" length="1">2</stringParm> <hexBinaryParm totalBytes="1"></hexBinaryParm> <unsignedIntParm name="lengthOfInfo"> 5518</unsignedIntParm> <intParm name="firstRecord">1</intParm> </structParm> <intParm name="rcdsToReturn" passDirection="in">264</intParm> <stringParm name="format" passDirection="in" length="10"> AUTU0150</stringParm> <stringParm name="selection" passDirection="in" length="10"> *USER</stringParm> <stringParm name="member" passDirection="in" length="10"> *NONE</stringParm> <intParm name="errorCode" passDirection="in">0</intParm> </parameterList> </program> </xpcml>