JRecord
|
The 2 main formats of RecordLayouts are Cobol and RecordEditor-XML Two other formats worth mentioning are
The package accepts standard Cobol Copybooks, look up the Cobol definition on the Web for more details. Here is a Sample:
6:000600* 7:000700* RECORD LENGTH IS 27. 8:000800* 9:000900 03 DTAR020-KCODE-STORE-KEY. 10:001000 05 DTAR020-KEYCODE-NO PIC X(08). 11:001100 05 DTAR020-STORE-NO PIC S9(03) COMP-3. 12:001200 03 DTAR020-DATE PIC S9(07) COMP-3. 13:001300 03 DTAR020-DEPT-NO PIC S9(03) COMP-3. 14:001400 03 DTAR020-QTY-SOLD PIC S9(9) COMP-3. 15:001500 03 DTAR020-SALE-PRICE PIC S9(9)V99 COMP-3. 16:
Record can be described via XML like the following. The easiest way to define a RecordEditor-XML file is to use the Layout-Wizard
1:<?xml version="1.0" ?> 2:<RECORD RECORDNAME="DTAR020" COPYBOOK="DTAR020" DELIMITER="<Tab>" 3: FONTNAME="CP037" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout" 4: LIST="Y" QUOTE="" RecSep="default"> 5: <FIELDS> 6: <FIELD NAME="KEYCODE-NO" POSITION="1" LENGTH="8" TYPE="Char" /> 7: <FIELD NAME="STORE-NO" POSITION="9" LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" /> 8: <FIELD NAME="DATE" POSITION="11" LENGTH="4" TYPE="Mainframe Packed Decimal (comp-3)" /> 9: <FIELD NAME="DEPT-NO" POSITION="15" LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" /> 10: <FIELD NAME="QTY-SOLD" POSITION="17" LENGTH="5" TYPE="Mainframe Packed Decimal (comp-3)" /> 11: <FIELD NAME="SALE-PRICE" POSITION="22" LENGTH="6" DECIMAL="2" TYPE="Mainframe Packed Decimal (comp-3)" /> 12: </FIELDS> 13:</RECORD>
Or if there are more than one format used in the file.
1:<?xml version="1.0" ?> 2:<RECORD RECORDNAME="ams PO Download" COPYBOOK="" DELIMITER="<Tab>" FILESTRUCTURE="Default" STYLE="0" 3: RECORDTYPE="GroupOfRecords" LIST="Y" QUOTE="" RecSep="default"> 4: <RECORDS> 5: <RECORD RECORDNAME="ams PO Download: Detail" COPYBOOK="" DELIMITER="<Tab>" 6: DESCRIPTION="PO Download: Detail" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout" 7: LIST="N" QUOTE="" RecSep="default" TESTFIELD="Record Type" TESTVALUE="D1"> 8: <FIELDS> 9: <FIELD NAME="Record Type" POSITION="1" LENGTH="2" TYPE="Char"/> 10: <FIELD NAME="Pack Qty" POSITION="3" LENGTH="9" DECIMAL="4" TYPE="Num Assumed Decimal (Zero padded)"/> 11: <FIELD NAME="Pack Cost" POSITION="12" LENGTH="13" DECIMAL="4" TYPE="Num Assumed Decimal (Zero padded)"/> 12: <FIELD NAME="APN" POSITION="25" LENGTH="13" TYPE="Num (Right Justified zero padded)"/> 13: <FIELD NAME="Filler" POSITION="38" LENGTH="1" TYPE="Char"/> 14: <FIELD NAME="Product" POSITION="39" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 15: <FIELD NAME="pmg dtl tech key" POSITION="72" LENGTH="15" TYPE="Char"/> 16: <FIELD NAME="Case Pack id" POSITION="87" LENGTH="15" TYPE="Char"/> 17: <FIELD NAME="Product Name" POSITION="101" LENGTH="50" TYPE="Char"/> 18: </FIELDS> 19: </RECORD> 20: <RECORD RECORDNAME="ams PO Download: Header" COPYBOOK="" DELIMITER="<Tab>" 21: DESCRIPTION="PO Download: Header" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout" LIST="N" 22: QUOTE="" RecSep="default" TESTFIELD="Record Type" TESTVALUE="H1"> 23: <FIELDS> 24: <FIELD NAME="Record Type" POSITION="1" LENGTH="2" TYPE="Char"/> 25: <FIELD NAME="Sequence Number" POSITION="3" LENGTH="5" DECIMAL="3" TYPE="Num Assumed Decimal (Zero padded)"/> 26: <FIELD NAME="Vendor" POSITION="8" LENGTH="10" TYPE="Num (Right Justified zero padded)"/> 27: <FIELD NAME="PO" POSITION="18" LENGTH="12" TYPE="Num Assumed Decimal (Zero padded)"/> 28: <FIELD NAME="Entry Date" DESCRIPTION="Format YYMMDD" POSITION="30" LENGTH="6" TYPE="Char"/> 29: <FIELD NAME="Filler" POSITION="36" LENGTH="8" TYPE="Char"/> 30: <FIELD NAME="beg01 code" POSITION="44" LENGTH="2" TYPE="Char"/> 31: <FIELD NAME="beg02 code" POSITION="46" LENGTH="2" TYPE="Char"/> 32: <FIELD NAME="Department" POSITION="48" LENGTH="4" TYPE="Char"/> 33: <FIELD NAME="Expected Reciept Date" DESCRIPTION="Format YYMMDD" POSITION="52" LENGTH="6" TYPE="Char"/> 34: <FIELD NAME="Cancel by date" DESCRIPTION="Format YYMMDD" POSITION="58" LENGTH="6" TYPE="Char"/> 35: <FIELD NAME="EDI Type" POSITION="68" LENGTH="1" TYPE="Char"/> 36: <FIELD NAME="Add Date" DESCRIPTION="Format YYMMDD" POSITION="69" LENGTH="6" TYPE="Char"/> 37: <FIELD NAME="Filler" POSITION="75" LENGTH="1" TYPE="Char"/> 38: <FIELD NAME="Department Name" POSITION="76" LENGTH="10" TYPE="Char"/> 39: <FIELD NAME="Prcoess Type" DESCRIPTION="C/N Conveyable/Non-Conveyable" POSITION="86" LENGTH="1" TYPE="Char"/> 40: <FIELD NAME="Order Type" POSITION="87" LENGTH="2" TYPE="Char"/> 41: </FIELDS> 42: </RECORD> 43: <RECORD RECORDNAME="ams PO Download: Allocation" COPYBOOK="" DELIMITER="<Tab>" 44: DESCRIPTION="Allocation Line" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout" 45: LIST="N" QUOTE="" RecSep="default" TESTFIELD="Record Type" TESTVALUE="S1"> 46: <FIELDS> 47: <FIELD NAME="Record Type" POSITION="1" LENGTH="2" TYPE="Char"/> 48: <FIELD NAME="DC Number 1" POSITION="3" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 49: <FIELD NAME="Pack Quantity 1" POSITION="7" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 50: <FIELD NAME="DC Number 2" POSITION="15" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 51: <FIELD NAME="Pack Quantity 2" POSITION="19" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 52: <FIELD NAME="DC Number 4" POSITION="39" LENGTH="4" TYPE="Char"/> 53: <FIELD NAME="Pack Quantity 4" POSITION="43" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 54: <FIELD NAME="DC Number 5" POSITION="51" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 55: <FIELD NAME="Pack Quantity 5" POSITION="55" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 56: <FIELD NAME="DC Number 6" POSITION="63" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 57: <FIELD NAME="Pack Quantity 6" POSITION="67" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 58: <FIELD NAME="DC Number 7" POSITION="75" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 59: <FIELD NAME="Pack Quantity 7" POSITION="79" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 60: <FIELD NAME="DC Number 8" POSITION="87" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 61: <FIELD NAME="Pack Quantity 8" POSITION="91" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 62: <FIELD NAME="DC Number 9" POSITION="99" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 63: <FIELD NAME="Pack Quantity 9" POSITION="103" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 64: <FIELD NAME="DC Number 10" POSITION="111" LENGTH="4" TYPE="Num (Right Justified zero padded)"/> 65: <FIELD NAME="Pack Quantity 10" POSITION="115" LENGTH="8" TYPE="Num (Right Justified zero padded)"/> 66: </FIELDS> 67: </RECORD> 68: </RECORDS> 69:</RECORD>
Following is an example of a CSV file (Tab Field Seperator). Key fields for Delimited files
RECORDTYPE | For CSV files it must be RECORDTYPE="Delimited". |
DELIMITER | Holds the field delimiter. i.e. DELIMITER="," for comma; For a Tab see below. |
FILESTRUCTURE | File Structure,
|
POSITION | The Field Number (1 = first field etc). |
LENGTH | Should not be entered (or be negative). |
2:<RECORD RECORDNAME="csv_DTAR020" COPYBOOK="csv_DTAR020" DELIMITER="<Tab>" 3: FILESTRUCTURE="CSV_NAME_1ST_LINE" 4: STYLE="0" RECORDTYPE="Delimited" LIST="Y" QUOTE="" RecSep="default"> 5: <FIELDS> 6: <FIELD NAME="keycode-no" DESCRIPTION="keycode-no" POSITION="1" TYPE="Char"/> 7: <FIELD NAME="Store-No" DESCRIPTION="Store-No" POSITION="2" TYPE="Char"/> 8: <FIELD NAME="Date" DESCRIPTION="Date" POSITION="3" TYPE="Char"/> 9: <FIELD NAME="Dept-No" DESCRIPTION="Dept-No" POSITION="4" TYPE="Char"/> 10: <FIELD NAME="Qty-Sold" DESCRIPTION="Qty-Sold" POSITION="5" TYPE="Char"/> 11: <FIELD NAME="Sale-Price" DESCRIPTION="Sale-Price" POSITION="6" TYPE="Char"/> 12: </FIELDS> 13:</RECORD>
For XML files, The fields XML~* and Following~Text are required and must be defined in the sequence as below.
2:<RECORD RECORDNAME="Xml_DTAR020_Copybook" COPYBOOK="Xml_DTAR020_Copybook" FILESTRUCTURE="XML_Use_Layout" 3: STYLE="0" RECORDTYPE="GroupOfRecords" LIST="Y" QUOTE="" RecSep="default"> 4: <RECORDS> 5: <RECORD RECORDNAME="ExportData" COPYBOOK="Xml_DTAR020_Copybook_ExportData" FILESTRUCTURE="XML_Use_Layout" 6: STYLE="0" RECORDTYPE="XML" LIST="N" QUOTE="" RecSep="default"> 7: <FIELDS> 8: <FIELD NAME="Xml~Name" POSITION="0" TYPE="XML Name Tag"/> 9: <FIELD NAME="Xml~End" POSITION="1" TYPE="Check Box True / Space"/> 10: <FIELD NAME="Following~Text" POSITION="2" TYPE="Edit Multi Line field"/> 11: <FIELD NAME="Xml~Prefix" POSITION="3" TYPE="Char"/> 12: <FIELD NAME="Xml~Namespace" POSITION="4" TYPE="Char"/> 13: </FIELDS> 14: </RECORD> 15: <RECORD RECORDNAME="DTAR020" COPYBOOK="Xml_DTAR020_Copybook_DTAR020" FILESTRUCTURE="XML_Use_Layout" 16: STYLE="0" RECORDTYPE="XML" LIST="N" QUOTE="" RecSep="default"> 17: <FIELDS> 18: <FIELD NAME="Xml~Name" POSITION="0" TYPE="XML Name Tag"/> 19: <FIELD NAME="Xml~End" POSITION="1" TYPE="Check Box True / Space"/> 20: <FIELD NAME="Following~Text" POSITION="2" TYPE="Edit Multi Line field"/> 21: <FIELD NAME="Xml~Prefix" POSITION="3" TYPE="Char"/> 22: <FIELD NAME="Xml~Namespace" POSITION="4" TYPE="Char"/> 23: <FIELD NAME="KEYCODE-NO" POSITION="5" TYPE="Char"/> 24: <FIELD NAME="STORE-NO" POSITION="6" TYPE="Char"/> 25: <FIELD NAME="DATE" POSITION="7" TYPE="Char"/> 26: <FIELD NAME="DEPT-NO" POSITION="8" TYPE="Char"/> 27: <FIELD NAME="QTY-SOLD" POSITION="9" TYPE="Char"/> 28: <FIELD NAME="SALE-PRICE" POSITION="10" TYPE="Char"/> 29: </FIELDS> 30: </RECORD> 31: <RECORD RECORDNAME="/ExportData" COPYBOOK="Xml_DTAR020_Copybook_/ExportData" FILESTRUCTURE="XML_Use_Layout" 32: STYLE="0" RECORDTYPE="XML" LIST="N" QUOTE="" RecSep="default"> 33: <FIELDS> 34: <FIELD NAME="Xml~Name" POSITION="0" TYPE="XML Name Tag"/> 35: <FIELD NAME="Xml~End" POSITION="1" TYPE="Check Box True / Space"/> 36: <FIELD NAME="Following~Text" POSITION="2" TYPE="Edit Multi Line field"/> 37: </FIELDS> 38: </RECORD> 39: </RECORDS> 40:</RECORD>
In recordEditor XML all attributes must be in quotes. i.e Length="12" and not Length=12.
1:<RECORD ...> 2: <FIELDS> 3: <FIELD .../> <!-- one or more fields --> 4: </FIELDS> 5:</RECORD>
Contains one record Definition. It can contain either sub-records held in a <records> tag or Fields in a <Fields>. Only one level of record nesting is allowed. You can not nest records within records within records.
Attributes on a Record tag:
RecordName | Records Name |
Delimiter | Field Delimiter for CSV files. |
FontName | Java name of the font. Normally this can be left out / spaces. Use CP037 for reading native mainframe on a PC / Linux. |
FileStructure | File Structure, Normally you can use default. Possible values are
|
RecordType | Type of Record. Values are
|
Style | Should be 0 (zero). |
RecSep | Record Separator. Leave as default. |
TestField | When there are more records in a file, If the value of this field equals TestValue This record will be used.. |
TestValue | The value the TestField is compared with. |
Other | Other Tags like List, Copybook are used by the RecordEditor and can be left out. |
Used to define a field. Attribute available include
Name | Field Name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Position | For flat (fixed field width) files it is the character position of the field. For CSV/XML fields, it is the field number. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Length | Field Length. Do not code for CSV / XML fields. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Decimal | The number of decimal places in a numeric field | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type | Field Type - possible values are
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description | Field Description. In the editor it is the column help. |
If there is only one record in a Layout the format is as follows.
1:<RECORD ...> 2: <FIELDS> 3: <FIELD .../> <!-- one or more fields --> 4: </FIELDS> 5:</RECORD>
When there are more than one record in a file, You need to define sub-record's within the record as follows. Also you should enter TestField and TestValue fields. These are used to determine which record to use.
1:<RECORD ... > 2: <RECORDS> 3: <RECORD ... TESTFIELD="Record Type" TESTVALUE="D1"> 4: <FIELDS> 5: <FIELD .../> 6: ... 7: </FIELDS> 8: </RECORD> 9: <RECORD ... TESTFIELD="Record Type" TESTVALUE="H1"> 10: <FIELDS> 11: <FIELD .../> 12: ... 13: </FIELDS> 14: </RECORD> 15: </RECORDS> 16:</RECORD>
The DB Format is for viewing / editing DB2-UDB delimited table exports files. The following SQL will generate SQL to create a copybook file for each table.
1:SELECT 'EXPORT TO "C:\Data\RecordEditor\CsvCopybooks\' || TabName || '.Csv" OF DEL MESSAGES "C:\export.txt" ' 2: || 'SELECT ''DB_DVMT_'' || c.TABSCHEMA, c.TABNAME, c.COLNAME, c.COLNO, c.TYPENAME, c.LENGTH, c.SCALE ' 3: || ' FROM SYSCAT.COLUMNS AS c ' 4: || ' where c.TABSCHEMA = ''' || TABSCHEMA || ''' and c.TABNAME = ''' || TabName || ''' ' 5: || ' ORDER BY c.TABNAME ASC, c.COLNO ASC; ' 6:FROM SYSCAT.TABLES where TABSCHEMA = 'ETB';; 7: 8:
The Record Editor is a Copybook Transfer format. You can create files in this format via the RecordEditor - LayoutEditor - Copy-Option. You can also cut from the RecordLayout editor and paste into a normal Text Editor.
The format of the file is basically a tab delimited file with the following fields
JRecord at SourceForge | Download Page | Forums |