TransactionParser
    Preparing search index...

    Class DataItem

    The DataItem class represents a single line in a COBOL copybook as an object.

    Data of the line such as the used level, the name of the element, picture clause etc. are parsen into properties of the DataItem

    Implements

    Index

    Constructors

    Properties

    children?: ICopybookItem[]

    List of copybook items containing all children under the current copybook item

    dataPosition: IDataPosition

    Object representing the offset of this copybook item in a transaction and the byteLength of this copybook item determined by the picture, length and usageType

    decimals?: number

    Amount of decimals used, related to PIC clauses defining decimals. Currently not in use, optional

    length: number

    Total length of the copybook item

    level: number

    Level at which this ICopybookItem resides

    name: string

    Name of the copybook item

    occurs?: number

    Amount of times this copybook item occurs, optional

    picture: picture

    Picture clause of the copybook item

    redefines?: ICopybookItem

    Reference to copybook item which the current copybook item redefines, optional

    signed: boolean

    Indicator if the copybook item is signed

    usage: usageType = 'display'

    Usage of the current copybook item, e.g DISPLAY or COMP-3

    value?: string

    Value for the current copybook item. Currently not in use, optional

    Methods

    • Experimental

      Format the DataItem value as a COBOL-style fixed-width string using formatter helpers.

      Returns string

      string String representation of the value for the current instance

    • Set the value for this DataItem taking picture, length and usage into account.

      • For string the value is converted to string, truncated or padded with spaces to length
      • For number and packed the value is converted to a number and validated against length (total digits). Throws when value is not numeric or exceeds the defined length
        • When usage is display, the value is stored as a string padded with leading zeros to match the defined length.
        • When usage is comp (or any other non-display usage), the value is stored as a numeric string without padding (() will handle the conversion to the appropriate binary format based on usage)

      Parameters

      • val: any

        Value to set

      Returns void

      {void}

      Setting the value for a group item (picture group) is not allowed and will throw an error

    • Convert the current value to a buffer.

      If the value is not set, an empty value will be returned according tot the picture and length

      Returns Buffer

      {Buffer} Buffer representation of the current value