[ Web Proxy ]
URL:
Viewing: https://cloud.google.com/mainframe-connector/docs/copybook-reference#native-copybook-parser [Back]  [Original]

Copybook parser reference  |  Mainframe Connector  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Copybook parser reference Stay organized with collections Save and categorize content based on your preferences.

Mainframe Connector supports two versions of the copybook parser:

Note: The Legacy parser is being deprecated. We recommend that you switch to the Native copybook parser.

You can define which parser you want to use based on your copybook. For more information on defining the parser that you want to use, see Define the copybook parser.

Native copybook parser

The Native copybook parser is the latest version of the parser and is used by default. The native copybook parser implements an ANTLR4-based parser and supports COBOL copybooks.

This section lists the preprocessing tasks performed by the Native copybook parser. It also outlines the data types supported by the Native copybook parser and the restrictions for its use.

Preprocessing

Before parsing a copybook, the Native copybook parser preprocesses the data and performs the following tasks:

Supported data types and restrictions

The following are the data types supported by the Native copybook parser and the restrictions for its use:

Support for date and timestamp fields

Mainframe Connector supports moving date and timestamp data in and out of BigQuery. To do so, you must define environment variables that begin with the word SUFFIX in the following format:

SUFFIX_SUFFIX_STRING="command --format FORMAT --timezone TIMEZONE"

The following list describes the format in more detail:

To add an alias for a SUFFIX_SUFFIX_STRING, you can set an environment variable SUFFIX_SUFFIX_ALIAS=$SUFFIX_SUFFIX_STRING.

Examples:

Support for null indicators

Mainframe Connector supports null indicators starting with version 5.13.0. To use null indicators, you must define environment variables that begin with the word SUFFIX in the following format:

SUFFIX_NULL_INDICATOR_NAME="command --null-value NULL_VALUE --not-null-value NOT_NULL_VALUE"

NULL_INDICATOR_NAME corresponds to the suffixes -NULL_INDICATOR_NAME or _NULL_INDICATOR_NAME that are interpreted as a null indicator when used as a suffix of a field name in a copybook.

The following list describes the parameters you can use with these environment variables:

If the null-indicator doesn't have a referenced field, Mainframe Connector displays an error message and stops processing the files.

Examples:

Copybook snippet

10 COL1-NID1            PIC S9(4) USAGE COMP.
10 COL1                 PIC S9(6) USAGE COMP.

10 FIELD       PIC        X(10).
10 FIELD-NID2  PIC        X(1).

10 COL2       PIC        X(10).
10 COL2-NULL  PIC        X(1).

Environment variables definition

SUFFIX_NID1="null-indicator --null-value -1 --not-null-value 0"
# Copybook fields with NID1 suffix null indicator configuration.
SUFFIX_NID2="null-indicator --null-value '?'"
# Copybook fields with NID2 suffix null indicator configuration.
SUFFIX_NULL="null-indicator --null-value '?' --keep"
# Copybook fields with NULL suffix null indicator configuration.

Support for DBCS fields

Ensure the following when using DBCS fields:

For example, if your data corresponding to the copybook field 03 FLD01 PIC N USAGE DISPLAY-1 contains bytes 0x43 and 0xC5 in encoding x-IBM930 that are not surrounded by 0x0E and 0x0F, you must rename the copybook field name to 03 FLD01-DBCS PIC N USAGE DISPLAY-1 in order to correctly decode the DBCS data.

Support for variable-length character strings

The Native copybook parser supports the following struct fields:

The first field in the struct field is the length of the second field, the string field. You might have to add some padding to the end of the record based on the record length as shown in the following figure.

Padding added to variable-length character strings. [Padding added to variable-length character strings.] Figure 1. Padding added to variable-length character strings.

Mainframe Connector removes the suffix from the variable name before saving the data in BigQuery. In this example, the variable name will be var.

To use struct fields, set the environment variable BQSH_FEATURE_VARIABLE_LENGTH_ENABLED to either yes or true.

When using struct fields, ensure the following:

Unsupported fields and constructs

The following sections describe fields and constructs are not supported by the

COBOL constructs

COBOL constructs even though these constructs are not supported. If you use these constructs in your copybook, Mainframe Connector shows an error.

Data types

COBOL data types like COMP-1 and COMP-2 are supported.

Legacy copybook parser

The legacy copybook parser is an older version of the parser that supports non-COBOL features. If you are using DSL-based copybook the legacy parser might be more suitable as the Native copybook parser might cause errors.

Note: The Legacy parser is being deprecated. We recommend that you switch to the Native copybook parser.

You can use copybook DD with the following restrictions:

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page