I have a Zfile reader class that uses a recgen generated class to read a MVS sequential data set. I have downloaded, in text mode, the data file and would like to use the recgen generated class to access the data for testing.
Is this possible?
I am using MyEclipse 8.0 and Jzos 2.3.2. I have the 1.0.6 cookbook and have gotten it to run on zos using a DB2 database.
Using recgen records in Eclipse
It is not generally possible to do this if you download the dataset in "text" mode, since it might have non-text fields (binary, packed, etc). Also, the regen-generated classes by default assume that the codepage is EBCDIC.
But it is possible to download the dataset in binary and process it with your record classes on your PC. In order to do this, you will need to have a mechanism for reading each record from a binary PC file into a byte array. If the records are fixed length, this is no problem, but you can use IBM RDW record prefixes if the records are variable length.
For an example, see the "RdwTransactionReader" class in the Cookbook, which reads binary records from a RDW-prefixed file.
Hint: you can download a dataset in binary to the PC with RDWs using FTP with:
ftp> binary
ftp> quote site rdw
ftp> get 'HLQ.DSN' myfile
But it is possible to download the dataset in binary and process it with your record classes on your PC. In order to do this, you will need to have a mechanism for reading each record from a binary PC file into a byte array. If the records are fixed length, this is no problem, but you can use IBM RDW record prefixes if the records are variable length.
For an example, see the "RdwTransactionReader" class in the Cookbook, which reads binary records from a RDW-prefixed file.
Hint: you can download a dataset in binary to the PC with RDWs using FTP with:
ftp> binary
ftp> quote site rdw
ftp> get 'HLQ.DSN' myfile
Thanks, worked like a charm.
Downloaded the data in binary. Including the code for completeness.
CountyStorage is an 1100 byte fixed length record containing only character data(no comp or PD).
public void setUpObject() {
try {
byte[] bytes = new byte[1100];
InputStream is = new BufferedInputStream(
new FileInputStream("dg03b.t19"));
try {
while (is.read(bytes) > 0 ){
cs = new CountyStorage(bytes);
System.out.println(cs.getNewPlate());
};
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
In the recgen record there is an attribute thus;
protected static CobolDatatypeFactory factory = new CobolDatatypeFactory();
which extends DataTypeFactory
which has an attribute String setStringEncoding;
which has getters and setters.
this seems to be null most of the time I check it.
Could this be used to alter the base code page? If not now maybe later?
Downloaded the data in binary. Including the code for completeness.
CountyStorage is an 1100 byte fixed length record containing only character data(no comp or PD).
public void setUpObject() {
try {
byte[] bytes = new byte[1100];
InputStream is = new BufferedInputStream(
new FileInputStream("dg03b.t19"));
try {
while (is.read(bytes) > 0 ){
cs = new CountyStorage(bytes);
System.out.println(cs.getNewPlate());
};
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
In the recgen record there is an attribute thus;
protected static CobolDatatypeFactory factory = new CobolDatatypeFactory();
which extends DataTypeFactory
which has an attribute String setStringEncoding;
which has getters and setters.
this seems to be null most of the time I check it.
Could this be used to alter the base code page? If not now maybe later?