X12 Decode V2 | DECODE_X12_V2

Syntax

DECODE_X12_V2( [value], [mapping], [includeEnvelope = false] )

Parameters

value
An X12 encoded TEXT value to decode. If it is not a TEXT value, it will be converted to one with the STRING operation.

mapping
A preset map definition that instructs the parser on how to organize the data it finds in the X12 document. Include the document number or define your own custom document mapping. Built-in templates include "940" and "945".

includeEnvelope optional
Boolean value that tells the parser whether or not to include the edi envelope in the parsed results. Defaults to false.

Return Value

An ARRAY value formatted as a segment document according to the mapping provided.

Description

Decode a TEXT value as an X12 document. Uses mapping declarations to properly organize loops. For more information on the X12 format, please visit https://www.edi-plus.com/resources/message-formats/ansi-x12/.

Examples

# value is a complete 940 EDI document
DECODE_X12_V2(VALUE, "940")            
# value is a complete 945 EDI document
DECODE_X12_V2(VALUE, "945")            
# includes the ISA, GS, GE, and IEA segments in the output.
DECODE_X12_V2(VALUE, "940", true)                           
# a custom document definition, output will only include N1 segment with N3, N4, and PER as subloops
DECODE_X12_V2(VALUE, DECODE_JSON('[{"N1": [{"N3":[]},{"N4":[]},{"PER":[]}]}]'))