X12Reader error in InterchangeHeader
Hi
I am using below code to get the interchange Control number but getting Null Reference Exception error.
Any idea how to get Interchange Control Number.
I am using Demo version of .NET SDK
using (var ediReader = new X12Reader(x12Stream, LoadFactory, new X12ReaderSettings() { ContinueOnError = true }))
{
x12Items = ediReader.ReadToEnd().ToList();
var icn = ediReader.CurrentInterchangeHeader.InterchangeControlNumber_13;
Console.WriteLine("ICN:{0}", icn);
}
Comments
1 comment
Hi,
You can access the interchange control number like this:
1. When using ReadToEnd() - this would have read ALL the data in the file so potentially multiple interchange control numbers. You need to tell which interchange control number exactly, that's why CurrentInterchangeHeader is NULL because there is no current:
2. When using Read(), you can use the CurrentInterchangeHeader because it's still iterating through the items:
Please sign in to leave a comment.