ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/dtxmp.htm

241 lines
11 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="Data types example usage" />
<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="dtxmp" />
<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>Data types example usage</title>
</head>
<body id="dtxmp"><a name="dtxmp"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Data types example usage</h1>
<div><p></p>
<div class="section"><div class="p">You can use the AS400DataType classes with ProgramCall to supply
data for program parameters and to interpret the data returned in program
parameters.<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
example disclaimer</a> for important legal information.</div>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Example: Using AS400DataType classes with ProgramCall</h4><p>The
following example shows how to use AS400DataType classes by using ProgramCall
to call the system API, QUSRMBRD "Retrieve Member Description". The QUSRMBRD
API retrieves the description of a specific member in a database file. The
tables following the example list the required QUSRMBRD parameters and the
types of information that the example retrieves.</p>
<pre> // Create a ProgramCall object. We will set the program name and
// parameter list later.
ProgramCall qusrmbrd = new ProgramCall(new AS400());
// Create an empty program parameter list
ProgramParameter[] parms = new ProgramParameter[6];
// Create AS400DataTypes to convert our input parameters from Java types
// to server data
AS400Bin4 bin4 = new AS400Bin4();
// We need a separate AS400Text object for each parameter with a
// different length because the AS400Text class requires the length to
// be specified.
AS400Text char8Converter = new AS400Text(8)
AS400Text char20Converter = new AS400Text(20);
AS400Text char10Converter = new AS400Text(10);
AS400Text char1Converter = new AS400Text(1);
// Populate our parameter list; we use the AS400DataType objects to
// convert our Java values to byte arrays containing server data.
// For the output parameter we need only specify how many bytes will
// be returned
parms[0] = new ProgramParameter(135);
parms[1] = new ProgramParameter(bin4.toBytes(new Integer(135)));
parms[2] = new ProgramParameter(char8Converter.toBytes("MBRD0100"));
parms[3] = new ProgramParameter(char20Converter.toBytes("MYFILE MYLIB "));
parms[4] = new ProgramParameter(char10COnverter.toBytes("MYMEMBER "));
parms[5] = new ProgramParameter(char1Converter.toBytes("0"));
// Set the program name and parameter list
qusrmbrd.setProgram("/qsys.lib/qusrmbrd.pgm", parms);
// Call the program
try
{
qusrmbrd.run();
}
catch(Exception e)
{
// Handle any exceptions
}
// Get the information retrieved. Note that this is raw server data.
byte[] receiverVar = parms[0].getOutputData();
// We need this to convert the time and date data
AS400Text char13Converter = new AS400Text(13);
// We need this to convert the text description data
AS400Text char50Converter = new AS400Text(50);
// Create an AS400Structure to handle the returned information
AS400DataType[] dataTypeArray = new AS400DataType[11];
dataTypeArray[0] = bin4;
dataTypeArray[1] = bin4;
dataTypeArray[2] = char10Converter;
dataTypeArray[3] = char10Converter;
dataTypeArray[4] = char10Converter;
dataTypeArray[5] = char10Converter;
dataTypeArray[6] = char10Converter;
dataTypeArray[7] = char13Converter;
dataTypeArray[8] = char13Converter;
dataTypeArray[9] = char50Converter;
dataTypeArray[10] = char1Converter;
AS400Structure returnedDataConverter = new AS400Structure(dataTypeArray);
// Convert the data returned to an array of Java Objects using our
// returnedDataConverter
Object[] qusrmbrdInfo = dataConverter.toObject(receiverVar, 0);
// Get the number of bytes returned
Integer bytesReturned = (Integer)qusrmbrdInfo[0];
Integer bytesAvailable = (Integer)qusrmbrdInfo[1];
if (bytesReturned.intValue() != 135)
{
System.out.println("Wrong amount of information returned.");
System.exit(0);
}
String fileName = (String)qusrmbrdInfo[2];
String libName = (String)qusrmbrdInfo[3];
String mbrName = (String)qusrmbrdInfo[4];
String fileAttribute = (String)qusrmbrdInfo[5];
String sourceType = (String)qusrmbrdInfo[6];
String created = (String)qusrmbrdInfo[7];
String lastChanged = (String)qusrmbrdInfo[8];
String textDesc = (String)qusrmbrdInfo[9];
String isSourceFile = (String)qusrmbrdInfo[10];
// We will just output all the information to the screen
System.out.println(fileName + " " + libName + " " + mbrName + " " +
fileAttribute + sourceType + " " + created + " " +
lastChanged + " " + textDesc + " " + isSourceFile);</pre>
</div>
<div class="section"><p>The following table lists the required parameters for the QUSRMBRD
API as used in the preceding example.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr class="tablemainheaderbar"><th valign="top" width="25%" id="d0e37">QUSRMBRD parameter</th>
<th valign="top" width="25%" id="d0e39">Input or output</th>
<th valign="top" width="25%" id="d0e41">Type</th>
<th valign="top" width="25%" id="d0e43">Description</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="25%" headers="d0e37 ">Receiver variable</td>
<td valign="top" width="25%" headers="d0e39 ">Output</td>
<td valign="top" width="25%" headers="d0e41 ">Char(*)</td>
<td valign="top" width="25%" headers="d0e43 ">Character buffer which will contain the information retrieved.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e37 ">Length of receiver variable</td>
<td valign="top" width="25%" headers="d0e39 ">Input</td>
<td valign="top" width="25%" headers="d0e41 ">Bin(4)</td>
<td valign="top" width="25%" headers="d0e43 ">Length of the character buffer provided for the receiver variable.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e37 ">Format name</td>
<td valign="top" width="25%" headers="d0e39 ">Input</td>
<td valign="top" width="25%" headers="d0e41 ">Char(8)</td>
<td valign="top" width="25%" headers="d0e43 ">Format specifying the type of information to be retrieved. Must be
one of: <ul><li>MBRD0100</li>
<li>MBRD0200</li>
<li>MBRD0300</li>
</ul>
The following example specifies MBRD0100.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e37 ">Qualified database file name</td>
<td valign="top" width="25%" headers="d0e39 ">Input</td>
<td valign="top" width="25%" headers="d0e41 ">Char(20)</td>
<td valign="top" width="25%" headers="d0e43 ">The qualified file name. This is the file name blank padded to 10
characters followed by the library name blank padded to 10 characters. Special
values of *CURLIB and *LIBL are allowed for the library name.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e37 ">Database member name</td>
<td valign="top" width="25%" headers="d0e39 ">Input</td>
<td valign="top" width="25%" headers="d0e41 ">Char(10)</td>
<td valign="top" width="25%" headers="d0e43 ">The name of the member blank padded to 10 characters. Special values
of *FIRST and *LAST are allowed.</td>
</tr>
<tr><td valign="top" width="25%" headers="d0e37 ">Override processing</td>
<td valign="top" width="25%" headers="d0e39 ">Input</td>
<td valign="top" width="25%" headers="d0e41 ">Char(1)</td>
<td valign="top" width="25%" headers="d0e43 ">Whether overrides are to be processed. 0 indicates that overrides
are not to be processed. This is the value we will specify.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><p>The following table lists the type of information that the example
retrieves (based on format MBRD0100, as specified in the preceding example):</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="border" border="1" rules="all"><thead align="left"><tr class="tablemainheaderbar"><th valign="top" width="50%" id="d0e117">Information retrieved</th>
<th valign="top" width="50%" id="d0e119">Type</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="50%" headers="d0e117 ">Bytes returned</td>
<td valign="top" width="50%" headers="d0e119 ">Bin(4)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Bytes available</td>
<td valign="top" width="50%" headers="d0e119 ">Bin(4)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Database file name</td>
<td valign="top" width="50%" headers="d0e119 ">Char(10)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Database file library name</td>
<td valign="top" width="50%" headers="d0e119 ">Char(10)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Member name</td>
<td valign="top" width="50%" headers="d0e119 ">Char(10)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">File attribute (type of file: PF, LF, DDMF)</td>
<td valign="top" width="50%" headers="d0e119 ">Char(10)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Source type (type of the source source member if this is a source file)</td>
<td valign="top" width="50%" headers="d0e119 ">Char(10)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Creation date and time</td>
<td valign="top" width="50%" headers="d0e119 ">Char(13)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Last source change date and time</td>
<td valign="top" width="50%" headers="d0e119 ">Char(13)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Member text description</td>
<td valign="top" width="50%" headers="d0e119 ">Char(50)</td>
</tr>
<tr><td valign="top" width="50%" headers="d0e117 ">Source file (whether the file is a source file: 0=data file, 1=source
file)</td>
<td valign="top" width="50%" headers="d0e119 ">Char(1)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>