COBOL defined layouts
Record layouts are defined using COBOL notation for data definition. This means that COBOL copybooks used by existing legacy applications can be reused to define the layouts of the files being processed.
When defining layouts with COBOL syntax, a single layout
element can defined more than one layout. Indeed, each 01 level defines a single layout.
For example the following snippet defines the layouts RECORD01
and RECORD02
:
01 RECORD01.
03 FIELD01 PIC X.
03 FIELD02 PIC X.
01 RECORD02.
03 FILLER PIC X(20).
When defining layouts using COBOL, some limitations apply.
Field enablement
Depending on the field definition, Ianus enabled the field for comparison and conversion. By default, fields are treated as follows:
Clause | Compared | Converted |
---|---|---|
Elementary fields | Yes | Yes |
Elementary FILLER fields | No | Yes |
Fields with REDEFINES clause | No | No |
Field groups | No | No |
Elementary items in field groups with REDEFINES | No | No |
Elementary items
Only elementary items are processed.
For example, with a record defined as follows:
01 REC.
03 F1.
05 A PIC X.
05 B PIC S9(8) COMP.
03 F2.
05 C PIC S9(4).
Only the fields A
, B
and C
are actually processed.
REDEFINEs
Items with the REDEFINES
clause and their children items are not included in the process.
For example, with a record defined as follows:
01 REC.
03 F1.
05 A PIC X.
05 B PIC S9(8) COMP.
03 F2.
05 C PIC S9(4).
03 F3 REDEFINES F2.
05 D PIC X(2).
Only the fields A
, B
and C
are actually processed, while D
is ignored.
FILLERs
Elementary FILLER
items are not included in the process.
For example, with a record defined as follows:
01 REC.
03 F1.
05 A PIC X.
05 B PIC S9(8) COMP.
03 F2.
05 C PIC S9(4).
03 FILLER PIC X(20).
Only the fields A
, B
and C
are actually compared or converted.
Note
To override default field enablement, you can use the enable
element in the layouts
element, or the directive enabled
.
Non Default Enablement
The default field enablement can be overridden using the element enable
inside layouts
(see Record Layouts).
Data Types
The data types supported remains the same described in Field Data Types.
The following table explains how COBOL data types are matched to Ianus native types:
COBOL Type | Ianus type | Content |
---|---|---|
DISPLAY | Char or Mixed | Text data, which encoding (EBCDIC or ASCII) depends on the repository settings |
ZONED | Zoned | Numerical text data, which encoding (EBCDIC or ASCII) depends on the repository settings |
COMP-X | Integer (big endian) | Integer data with big-endian notation |
COMP-5 | Integer (little endian) | Integer data with little-endian notation |
COMP | Integer | Integer data which notation depends on the repository or layout settings |
PACKED | Packed | Packed data |
DISPLAY-1 | DBCS | Non-shifted DBCS data |
COMP-1 | Float | 4 bytes Floating Point, encoded as IBM370 is the repository encoding is EBCDIC or IEEE 754 is the enconding is ASCII |
COMP-2 | Double | 8 bytes Floating Point, encoded as IBM370 is the repository encoding is EBCDIC or IEEE 754 is the enconding is ASCII |
Field Directives
Field attributes can be overridden in the COBOL layout using field directives.
Field directives are identified by the string @ianus*
and refer to the immediately following field definition.
Syntax
@ianus*key=value [key=value]…
Where key is the field attribute to override and value is the attribute value.
The following attributes can be overridden by field directives:
Attribute | Type | Purpose | Default |
---|---|---|---|
name | string | Name of the field. The name must be unique in the layout. | |
type | string | Field data type. Refer to Field Data Types. | |
length | integer | Length of the field in bytes. | |
encoding | string | For char fields, defines the character encoding: ascii or ebcdic . |
If not defined, the repository default encoding is assumed |
codepage | string | For char fields, defines the codepage used for EBCDIC to ASCII conversion (when required). | If not defined, the repository default codepage is used. |
endian | string | For integer fields, define the endian style of the field: default , bin or little . |
If not defined, the layout default endianness is used. |
signed | bool | For integer, packed and zoned fields, defines whether the field is signed. | true |
force_sosi | bool | If set to true , a mixed field is assumed to start in SHIFT-IN mode (like if 0x0e was present) |
false |
enabled | bool | Field anablement (See above) | See above, in "Field Enablement" |
zonedsign | string | Defines the SIGN mode (ascii or ebcdic) of the ZONED fields | ebcdic |
keypart | bool | if set to true , the field is considered part of the key to compare when using filecompare with mode=key |
false |
In fixed format COBOL layouts tags must be placed at column 1. Example:
01 FILE01-REC-COBOL.
03 FILLER.
05 CHAR01 PIC X(8).
@ianus*type=dbcs
05 CHAR02 PIC X(16) VALUE LOW-VALUES.
In free format COBOL layouts, directives can be placed anywhere before the field. Example:
01 FILE01-REC-COBOL.
03 FILLER.
05 CHAR01 PIC X(8).
@ianus*type=dbcs
05 CHAR02 PIC X(16) VALUE LOW-VALUES.
In both examples above, the directive (type=dbcs
) refers to the field imemfdiately following, CHAR02
.
Multiple directive can be specified for a single field, either specifying more than on eattribute in the directive or using multiple directives. For example:
01 FILE01-REC-COBOL.
03 FILLER.
05 CHAR01 PIC X(8).
@ianus*type=dbcs length=12
05 CHAR02 PIC X(16) VALUE LOW-VALUES.
@ianus*type=mixed
@ianus*length=8
05 CHAR03 PIC X(16) VALUE LOW-VALUES.
Example
<filecompare name="FILECMP01" left="REPOEBCDIC" right="REPOASCII">
<log>**** SEQ FIXED comparison - NO DIFF ***</log>
<left recfmt="fixed" reclen="80">IANUS.TEST.SEQ01.EBCDIC.DAT</left>
<right recfmt="fixed" reclen="80">IANUS.TEST.SEQ01.ASCII.DAT</right>
<layouts>
<layout type="cobol" format="free" length="80" zonedsign="ebcdic">
01 FILE01-REC-COBOL.
03 FILLER.
05 CHAR01 PIC X(8).
05 CHAR02 PIC X(16) VALUE LOW-VALUES.
03 ZONED-FIELDS.
05 ZONED01 PIC S9(8) VALUE 0.
05 ZONED02 PIC 9(8) VALUE HIGH-VALUE.
03 COMP-FIELDS.
05 COMP01 PIC S9(8) COMP VALUE 1.
05 COMP02 PIC 9(8) COMP VALUE -1.
05 COMP03 PIC S9(4) USAGE IS COMP.
05 COMP04 PIC 9(4) COMP.
03 PACKED-FIELDS.
05 PACK01 PIC S9(9) USAGE COMP-3 VALUE LOW-VALUES.
05 PACK02 PIC 9(8) PACKED.
</layout>
</layouts>
</filecompare>
<filecopy name="CP03" source="REPODBCS" target="TMPDBCS_A" mode="layout">
<source recfmt="fixed" reclen="80">IANUS.TEST.DBCS01.EBCDIC.DAT</source>
<target recfmt="fixed" reclen="80">IANUS.TEST.DBCS01.DIR01.DAT</target>
<layouts>
<layout type="cobol" format="free" length="80">
01 FILE01-REC-COBOL.
03 FILLER.
05 CHAR01 PIC X(8).
@ianus*type=dbcs name=FAVA
05 CHAR02 PIC X(16) VALUE LOW-VALUES.
@ianus*name=NEWNAME
@ianus*type=mixed
05 CHAR03 PIC X(16).
03 ZONED-FIELDS.
@ianus*type=zoned signed=true
05 ZONED01 PIC X(8).
@ianus*type=zoned signed=false
05 ZONED02 PIC X(8).
03 COMP-FIELDS.
@ianus*type=integer signed=true
05 COMP01 PIC X(4).
@ianus*type=integer signed=false
05 COMP02 PIC X(4).
@ianus*type=integer signed=true
05 COMP03 PIC X(2).
@ianus*type=integer signed=false
05 COMP04 PIC X(2).
03 PACKED-FIELDS.
@ianus*type=packed signed=true
05 PACK01 PIC X(5).
@ianus*type=packed signed=false
05 PACK02 PIC X(5).
03 FILLER PIC X(2).
</layout>
</layouts>
<filecompare name="COMPARE.TAG.CORRECT" left="REPOEBCDIC" right="REPOBGLA" mode="layout" >
<left recfmt="fixed" reclen="80">IANUS.TEST.REDEF02.EBCDIC.DAT</left>
<right recfmt="fixed" reclen="80">IANUS.TEST.REDEF02.ASCII.DAT</right>
<layouts>
<layout type="cobol" format="free">
01 multi-rec.
03 rec-data.
05 fill01 pic x(40).
05 fill02 pic x(40).
03 rec-01 redefines rec-data.
05 rec-01-a pic x(8).
05 rec-01-b pic 9(8).
05 rec-01-c pic x(8).
@ianus*enabled=true
03 rec-02 redefines rec-data.
05 rec-02-a pic x(8).
05 rec-02-b pic S9(8) comp.
05 rec-02-c pic S9(8) comp-3.
05 rec-02-d pic x(10).
05 filler redefines rec-02-d.
07 rava pic s9(8) comp.
03 rec-03 redefines rec-data.
05 rec-03-a pic x(8).
05 rec-03-b pic S9(8) comp.
05 rec-03-c pic S9(8).
05 rec-03-d pic x(8).
</layout>
</layouts>
</filecompare>
</filecopy>