TransactionParser
    Preparing search index...

    Class CopybookParser

    CopybookParser lets you parse a COBOL copybook into an array of DataItem's that can be then be used further.

    Together with the Transaction and TransactionPackage class, it can be used to load transaction data from a file, parse it into DataItem objects, alter the value and store the (modified) transaction

    Parse a copybook:

    const parser = new CopybookParser('/path/to/copybook'); // Supports any extension
    parser.parse(); // Load copybook as object

    parser.getParsedCopybook(); // Retrieve copybook as object, also returned by the parse() function
    parser.toJson(); // Retrieve copybook as JSON string
    Index

    Constructors

    Methods

    • Parses a copybook for which the path is set in either the constructor or updateCopybookPath(path) and returns an array of DataItem's representing the copybook

      Returns DataItem[]

      Array of DataItem representing the copybook

      • Lines in copybook will be split based on CRLF or LF
      • Tabs will be replaced with spaces, all lines will be trimmed
      • Skips blank lines or comment lines starting with *

      If the copybook contains an OCCURS clause, the processed dataItem will be replaced by n dataItems. They will be identified by the DataItem.name property like NAME-n

      Throws an error when copybook path is not set or doesn't exist, or in certain cases when unable to parse the current copybook line

    • Convert the parsed copybook to a JSON string

      Returns string

      string JSON object representing the copybook as string

      Return value will be an empty JSON array if the parse() function has not yet been executed

    • Updates copybook path

      Parameters

      • copybookPath: string

      Returns void

      This will erased any previously parsed copybook data