-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edi Reader does not respect X12 advised control characters #19
Comments
@raholland79 A temp workaround until this is fixed would be to alter the default grammar with different presets: public class CustomX12Grammar : EdiGrammar
{
public CustomX12Grammar : base()
{
_ComponentDataElementSeparator = '>',
_DataElementSeparator = '*',
_DecimalMark = '.',
_ReleaseCharacter = null,
_Reserved = new char[0],
_SegmentTerminator = '~',
_ServiceStringAdviceTag = null,
_InterchangeHeaderTag = "ISA",
_FunctionalGroupHeaderTag = "GS",
_MessageHeaderTag = "ST",
_MessageTrailerTag = "SE",
_FunctionalGroupTrailerTag = "GE",
_InterchangeTrailerTag = "IEA",
}
} |
So in the case of
We have no segment terminator - How do I represent that? Also using the example given, on every file I try, I get this error
|
sorry about that. My intention was to show how you could work around this by testing different character sets for the delimiters. Since it is not clear without the complete edi transmition what they are. Consider the above as the default configuration. I am guessing that a space is used as the |
take a look this is what I found about what X12 990 looks like. Its a sample I found googling about it
|
Ok according to these guys here
this means that there is a great possibility that your delimiters are not visible. According to the same link standards suggest you use the following control characters (some of them invisible). Try this: public class CustomX12Grammar : EdiGrammar
{
public CustomX12Grammar : base()
{
_ComponentDataElementSeparator = '>'; // for 990
//_ComponentDataElementSeparator = ':'; // for your 214
_SegmentNameDelimiter = (char)Int16("001D", System.Globalization.NumberStyles.AllowHexSpecifier);
_DataElementSeparator = (char)Int16("001D", System.Globalization.NumberStyles.AllowHexSpecifier);
_SegmentTerminator = (char)Int16("001C", System.Globalization.NumberStyles.AllowHexSpecifier);
_DecimalMark = '.',
_ReleaseCharacter = null,
_Reserved = new char[0],
_ServiceStringAdviceTag = null,
_InterchangeHeaderTag = "ISA",
_FunctionalGroupHeaderTag = "GS",
_MessageHeaderTag = "ST",
_MessageTrailerTag = "SE",
_FunctionalGroupTrailerTag = "GE",
_InterchangeTrailerTag = "IEA",
}
} PS: You could try to see the Unicode |
That matches mine exactly' However, using the default config above for files that conform to the default configuration I still get:
The code is the default as you've written above - and the 214 works fine with the default NewX12() But using the custom grammar gives the expect * but got * error.
|
I can't get it working. I may have to try Edi Fabric - but would rather not. I have a customer wanting this done NOW though. |
@raholland79 I can see if I can make this work but I need you to send me the original sample file (not tampered with), If this is sensitive information involved send me via email here: c.leftheris at live.com . I need the originals because any file edited with a text editor may have stripped out the invisible control characters we are searching for. I have been working hard to release a first version that includes the Serialization (writing back to EDI) for a while now. Not an easy task since this is an opensource project I work on my free time. That said it just came out yesterday v1.1 and its out of the way. |
Oh I know you're working hard - And I appreciate it immensely I'd be willing to toss some cash your way for your hard work. I've attached a zip with all 4 files. If I remember right only the 214 is working out of the box. |
204 and 990 are top priority |
@raholland79 Ok the issue here is that the new line |
So basically replace the trailing \n on the ISA line in code with a ~ and process from there? |
No you must replace every occurrence of the [Fact]
public void X12_204_Test() {
var grammar = EdiGrammar.NewX12();
grammar.SetAdvice(
segmentNameDelimiter: '*',
dataElementSeparator: '*',
componentDataElementSeparator: ':',
segmentTerminator: '~',
releaseCharacter: null,
reserved: null,
decimalMark: '.');
string text = File.ReadAllText(@"C:\sandbox\drdispatch\EDI\assets\204-MGCTLYST-SAMPLE.EDI");
var segmentCount = 0;
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text.Replace('\n', '~')))) {
interchange = new EdiSerializer().Deserialize<Models.Transportation_204>(new StreamReader(stream), grammar);
}
} this reads the whole file into a string. Then replaces the character and at last it feeds the result to the |
My idiot vendor now says the terminator should be ~ on all files - I'm reconfirming to be sure - but If so this makes the library work as is without any work around and you can backlog this particular bug for more important work. I'll let you know ASAP. Again, thanks for the wonderful hard work and excellent communication. |
They're good with ~ so - while this may be a bug I don't need it handled. |
@raholland79 glad you made it work. Issue #24 is still one of my top priorities. Thanks. |
I did find a way to solve this issue (Not nice ,but works) My solution ? Not nice but solves the File attached shows the method I did. Better solution would be to allow proper reading of the ISA16 field though. |
Hi @PGP-Protector, Unfortunately this is still an issue. The main reason is that I did not find the time. Changing the code to be able to treat Regarding your workaround, it seems fine to me. The only improvement (suggestion) would be to use the var grammar = EdiGrammar.NewX12();
grammar.SetAdvice(
segmentNameDelimiter: '*',
dataElementSeparator: '*',
componentDataElementSeparator: ':',
segmentTerminator: '!',
releaseCharacter: null,
reserved: null,
decimalMark: '.'); |
In all known EDI formats there are default control characters these are documented in the default
EdiGrammar
presets.EdiGrammar.NewEdiFact()
EdiGrammar.NewX12()
EdiGrammar.NewTradacoms()
Now in the EdiFact and X12 cases there is a way for the transmitter (he who sends the edi transmission)
to advise differently for each of the control characters.
Control characters are considered to be the segment, element & component seperators plus the escape character.
In X12 the current implementation completely ignores them.
The text was updated successfully, but these errors were encountered: