web stats
Mirth Community - View Single Post - Batch processing edi 834 files
View Single Post
  #11  
Old 07-17-2017, 09:28 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

Quote:
Originally Posted by kirbykn2 View Post
I did something similar for an X12 file. I set "Process Batch" to yes on the summary tab, then configured the "Batch Delimiter" in "Set Data Types".

I have similar set up with following code in batch script and it takes ages to run and it spits out just one message and after that I see heapspace error

var segDelim = '~';
var elementDelim = '*';
var subelementDelim = ':';
var infer = true;

var message = new java.lang.StringBuilder();
var ch;
while ((ch = consume(1)) != null) {
if (infer) {
elementDelim = consume(3);
subelementDelim = consume(101);
segDelim = consume(1);
consumeNewline();
infer = false;
continue;
} else if (ch == segDelim) {
consumeNewline();
reader.mark(3);
if (readChar() == 'I' && readChar() == 'N' && readChar() == 'S') {
reader.reset();
break;
}
reader.reset();
}
}

return message.toString();

function readChar() {
var c = reader.read();
return c == -1 ? null : java.lang.Character.valueOf(c);
}

function consume(num) {
var ch;
for (var i = 1; i <= num; i++) {
ch = readChar();
if (ch != null) {
message.append(ch);
}
}
return ch;
}

function consumeNewline() {
reader.mark(1);
var ch = readChar();
if (ch == '\r') {
message.append(ch);
reader.mark(1);
if ((ch = readChar()) == '\n') {
message.append(ch);
} else {
reader.reset();
}
} else if (ch == '\n') {
message.append(ch);
} else {
reader.reset();
}
}
Reply With Quote