Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

X12QueryEngine API

Josh Johnson edited this page Apr 19, 2016 · 4 revisions

API Surface

The X12QueryEngine class requires an instance of X12Parser to be constructed. Please visit the X12Parser API documentation first before reading this document.

Constructor

constructor(private _parser: X12Parser) { }

Instance Methods

Method Returns Notes
query(rawEdi: string, reference: string) X12Element[] The reference argument must be a valid element reference.
querySingle(rawEdi: string, reference: string) X12Element The reference argument must be a valid element reference.

Example

import { X12Parser, X12QueryEngine } from 'x12/core';

let rawEDI = '...';

let parser = new X12Parser(true);
let engine = new X12QueryEngine(parser);

let departmentNumber = engine.querySingle(rawEDI, 'REF02:REF01["DP"]').value;

Element Reference Syntax

[<HL Path>-][<Parent Segment Path>-]<Element Reference>[:<Element Reference>[<Value>]]
Section Example Description
HL Path HL+O+P+I Defines a path through a series of HL segments.
Parent Segment Path PO1-REF Defines a path through a series of adjacent segments.
Element Reference REF02 Defines an element by position.
Value "DP" Defines a value to be checked when evaluating qualifiers.

Example 1: Select All REF02 Elements
REF02

Example 2: Select All REF02 Elements With a PO Qualifier in REF01
REF02:REF01["PO"]

Example 3: Select All Line-Level PO Numbers (850)
PO1-REF02:REF01["PO"]

Example 4: Select All ASN Line Quantities
HL+S+O+P+I-LIN-SN102

API Documentation

Clone this wiki locally