package common;
import com.ibm.as400.access.AS400;
import
com.ibm.as400.access.AS400FileRecordDescription;
/**
* Use the AS400FileRecordDescription to create static objects which represent
* the external definitions of the model input and output data structures
* (MDLIDS01 and MDLODS01). Run this after changing the structure of either
* physical file which externally describes these data structures.
* <P>
* From the javadocs of AS400FileRecordDescription:<br>
* The AS400FileRecordDescription class represents the record descriptions of a
* physical or logical file on the server. This class is used to retrieve the
* file field description of a physical or logical file, and to create Java
* source code for a class extending from RecordFormat that can then be compiled
* and used as input to the AS400File.setRecordFormat() method. This allows the
* record format to be created statically during development time and then
* reused when needed. The class also provides a method for returning
* RecordFormat objects that can be used as input to the
* AS400File.setRecordFormat() method. This method can be used to create the
* record format dynamically.
*
* @author Bill Blalock
*
*/
public class CreateModelRecordFormats {
public static void main(String[]
parameters) {
AS400 as400
= null;
try {
// Create
an AS400 object for the server that has the data queue.
System.out.println("Instantiating AS400 object.");
as400 = new AS400(Me.getSYSTEM(), Me.getUSER(), Me.getPASSWORD());
// create static RecordFormat for input data structure definition
System.out.println("Retrieving MDLI record format descriptions.");
AS400FileRecordDescription mdliFormatDescription = new AS400FileRecordDescription(
as400, Me.getMDLI_DS());
System.out.println("Writing MDLI record format descriptions.");
mdliFormatDescription.createRecordFormatSource("src/dataqueue",
"dataqueue");
// create static RecordFormat for output data structure definition
System.out.println("Retrieving MDLO record format descriptions.");
AS400FileRecordDescription mdloFormatDescription = new AS400FileRecordDescription(
as400, Me.getMDLO_DS());
System.out.println("Writing MDLO record format descriptions.");
mdloFormatDescription.createRecordFormatSource("src/dataqueue",
"dataqueue");
System.out.println("Finished.");
} catch (Exception e) {
// If any of the above
operations failed say the data queue
// operation
// failed and output the
exception.
if (as400 != null)
as400.disconnectAllServices();
System.out.println("Data Queue operation failed");
System.out.println(e);
e.printStackTrace();
}
if (as400 != null)
as400.disconnectAllServices();
System.exit(0);
}
}