Closed skhan-nacmgit closed 4 years ago
Interestingly, a PO with the same ISA seems to work just fine.
ISA00 00 08TPTESTUS00 ZZTESTCOMP 1910291900:005018201010470P>
@skhan-nacmgit You are not setting the grammar correctly. The in the SetAdvise
you are not providing the characters in the correct positions. Please use the other overload which guides you through like seen below:
// Load the EDI Parser
var grammar = EdiGrammar.NewX12();
// Set terminators specific to vendors
grammar.SetAdvice('*', '*', '>', '\n', null, null, '.'); // <-- use this
Also since the segment terminator is the newline itself make sure you got a newline in the end of your transmission at the end of the IEA
line
This suggestion doesnt work. I am setting the grammar like this:
grammar.SetAdvice('*', '*', ':', '\n', null, null, '.');
This is a sample taken from a document in prod
ISA*00* *00* *08*999999US00 *ZZ*TEST99 *191118*1956*:*00501*820101061*0*P*>
GS*RA*999999US00*TEST99*20191118*1956*820101061*X*005010
ST*820*101067
BPR*I*104029.25*C*CHK************20191118*VEN
TRN*3*4614814
CUR*PR*USD
N1*PR*TESTMART INC.*UL*0078992000008
N1*PE*Test Company, LLC
REF*IA*449963
ENT*1
RMR*IV*27213*PO*4212.34*4302.93*90.59
REF*DP*00040
REF*MR*0020
REF*PO*2708989667
REF*MC*944506856
REF*19*07
REF*ST*0078742033587
DTM*097*20190924
SE*336*101067
GE*1*820101061
IEA*1*820101061
var grammar = EdiGrammar.NewX12();
grammar.SetAdvice('*', '*', ':', '\n', null, null, '.');
// Wire up an 820 MAP
var interchange = default(RemittanceAdvice_820);
using (var stream = new StreamReader(@"C:\PATH_TO_820.304.EDI"))
{
interchange = new EdiSerializer().Deserialize<RemittanceAdvice_820>(stream, grammar);
//Console.WriteLine("Document Date: " + interchange.Date);
//Console.WriteLine("Sender ID: " + interchange.Sender_ID);
//Console.WriteLine("Reveiver ID: " + interchange.Receiver_ID);
}
Console.Read();
Fails with
Additional information: Unable to convert string '>
GS' to char. It is more than 1 character long.
Evan if I add a New Line after IEA
And if I change the grammar to:
grammar.SetAdvice('', '', '>', '\n', null, null, '.');
I get the error: Unterminated string. Expected delimiter. Path 'ISA[1061][0]', line 412, position 17.
Hi you issue is definitely related to the advise characters but it does not seem to be a bug since I cannot reproduce. I am not sure of the correct advise if I don't see the original file. I suspect that by copy pasting in the github comment I only see \r\n
so I suspect that \n
is the correct character for segment termination. It may not be the case, and you may have the \r
instead (Or even a more weird control character that is not even visible).
you can either
I am setting the grammar as such:
grammar.SetAdvice('*', '*', ':', '\n', null, null, '.');
and all when I choose to display all characters in my file using Notepad++ I see each line ending with CRLF
e.g.
REF*DP*00040 CRLF
REF*MR*0020 CRLF
REF*PO*2708989667 CRLF
REF*MC*944506856 CRLF
REF*19*07 CRLF
REF*ST*0078742033587 CRLF
I can cleanup a production file and email it to you if that helps.
Please make a pull request with your failing test & file. Because as I stated above the file is working as expected on my side.
One last thing. Are you running on the latest version of the library?
Ok. I'll make the pull request. I am using v1.9.6.0.
I copied down your test and for some reason it works. I do have to manually add the newline after IEA. Is there a way to get this added automatically if required in a file?
This issue can be closed.
I do have to manually add the newline after IEA. Is there a way to get this added automatically if required in a file?
There is a bug that I will be fixing today regarding the new line. Exprect to land in v1.9.7.
This a basic test:
POCO
Loading the doc:
This is a test 820
The Error:
An unhandled exception of type 'indice.Edi.EdiException' occurred in indice.Edi.dll Additional information: Unable to convert string '> GS' to char. It is more than 1 character long.