olmelabs / EdiEngine

Simple .NET EDI X12 Reader, Writer and Validator. EDI JSON Serialization and Deserialization. Written in C#
MIT License
99 stars 47 forks source link

ISA not found #32

Open denniselit opened 2 years ago

denniselit commented 2 years ago

Hi,

Im fairly new to EDI and tries to convert an EDIFACT message to json or XML with EdiEngine, however the files I receives does not start with ISA (since it's EDIFACT and not X12 i think?).

Is there a way to work around or fix this with EdiEngine?

The structure in the files I receive looks like this (https://learn.microsoft.com/en-us/biztalk/core/edi-headers-and-trailers):

UNA Service String Advice  
UNB Interchange Control Header  
  UNG Functional Group Header  
    UNH Message Header  
    UNT Message Trailer  
  UNE Functional Group Trailer  
UNZ Interchange Control Trailer

Code:

        var edi = File.ReadAllText(path);
        EdiDataReader r = new EdiDataReader();
        EdiBatch b = r.FromString(edi.Trim());

        //Serialize the whole batch to JSON
        JsonDataWriter w1 = new JsonDataWriter();
        string json = w1.WriteToString(b);

        //OR Serialize selected EDI message to Json
        string jsonTrans = JsonConvert.SerializeObject(b.Interchanges[0].Groups[0].Transactions[0]);

        //Serialize the whole batch to XML
        XmlDataWriter w2 = new XmlDataWriter();
        string xml = w2.WriteToString(b);

Best regards!

olmelabs commented 2 years ago

Hi DennisEdiEngine doesn’t support EdiFact unfortunately. I don’t have maps and parser implemented. Only X12 is supported.Best regards,OlegOn 3 Nov 2022, at 12:06, Dennis Wetterlund @.***> wrote: Hi, Im fairly new to EDI and tries to convert an EDIFACT message to json or XML with EdiEngine, however the files I receives does not start with ISA (since it's EDIFACT and not X12 i think?). Is there a way to work around or fix this with EdiEngine? The structure in the files I receive looks like this (https://learn.microsoft.com/en-us/biztalk/core/edi-headers-and-trailers): UNA Service String Advice
UNB Interchange Control Header
UNG Functional Group Header
UNH Message Header
UNT Message Trailer
UNE Functional Group Trailer
UNZ Interchange Control Trailer

Code: var edi = File.ReadAllText(path); EdiDataReader r = new EdiDataReader(); EdiBatch b = r.FromString(edi.Trim());

    //Serialize the whole batch to JSON
    JsonDataWriter w1 = new JsonDataWriter();
    string json = w1.WriteToString(b);

    //OR Serialize selected EDI message to Json
    string jsonTrans = JsonConvert.SerializeObject(b.Interchanges[0].Groups[0].Transactions[0]);

    //Serialize the whole batch to XML
    XmlDataWriter w2 = new XmlDataWriter();
    string xml = w2.WriteToString(b);

Best regards!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

olmelabs commented 1 year ago

See above

olmelabs commented 1 year ago

^^