This versions adds support for Processing Cobol Messages in code Generated by the CodeGen (JRecord Code generation utility):
The ReadMe_NewUsers.md has an expanded version of this section. The first thing new users need to decide is
JRecord is available from Sourceforge:
**Current JRecord Download:
JRecord provides
For Documentation see JRecord Documentation
The easiest way to access JRecord is via IOBuilders (using the JRecordInterface1 class):
ICobolIOBuilder ioBldr
= JRecordInterface1.COBOL
.newIOBuilder("CobolCopybook.cbl")
.setSplitCopybook(CopybookLoader.SPLIT_01_LEVEL)
.setDialect(ICopybookDialects.FMT_FUJITSU);
AbstractLineReader reader = ioBldr.newReader("input File Name");
AbstractLine l;
while ((l = reader.read()) != null) {
...
}
reader.close();
There is a description of using the IOBuilder interface in the JRecord Manual. You should also investigate the Code Generation options.
To help you get started with JRecord, there are 2 Code Generate options available:
JRecord CodeGen is now part of the RecordEditor see RecordEditor Generate option for details. Also see
Code to read a Cobol file (Generated by CodeGen utility):
ICobolIOBuilder iob = JRecordInterface1.COBOL
.newIOBuilder(copybookName)
.setFont("cp037")
.setFileOrganization(Constants.IO_FIXED_LENGTH)
.setSplitCopybook(CopybookLoader.SPLIT_NONE)
;
FieldNamesDtar021.RecordDtar021 rDtar021 = FieldNamesDtar021.RECORD_DTAR021;
AbstractLineReader reader = iob.newReader(dataFile);
while ((line = reader.read()) != null) {
lineNum += 1;
System.out.println(
line.getFieldValue(rDtar021.keycodeNo).asString()
+ " " + line.getFieldValue(rDtar021.storeNo).asString()
+ " " + line.getFieldValue(rDtar021.qtySold).asString()
+ " " + line.getFieldValue(rDtar021.salePrice).asString()
);
}
reader.close();
Cobol Field Name class (Generated by CodeGen utility):
public class FieldNamesDtar021 {
public static final RecordDtar021 RECORD_DTAR021 = new RecordDtar021();
public static class RecordDtar021 {
public final String keycodeNo = "KEYCODE-NO";
public final String storeNo = "STORE-NO";
public final String theDate = "THE-DATE";
public final String deptNo = "DEPT-NO";
public final String qtySold = "QTY-SOLD";
public final String salePrice = "SALE-PRICE";
}
}
FieldNamesDtar022.RecordDtar022 rDtar022 = FieldNamesDtar022.RECORD_DTAR022;
ICobolIOBuilder iobWrite = JRecordInterface1.COBOL
.newIOBuilder(outCopybookName)
.setFont("cp037")
.setFileOrganization(Constants.IO_FIXED_LENGTH)
.setSplitCopybook(CopybookLoader.SPLIT_NONE)
;
AbstractLineWriter writer = iobWrite.newWriter(outputFileName);
AbstractLine dtar022Line = iobWrite.newLine();
dtar022Line.getFieldValue(rDtar022.keycodeNo).set("223");
dtar022Line.getFieldValue(rDtar022.theDate) .set(22);
dtar022Line.getFieldValue(rDtar022.deptNo) .set(22);
dtar022Line.getFieldValue(rDtar022.qtySold) .set(5);
dtar022Line.getFieldValue(rDtar022.salePrice).set("123.45");
writer.write(dtar022Line);
...
writer.close();
If working with Hadoop have a look at:
Previous versions of JRecord came with utilities (editors etc), this version does not with old utilities (it does have Csv2Cobol and Cobol2Csv utilities).
I would suggest you:
You can use the RecordEditor to view / try out the JRecord-options before writing your code. In the future, I hope to release a Cobol-Version of the RecordEditor that uses Cobol-Copybooks and Xml-File descriptions. This will replace the old JRecord-Utilities. This is unlikely to be released before the end of 2015 though.
This versions includes
Changes that should not matter to users of JRecord
Minor improvements in handling duplicate field names
Csv changes to Bring JRecord into line with the RecordEditor, in particular
Extra Functionality For use by CodeGen generated code.
Two new Code Templates added to the CodeGen utility.
Changes for complex Occurs Depending