HELP: Compile schema files into row specs and append to the row list TYPE: OBJECT SYNTAX: COMPILE[(FORMAT['str'/STREAM/DUMMY...],UNLOAD=NONE/IMSL/IMSS/IMSH/IHDU/IMSL-BOTH/IMSL-WLEN/IMSL-WOLN/IMSS-BOTH/IMSS-WLEN/IMSS-WOLN/IHDU-BOTH/IHDU-WLEN/IHDU-WOLN/DB2U/DB2S/DB2IX,CCSID='str'/DEFAULT/ASCII/EBCDIC/BOMUTF/BOMUCS/SYSTEM/LOCAL,CHRSET=AUTO/ASCII/EBCDIC,MAXOCCURS=num,COLTYPE['str'...],COLPATH=FULL/LEAF,COLSEP=UNDERSCORE/DOT/HYPHEN/NONE,TRIM=NONE/TRAILING/LEADING/BOTH,FILLER=COLUMN/ALIGN/SKIP,ROWIN='str'/STREAM/DUMMY,ROWOUT='str'/STREAM/DUMMY,ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,DETECT)...]
The COMPILE sub-object triggers automatic row-spec generation from schema files. One or more schema files are compiled by the FMT2TAB schema compiler into row specifications that are appended to the row list of the enclosing TABLE object. Manually specified ROW entries and COMPILE-generated rows are combined in a single row list; manual rows come first, then compiled rows in the order the COMPILE objects appear.
Multiple COMPILE objects are allowed within a single TABLE. Each COMPILE object runs the schema compiler independently with its own settings (CCSID, IMS mode, column naming, etc.).
The FORMAT parameter accepts one or more schema file paths. The file format is detected automatically by probing the available schema compilers in order. Currently supported: COBOL copybooks, PL/I structure definitions and HLASM DSECTs. Each compiler is asked in turn whether it recognises the file, and the decision is made on the content: the file name plays no part in it, because on z/OS a schema is a member of a PDS library and carries no extension at all. A file that no compiler accepts is reported as such. See the BCSV command documentation for the PL/I and HLASM type mapping tables; the field annotations DATE, CCSID, BINARY and OMIT are described further down on this page.
ROWIN and ROWOUT provide a caching mechanism: ROWOUT writes the generated TABLE string to a file after compilation; ROWIN reads a previously cached TABLE string instead of running the compiler. When ROWIN is set, FORMAT is ignored.
IMS mode wraps each COBOL structure in an IMS_<SEGNAME> routing block with the appropriate DFSURGU0 prefix columns prepended. The IMS_EOF catch-all drain row is appended automatically. See the BCSV command documentation for details on IMS wrapping formats.
When multiple COMPILE objects or multiple FORMAT values within one
COMPILE object require different unload envelopes, each FORMAT value
may carry a /%<token> suffix (e.g. format='PART.cpy/%imsl') that
overrides the enclosing UNLOAD= for that copybook only. Supported
tokens: imsl, imss, hdu, none (case-insensitive). A FORMAT
value without a /% suffix inherits the enclosing UNLOAD= value.
See the FORMAT parameter manual page for the full syntax and rules.
IHDU mode (UNLOAD=IHDU in the enclosing BCSV command) honours an
optional * SEG-CODE X'NNNN' annotation in the COBOL copybook that
precedes an 01-level definition. The schema compiler pre-scans the
raw source (before COBOL preprocessing), pairs each annotation with
the next 01-level name, and emits a
type.binary(match(data=X'NNNN' fmterr)) predicate on the _hdu_seg_
drain column of the generated row spec. This routes each IMS HD
Unload record to the matching segment row by its SEG-CODE discrim-
inator; records whose SEG-CODE does not match any annotated 01-level
fall through to the IHDU_UNKNOWN catch-all. The annotation must appear
as a COBOL comment (indicator * in column 7 for fixed format, or a
line starting with * for free format); the hex digits must be of
even length. Malformed annotations are silently ignored so that
existing comment text in customer copybooks keeps working. Only the
main copybook file is scanned -- COPY-expanded members are not.
Annotations in non-IHDU unload modes have no effect.
ENDIAN selects the byte order applied to COBOL COMP-5 binary fields. Default SYSTEM follows the runtime platform, BIG forces big-endian (required on open-world hosts reading z/OS-produced COMP-5 bytes), LITTLE forces little-endian, LOCAL follows the physical runtime platform. Regular COMP/COMP-4/BINARY fields are always big-endian per COBOL standard and are not influenced by this parameter.
CHRSET selects the source character set for PIC X/A string columns when no explicit CCSID is given. It resolves to the system-wide default for the chosen charset via the FL_DEFAULT_EBCDIC_CCSID or FL_DEFAULT_ASCII_CCSID environment variables (falling back to compile-time defaults when unset).
When an explicit CCSID parameter is given it takes priority over CHRSET.
conv read.binary(file='data.bin'
table(compile(format='EMP.cbl' ccsid='IBM-037')))
write.text(file='out.csv')
conv read.binary(table(
row(name=HDR fixlen=4 col(name=magic type.binary()))
compile(format='PAYLOAD.cbl' ccsid='IBM-037')))
write.text(file='out.csv')
xcnv input(read.record(table(
compile(format='HEAD.cbl')
compile(format='BODY.cbl' ccsid='IBM-037' ims=long))))
conv read.binary(table(compile(format='HUGE.cbl' rowout='schema.tab'))) conv read.binary(table(compile(rowin='schema.tab')))
Field-level inline annotations allow the schema file to carry type-override hints directly in COBOL, PL/I, or HLASM comments. The compiler recognises four annotation keywords. COLTYPE overrides (runtime parameter) always take precedence over annotations.
COBOL inline comment syntax (COBOL 2002+, IBM Enterprise COBOL v3.2+):
05 ORDER-DATE PIC 9(8) COMP-3. *> DATE YYYYMMDD 05 DELIVERY PIC 9(7) DISPLAY. *> DATE YYYYDDD 05 TIMESTAMP PIC X(26). *> DATE YYYY-MM-DDTHH:MI:SS.ssssss 05 CUST-NAME PIC X(40). *> CCSID IBM-1141 05 INTERNAL PIC 9(4) COMP. *> OMIT 05 RAW-FIELD PIC X(8). *> BINARY
PL/I block comment syntax:
2 ORDER-DATE FIXED DEC(8), / DATE YYYYMMDD / 2 CUST-NAME CHAR(40), / CCSID IBM-1141 / 2 INTERNAL FIXED BIN(15), / OMIT / 2 RAW-FIELD CHAR(8), / BINARY /
HLASM remark field (text after DS operand):
AGFDATE DS PL4 DATE YYYYMMDD AGFNAME DS CL20 CCSID IBM-1141 AGFRAW DS XL8 BINARY AGFINT DS H OMIT
Annotation semantics:
STRING: FORMAT['str'/STREAM/DUMMY...] - Path(s) to schema file(s); format is detected by probing compilers
STREAM - Read from stdin or write to stdoutDUMMY - Read EOF or write nothingNUMBER: UNLOAD=NONE/IMSL/IMSS/IMSH/IHDU/IMSL-BOTH/IMSL-WLEN/IMSL-WOLN/IMSS-BOTH/IMSS-WLEN/IMSS-WOLN/IHDU-BOTH/IHDU-WLEN/IHDU-WOLN/DB2U/DB2S/DB2IX - Database unload format selector [NONE]
NONE - Plain fixed-format input, no unload wrapper [default]IMSL - IMS DFSURGU0 LONG format (IBM z/OS): 20-byte prefix, RECFM=VB, SEGNAM discriminator; both framings (=IMSL-BOTH)IMSS - IMS DFSURGU0 SHORT format (IBM z/OS): 4-byte prefix (LL+ZZ), no SEGNAM; fixlen disambiguates rows; both framings (=IMSS-BOTH)IMSH - IMS DFSURGU0 LONG format (HP variant, not yet supported)IHDU - IMS HD Unload (DFSURGL0): physical DB image, 2-byte SEG-CODE prefix, RECFM=VB; SEG-CODE routing (Wave 2); both framings (=IHDU-BOTH)IMSL-BOTH - IMS LONG: emit both the with-prefix and without-prefix (stripped) rowsIMSL-WLEN - IMS LONG: emit only the with-prefix row (fixlen includes the 20-byte prefix)IMSL-WOLN - IMS LONG: emit only the without-prefix row (read.auto-stripped framing)IMSS-BOTH - IMS SHORT: emit both the with-prefix and without-prefix (stripped) rowsIMSS-WLEN - IMS SHORT: emit only the with-prefix row (fixlen includes the 4-byte prefix)IMSS-WOLN - IMS SHORT: emit only the without-prefix row (read.auto-stripped framing)IHDU-BOTH - IMS HD Unload: emit both the with-prefix and without-prefix (stripped) rowsIHDU-WLEN - IMS HD Unload: emit only the with-prefix row (fixlen includes the 36-byte prefix)IHDU-WOLN - IMS HD Unload: emit only the without-prefix row (read.auto-stripped framing)DB2U - Db2 DSNUTILB UNLOAD FORMAT UNLOAD: RECFM=VB, 2-byte OBID prefix, inline null indicator X'FF' (not yet supported)DB2S - Db2 DSNTIAUL sample program: RECFM=FB, grouped null indicators X'6F' at row front (not yet supported)DB2IX - Db2 PC/IXF self-describing format: H/T/C/D records with embedded schema (not yet supported)STRING: CCSID='str'/DEFAULT/ASCII/EBCDIC/BOMUTF/BOMUCS/SYSTEM/LOCAL - Source CCSID of binary input data for string columns [LANG]
DEFAULT - Use default CCSID (auto-detect)ASCII - Use default ASCII CCSID (environment)EBCDIC - Use default EBCDIC CCSID (environment)BOMUTF - Determine the correct UTF CCSID from byte order mark (BOM) only when readingBOMUCS - Determine the correct UCS CCSID from byte order mark (BOM)only when readingSYSTEM - Use system character set (environment/logical)LOCAL - Use local character set (auto-detect + system/physical)NUMBER: CHRSET=AUTO/ASCII/EBCDIC - Source character set for string columns: AUTO (locale), EBCDIC, or ASCII; resolves via defccsid() [AUTO]
AUTO - Derive from locale/environment (default)ASCII - ASCII/ISO-8859 -- uses defccsid(FL_DEFAULT_ASCII_CCSID)EBCDIC - EBCDIC -- uses defccsid(FL_DEFAULT_EBCDIC_CCSID)NUMBER: MAXOCCURS=num - Maximum OCCURS repetitions expanded per array field; 0 = no limit [0]STRING: COLTYPE['str'...] - Column type overrides for byte array fields: 'pattern/&value'; value is 'binary' or a CCSID name [none]NUMBER: COLPATH=FULL/LEAF - Column naming depth: FULL=full hierarchy path, LEAF=leaf name only [FULL]
FULL - Full hierarchy path from root to leaf, components joined by COLSEP [default]LEAF - Leaf field name only, no path prefixNUMBER: COLSEP=UNDERSCORE/DOT/HYPHEN/NONE - Path component separator in column names (COLPATH=FULL) [UNDERSCORE]
UNDERSCORE - Underscore '_' as path component separator [default]DOT - Dot '.' as path component separatorHYPHEN - Hyphen '-' as path component separatorNONE - No separator between path componentsNUMBER: TRIM=NONE/TRAILING/LEADING/BOTH - Padding removal for PIC X/A string columns [NONE]
NONE - No trimming of padding bytes from string columns [default]TRAILING - Remove trailing padding bytes from PIC X/A string columns (Wave 1)LEADING - Remove leading padding bytes from PIC X/A string columns (Wave 2)BOTH - Remove leading and trailing padding bytes from PIC X/A string columns (Wave 2)NUMBER: FILLER=COLUMN/ALIGN/SKIP - COBOL FILLER field handling: COLUMN=emit as binary col, ALIGN=absorb, SKIP=omit [COLUMN]
COLUMN - Emit FILLER fields as _FILLER_<offset> TYPE.BINARY columns [default]ALIGN - Absorb FILLER alignment padding via FORMAT.FIX(ALIGN=n) on the preceding fieldSKIP - Suppress FILLER fields entirely (Wave 2)STRING: ROWIN='str'/STREAM/DUMMY - Read pre-compiled row-spec TABLE string from this file; FORMAT is ignored when set
STREAM - Read from stdin or write to stdoutDUMMY - Read EOF or write nothingSTRING: ROWOUT='str'/STREAM/DUMMY - Write generated TABLE string to this file after compilation
STREAM - Read from stdin or write to stdoutDUMMY - Read EOF or write nothingNUMBER: ENDIAN=SYSTEM/BIG/LITTLE/LOCAL - Byte order for COMP-5 fields; BIG reads mainframe unloads on open-world [default native]
SYSTEM - Byte order of the default logical systemBIG - Big endian byte orderLITTLE - Little endian byte orderLOCAL - Byte order of the real physical systemSWITCH: DETECT - Emit type.detect() for character string columns (PIC X/A/CHAR/CL) instead of a fixed type.string() [FALSE]