COBOL Copybook Parser
Overview
You can use the Copybook Snap for consuming one or more COBOL Copybooks and a data stream to produce a JSON formatted message containing the structured payload.
Snap Views
| Type | Description | Examples of Upstream and Downstream Snaps |
|---|---|---|
| Input | The input to this Snap must be a flat binary file containing the data that must be mapped by the COBOL structure(s) provided as part of the configuration. | File Reader, Zip File Reader |
| Output | The output is structured results in JSON format based on the data provided. | JSON Splitter, Sort Snap |
| Learn more about Error handling. | ||
Snap Settings
| Field/Field set | Description |
|---|---|
Label* String |
Specify a unique name for the Snap. You can modify the default name especially if you have more than one of the same Snaps in your pipeline. Default value: Cobol Copybook Parser Example: Process The 038 Copybook |
Copybooks*
Fieldset |
Use this field set to define the Copybooks to use. |
Copybook File* String/Expression |
Specify the Copybook file which describes the data. Alternatively, click the upload icon to browse and upload the desired copybook file. Default value: N/A Example: PipeRecFileOfPS.json |
Copybook Split* String/Expression |
Select the option to split the copybook for processing. The available options are:SPLIT_NONE: No split.SPLIT_01_LEVEL: Splits on all 01 levels.SPLIT_TOP_LEVEL: Splits on the top-level structures defined by a level that is is greater than level 01.SPLIT_REDEFINE: Splits on the highest level of COBOL REDEFINE structures.If the Copybook contains multiple ‘01 entries’, it must be split for processing.If the Copybook contains multiple structures below the 01 level, that must be used.noteIf the Copybook contains multiple ‘01 entries’, it must be split for processing.If the Copybook contains multiple structures below the 01 level, that must be used.If the Copybook contains multiple ‘01 entries’, it must be split for processing.If the Copybook contains multiple structures below the 01 level, that must be used. Default value: SPLIT_NONE Example: SPLIT_01_LEVEL |
Organization* String/Expression |
Specify the type of file organisation for the data payload. Alternatively click the Suggestionicon to fetch a list of file organisation types and select the desired organisation.IO_DEFAULT: Attempt to automatically detect the file organisation.IO_STANDARD_TEXT_FILE: Standard file using CRLF or LF as newline delimiter.IO_UNICODE_TEXT: Unicode/double byte file using CRLF or LF as newline delimiter.IO_FIXED_LENGTH: Every record (or line) is a standard fixed length based on the maximum record length (determined from copybook).IO_CONTINOUS_NO_LINE_MARKER: Files where there are no End-of-Line markers. Records are based on Record-Lengths.IO_VB: Mainframe VB (Variable Record length file). Records consist of a Record-Length including the length of the following data followed by the Record-Data.IO_VLI: Mainframe like VB (Variable Record length file). Records consist of a byte swapper Record-Length excluding the length of the following data followed by the Record-Data. Default value: IO_DEFAULT Example: IO_UNICODE_TEXT |
Dialect* String/Expression |
Specify the COBOL dialect. The available options are:FMT_MAINFRAME: Mainframe COBOL (Big Endian).FMT_INTEL: Intel COBOL (Little Endian).FMT_FUJITSU: Fujitsu Cobol 3 compiler.FMT_OPEN_COBOL: GnuCobol (formerly Open Cobol) on a Little-Endian machine.FMT_OC_MICRO_FOCUS_B: GnuCOBOL running in Microfocus compatibility mode on a Big-Endian machine.FMT_BIG_ENDIAN: Generic Big Endian.The selected dialect determines how the parser deals with binary information in the input file. Default value: FMT_MAINFRAME Example: FMT_INTEL |
Encoding* String/Expression |
Specify the format for encoding the input data. Any supported Java encoding is available for use. Some common code pages to be used: CP1141: Standard mainframe EBCDIC code page. ASCII: Standard ASCII files. Windows-1252: Standard code page used on Windows platforms. Default value: UTF8 Example: CP1252 |
Enclose character values in quote Checkbox |
Select this checkbox to wrap all character fields in single quotes. Many applications need to differentiate between character and numeric fields. Default value: Selected |
Compatibility Checkbox |
Select this checkbox to maintain backward compatibility with the original version of the Snap. However, we recommend that you update your pipelines to handle the new format immediately, as this checkbox will be removed in a future release.noteThe key distinctions introduced with theCompatibilitycheckbox are:A line element starts each output JSON record when the structure begins with a structure name. If you select this checkbox, the Snap does not output the JSON record.When an array element only contains one item, the item is added. If you deselect this checkbox, an array is consistently generated regardless of the number of items in the array.All items are treated as strings with varying attempts to turn to strings when numeric. If you deselect this checkbox, the Snap handles the field based on the data type indicated by the COBOL field type.The key distinctions introduced with theCompatibilitycheckbox are:A line element starts each output JSON record when the structure begins with a structure name. If you select this checkbox, the Snap does not output the JSON record.When an array element only contains one item, the item is added. If you deselect this checkbox, an array is consistently generated regardless of the number of items in the array.All items are treated as strings with varying attempts to turn to strings when numeric. If you deselect this checkbox, the Snap handles the field based on the data type indicated by the COBOL field type. Default value: Selected |
Truncate picX field spaces* String/Expression |
Specify or select the setting that determines the blanks that are stripped off from a character field. The available options are:OFF: No stripping of blanks will occurBOTH: Blanks will be stripped from both the start of the data value and the end.LEADING: Blanks will be stripped from the start of the data value.TRAILING: Blanks will be stripped from the end of the data value. Default value: BOTH Example: OFF |
Selection Criteria
Button |
The provision of XML selection criteria offers complex selection criteria. This is provided using an XML structure as described below.Selection criteria must be provided in the Snap to match a data record to the copybook structure. The selection criteria is an XML-based configuration as follows:<sc:selection xmlns:sc="http://www.snaplogic.com/namespaces/cobol/selectionCriteria"> <recordSelection> <name>STRUCTURE_NAME</name> <fieldSelection> <field name="FIELD_NAME">VALUE</field> </fieldSelection> </recordSelection> </sc:selection>Where:STRUCTURE NAMEis the name of the structure containing the field.FIELD NAMEis the name of the field within the structure to be compared.VALUEis the value to be compared. When this is equal to the FIELD NAME contents in a record being processed, this structure will be selected.It is possible to have AND along with OR conditions:<fieldSelection>elements are OR-ed<field name>elements are AND-ed Default value: N/A Example: The following selection criteria would match:REC-TYPE = "P"or"T" to the DETAIL record.REC-IND = "X1"andREC-TYPE = "T" to the TRAILER record.<sc:selection xmlns:sc="http://www.snaplogic.com/namespaces/cobol/selectionCriteria"> <recordSelection> <name>DETAIL</name> <fieldSelection> <field name="REC-TYPE">P</field> <fieldSelection> <fieldSelection> <field name="REC-TYPE">T</field> </fieldSelection> </recordSelection> <recordSelection> <name>TRAILER</name> <fieldSelection> <field name="REC-IND">X1</field> <field name="REC-TYPE">T</field> </fieldSelection> </recordSelection> </sc:selection> |
Header Structure (for first record) String |
Specify a Header record which is the first record in the file.If the data being processed has a header, middle and/or trailer structure name then, specify the name of the header structure to process the first record of the file.If the header structure is not provided, the specified middle structure interprets the first record from the file being processed. Default value: N/A Example: Header-record |
Middle Structure Name (all records in between) String |
Specify one or more Middle records which contain the main data.If the data being processed contains a header and/or a middle structure and/or a trailer structure name then, specify the name of the middle structure to be used to process the record(s) between the first and last records of the file.If no middle structure is provided and a header structure name is provided, the specified header structure will be used to interpret the records subsequent to the first record of the file being processed. Default value: N/A Example: Detail-record |
Trailer Structure Name (for last record) String |
Specify a Footer record which is the last record in the file.If the data being processed contains a header and/or a middle structure and/or a trailer structure name then, specify the name of the trailer structure here to be used to process the record(s) between the last record of the file.If no trailer structure is provided and a middle structure name is provided, the specified middle structure will be used to interpret the last record of the file being processed. Default value: N/A Example: Trailer-record |
Configure error processing
Fieldset |
Configure the action the Snap must take when an error occurs. |
Set maximum acceptable number of errors String |
Set the maximum number of acceptable errors that can occur before the Snap terminates. Zero (0) indicates no limit on errors that can be issued. |
Configure field error processing
Fieldset |
Use this field set to configure the Snap's action when an error occurs for each field. |
Field Name String/Expression/ Suggestion |
Specify or select the full name (this must include structure for uniqueness) of the COBOL field being configured. |
Error processing configuration* Dropdown list |
Select or set the action the Snap must take when an error occurs when processing:Fail:The pipeline processing fails immediately an error is encountered on this field. This is the default behavior of the Snap.IgnoreField:The field is ignored and is not included in the output record.IgnoreRecord:The entire record is ignored and not included in the output.DefaultValue:The default value provided will be output for the field in the output record. |
Default value for field String/Expression |
This is the value that will be output for a field when the DefaultValue is configured for the field. |
Debugging configuration
Fieldset |
Configure the debugging properties. |
Name of only structure to output String/Expression/ Suggestion |
Specify or select the name of the only structure for which data is to be sent to the output. Data for any other structure will be ignored and is not sent to the output. |
Ranges of records to be output
Fieldset |
Specify one or more ranges of records to be output. |
Low record for range String |
Specify the first record in the range to be output.noteThe numbers here are relative to 1, so 1 is the first record, 2 is the second record.If the ranges include records which don’t exist in the input data, these will simply be ignored.If ranges overlap, this will cause a configuration error.The numbers here are relative to 1, so 1 is the first record, 2 is the second record.If the ranges include records which don’t exist in the input data, these will simply be ignored.If ranges overlap, this will cause a configuration error. |
High record for range String |
Specify the last record in the range to be output. |
Snap execution Dropdown list |
Choose one of the three modes in
which the Snap executes. Available options are:
|
Troubleshooting
| Error | Reason | Resolution |
|---|---|---|
| "No copybooks provided or found in configuration" | At least one copybook must be configured for the Copybook Parser Snap. | Configure one or more Copybooks for the Snap. |
| "Header structure, middle structure or trailer structure cannot be specified with selection criteria" | A Header, Middle or Trailer structure has been specified along with the selection criteria for records. | Change the configuration to specify either the Selection criteria XML _OR_ one of more of the Header, Middle or Trailer structure configuration parameters. |
| "File : <file name> not found" | The file name provided for a Copybook cannot be found while trying to read the copybook file or files configured. | Review the configuration for the copy book files and ensure that they all exist and are accessible. |
| "Input protocol <protocol> not supported" | The protocol <protocol> provided for a copy book is not supported | Ensure the file names provided for each copybook use a supported protocol. |
| "No copybooks provided or found in configuration" | At least one copybook must be configured for the Copybook Parser Snap. | Configure one or more copybooks for the Snap. |
| "Failed to process copybooks due to: <error message>" | The Snap encountered difficulties while processing the provided copybooks using the available configurations, resulting in unsuccessful processing attempts. | Review the message provided in “<error message>” and correct the error highlighted there. |
| "Structure <name> not found in copybooks" | The structure name <name> has been provided as a configuration parameter but the structure does not exist in the copybooks provided. | Ensure that you provide the accurate copybooks or specify the correct structure name referenced to identify a structure included in the provided copybooks. |
| "Field <field name> not found in structure <structure name>" | The field was not found in the structure . | Correct the field name to reference the correct name in the named structure or the correct structure where the field name is defined. |
| "IO Error combining copybooks due to: <error message>" | A system error occurred combining multiple copybooks for processing. | Determine the problem based on the “<error message>” provided and correct the error. |
| "Range %d:%d overlaps with range %d:%d" | Multiple debug ranges have been provided and one range overlaps with another range. | Identify the range based on the ranges in the message and correct the overlap. |
| "Invalid range low record number <low> is higher than the high record number <high> | The lower range is higher than the higher range. | Correct the range specification so that the low range is less than or equal to the high range. |
| "Failed to parse XML selection criteria due to: <error message>" | An attempt to parse the XML provided in the selection criteria failed due to the error provided as “<error message>”. | Determine the problem with the XML based on the <error message> and correct the provided XML. |
| "Invalid error field configuration setting <setting> for field <field name>" | A field error configuration setting is invalid. | Correct the setting for the field configuration based on the suggestions provided in the configuration. |
| "I/O Error processing record <record number>, processing terminated" | An I/O error occurred while processing the record number. | Search for system or other errors during the runtime and correct the issue. |
| "Execution terminated as error count <error count> exceeded configured maximum error count <maximum errors>""Failed to process field <field name> due to <Error message>" | The Snap processing has terminated because the number of errors encountered while processing the data is more than the maximum errors configured. | Correct the errors that have occurred or increase the error threshold. You can increase the number of expected errors allowed by adjusting the maximum error configuration. By doing so, the Snap can complete its processing even if additional errors are encountered. |
| Snap fails to process any data. |
The File Organization is incorrect. For example, IO_FIXED_LENGTH is specified but the file contains CR/LF or LF characters. The Snap can also fail when:
|
Manually inspect the data along with the COBOL structures to determine:
|
| Snap processes some data but fails mid-way through the process. | This can be caused by any of the reasons where no data is processed so check these first.Invalid packed decimal data has been encountered which causes an exception processing an individual data record. | Check all the possibilities included for when the Snap does not process any data.Identify the record that is causing the failure. Work through the data based on the COBOL structure that should process this record and identify the invalid data. |
| Character data is invalid or contains single invalid data. | The encoding selected does not correctly reflect the encoding used for the input character data. | If the character data is totally corrupted, it suggests that you have selected an ASCII related encoding for EBCDIC input or vice versa. You can view a character field in the data to establish if the data is EBCDIC or ASCII encoded.If the character data is legible but some characters are corrupted, it suggests that you have not selected the correct ‘flavor’ of the ASCII or EBCIDC encoding. For example, this may be that a US EBCDIC codepage is selected but the character data is Portuguese EBCDIC encoded. |
| Unable to determine structure for field names. | The COBOL structures that you have provided cannot support field configuration. | Contact SnapLogic Customer Support for more details. |
Additional Information
The input to this Snap must be a flat binary file containing the data that must be mapped by the COBOL structure(s) provided as part of the configuration. This file will consist of data that have records with the following formats. For the records to be processed correctly, you must configure the correct record type processing for the records to be processed accurately:
- Fixed Length records: Records with a consistent fixed length, the total length of the COBOL structure or structures configured for the Snap.
- Records delimited by a carriage return/line feed (CR/LF) or just an LF: Records separated by CR/LF characters within the data. The data length between these CR/LFs may be fixed or variable and must be correctly represented by the length of the COBOL structure or structures configured for the Snap.
- Variable blocked records: Variable length records created on IBM z/OS environments with an RDW before each record. This RDW includes the record length, including the length of the following data followed by the Record-Data.
- Alternate variable blocked records: Records consist of a byte swapper record length excluding the length of the following data followed by the record data.
To ensure accurate processing of the data, you must configure the following types of data correctly:
- Character data:This data should have a code page you must correctly specify in your configuration.
- Binary data:These are binary numeric values with a specific endianness (the order in which the bits are transmitted over a communication channel) depending on the platform from which they have come.Big Endian generally comes from older mainframe platforms (z Series, i Series, Solaris, etc.) and is where the high-order byte of the binary value is the most significant byte.Little Endian generally comes from newer platforms (x86, x86-64, and so on) and is where the low-order byte of the binary value is the most significant byte.