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

157 lines
8.9 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="AS400FileRecordDescription" />
<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="rla400fd" />
<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>AS400FileRecordDescription</title>
</head>
<body id="rla400fd"><a name="rla400fd"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">AS400FileRecordDescription</h1>
<div><p></p>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/access/AS400FileRecordDescription.html#NAVBAR_TOP"> AS400FileRecordDescription</a> class provides the methods
for retrieving the record format of a file on the server. This class provides
methods for creating Java™ source code for subclasses of <a href="javadoc/com/ibm/as400/access/RecordFormat.html#NAVBAR_TOP"> RecordFormat</a> and for returning RecordFormat objects,
which describe the record formats of user-specified physical or logical files
on the server. The output of these methods can be used as input to an AS400File
object when setting the record format.</p>
</div>
<div class="section"><p>It is recommended that the AS400FileRecordDescription class always
be used to generate the RecordFormat object when the file already exists
on the server.</p>
</div>
<div class="section"><div class="note"><span class="notetitle">Note:</span> The AS400FileRecordDescription class does not retrieve the
entire record format of a file. Only enough information is retrieved to describe
the contents of the records that make up the file. Information such as column
headings, aliases, and reference fields is not retrieved. Therefore, the record
formats retrieved cannot necessarily be used to create a file whose record
format is identical to the file from which the format was retrieved.</div>
</div>
<div class="section"><p><strong>Creating Java source code for subclasses of RecordFormat
to represent the record format of files on the server</strong></p>
</div>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/access/AS400FileRecordDescription.html#CREATERECORDFORMATSOURCE(JAVA.LANG.STRING, JAVA.LANG.STRING)"> createRecordFormatSource()</a> method creates Java source
files for subclasses of the <a href="javadoc/com/ibm/as400/access/RecordFormat.html">RecordFormat</a> class. The files can be compiled and used
by an application or applet as input to the <a href="javadoc/com/ibm/as400/access/AS400File.html#SETRECORDFORMAT()"> AS400File.setRecordFormat()</a> method.</p>
</div>
<div class="section"><p>The createRecordFormatSource() method should be used as a development
time tool to retrieve the record formats of existing files on the server.
This method allows the source for the subclass of the RecordFormat class to
be created once, modified if necessary, compiled, and then used by many Java programs
accessing the same files on the server. Because this method creates files
on the local system, it can be used only by Java applications. The output (the Java source
code), however, can be compiled and then used by Java applications and applets alike.</p>
</div>
<div class="section"><div class="note"><span class="notetitle">Note:</span> This method overwrites files with the same names as the Java source
files being created.</div>
</div>
<div class="section"><p><strong>Example 1:</strong> The following example shows how to use the createRecordFormatSource()
method:</p>
</div>
<div class="section"><div class="p"><pre> // Create an AS400 object, the file exists on this
// server.
AS400 sys = new AS400("mySystem.myCompany.com");
// Create an AS400FileRecordDescription object that represents the file
AS400FileRecordDescription myFile = new AS400FileRecordDescription(sys,
"/QSYS.LIB/MYLIB.LIB/MYFILE.FILE");
// Create the Java source file in the current working directory.
// Specify "package com.myCompany.myProduct;" for the
// package statement in the source since I will ship the class
// as part of my product.
myFile.createRecordFormatSource(null, "com.myCompany.myProduct");
// Assuming that the format name for file MYFILE is FILE1, the
// file FILE1Format.java will be created in the current working directory.
// It will overwrite any file by the same name. The name of the class
// will be FILE1Format. The class will extend from RecordFormat.
</pre>
</div>
</div>
<div class="section"><p><strong>Example 2:</strong> Compile the file you created above, FILE1Format.java,
and use it as follows:</p>
</div>
<div class="section"><div class="p"><pre> // Create an AS400 object, the file exists on this
// server.
AS400 sys = new AS400("mySystem.myCompany.com");
// Create an AS400File object that represents the file
SequentialFile myFile = new SequentialFile(sys, "/QSYS.LIB/MYLIB.LIB/MYFILE.FILE");
// Set the record format
// This assumes that import.com.myCompany.myProduct.FILE1Format;
// has been done.
myFile.setRecordFormat(new FILE1Format());
// Open the file and read from it
....
// Close the file since I am done using it
myFile.close();
// Disconnect since I am done using record-level access
sys.disconnectService(AS400.RECORDACCESS);</pre>
<strong>Creating RecordFormat objects to represent the record format
of files on the server</strong></div>
</div>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/access/AS400FileRecordDescription.html#RETRIEVERECORDFORMAT()"> retrieveRecordFormat()</a> method returns an array of RecordFormat
objects that represent the record formats of an existing file on the server.
Typically, only one RecordFormat object is returned in the array. When the
file for which the record format is being retrieved is a multiple format logical
file, more than one RecordFormat object is returned. Use this method to dynamically
retrieve the record format of an existing file on the server during runtime.
The RecordFormat object then can be used as input to the <a href="javadoc/com/ibm/as400/access/AS400File.html#SETRECORDFORMAT()"> AS400File.setRecordFormat()</a> method.</p>
</div>
<div class="section"><p>The following example shows how to use the retrieveRecordFormat()
method:</p>
</div>
<div class="section"><div class="p"><pre> // Create an AS400 object, the file exists on this
// server.
AS400 sys = new AS400("mySystem.myCompany.com");
// Create an AS400FileRecordDescription object that represents the file
AS400FileRecordDescription myFile = new AS400FileRecordDescription(sys,
"/QSYS.LIB/MYLIB.LIB/MYFILE.FILE");
// Retrieve the record format for the file
RecordFormat[] format = myFile.retrieveRecordFormat();
// Create an AS400File object that represents the file
SequentialFile myFile = new SequentialFile(sys, "/QSYS.LIB/MYLIB.LIB/MYFILE.FILE");
// Set the record format
myFile.setRecordFormat(format[0]);
// Open the file and read from it
....
// Close the file since I am done using it
myFile.close();
// Disconnect since I am done using record-level access
sys.disconnectService(AS400.RECORDACCESS);</pre>
</div>
</div>
</div>
</body>
</html>