Example of how to parse a document that contains multiple EDI document types

Post author
Geovani Martinez

Any update on this previously created github post https://github.com/EdiFabric/Sdk/issues/1 .Thank you for your time.

Comments

3 comments

  • Comment author
    Admin
    • Edited

    I also added the snippet below to the GitHub issue:

    using (var ediReader = new EdifactReader(ediStream, LoadFactory))
    {
    while(ediReader.Read())
    {
    var deljit = ediReader.Item as TSDELJIT;
    if (deljit != null)
    ProcessDeljit(ediReader.CurrentInterchangeHeader, ediReader.CurrentGroupHeader, deljit);

    var delfor = ediReader.Item as TSDELFOR;
    if (delfor != null)
    ProcessDelfor(ediReader.CurrentInterchangeHeader, ediReader.CurrentGroupHeader, delfor);
    }
    }

    public TypeInfo LoadFactory(UNB unb, UNG ung, UNH unh)
    {
    if (unh.MessageIdentifier_02.MessageType_01 == "DELJIT")
    return typeof(TSDELJIT).GetTypeInfo();

    if (unh.MessageIdentifier_02.MessageType_01 == "DELFOR")
    return typeof(TSDELFOR).GetTypeInfo();

    throw new Exception(string.Format("Unsupported transaction {0}" +
    unh.MessageIdentifier_02.MessageType_01));
    }

    public void ProcessDeljit(UNB unb, UNG ung, TSINVOIC deljit)
    {
    }

    public void ProcessDelfor(UNB unb, UNG ung, TSINVOIC delfor)
    {
    }
    0
  • Comment author
    Geovani Martinez
    • Edited

    Hello,

    I'm sorry for some reason I did not get the ticket reply notifications. Your code snippet was exactly what I was looking for. Thanks. I do have one more question. I have an edifact - deljit document when we read the document we get a null UNG object. When I inspect the document (EDI NOTEPAD) in XML view I can see the UNG group. What could I be doing wrong that the ediReader is not extracting the UNG (CurrentGroupHeader)? Any guidance is greatly appreciated.



    0
  • Comment author
    Admin

    CurrentGroupHeader is populated after a UNG segment is read and is cleared after interchange header\trailer or group trailer is read.

    Can't comment on other products.

     

    0

Please sign in to leave a comment.