Article: Splitting Data – JS

Index

Splitting Data

EDIFileSplitter is capable of splitting an X12 EDI data into many smaller strings. Developers can split data at the envelope level (ISA), the functional group level (GS) , or the header level (ST) by setting the FileSplitLevel property of EDIFileSplitter.

Example

const edi = require(‘rdpcrystal-edi-library’);
 
//Original document with 2 Transactions (ST)
let original =”ISA*00*          *00*          *ZZ*133052274      *ZZ*311279999…”;
 
//Create a new EDIFileSplitter
let splitter = new edi.EDIFileSplitter();
 
//Split the document at the ST header
splitter.FileSplitLevel = edi.FileSplitLevel.HEADER;
 
//Put 1 ST-SE loop in each file
splitter.NumberOfItemsPerFile = 1;
 
//Split the document
let splitDocs = splitter.split(original);
 
console.log(“First Split Document”);
console.log(splitDocs[0]);
 
console.log(“Second Split Document”);
console.log(splitDocs[1]);

EDIFileSplitter will add the correct number of items in element 1 of the SE, GE, and IEA segments.

Related Articles

Main Categories