Skip to content
This repository was 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

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

Example

import{X12Parser,X12QueryEngine}from'x12/core';letrawEDI='...';letparser=newX12Parser(true);letengine=newX12QueryEngine(parser);letdepartmentNumber=engine.querySingle(rawEDI,'REF02:REF01["DP"]').value;

Element Reference Syntax

[<HL Path>-][<Parent Segment Path>-]<Element Reference>[:<Element Reference>[<Value>]]
SectionExampleDescription
HL PathHL+O+P+IDefines a path through a series of HL segments.
Parent Segment PathPO1-REFDefines a path through a series of adjacent segments.
Element ReferenceREF02Defines 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