COMPILE

Synopsis

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)...]

Description

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.

Example: COBOL schema on read.binary

conv read.binary(file='data.bin'
     table(compile(format='EMP.cbl' ccsid='IBM-037')))
     write.text(file='out.csv')

Example: Mixed manual row-spec and compiled rows

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')

Example: Multiple COMPILE objects with different settings

xcnv input(read.record(table(
     compile(format='HEAD.cbl')
     compile(format='BODY.cbl' ccsid='IBM-037' ims=long))))

Example: ROWOUT caching

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:

Arguments