Validation of service segments

Post author
Robin Reiß

Hello,

i'm wondering if EdiFabric can validate service segments like UNB, UNG, etc.?

Best regards,

Robin Reiß

Comments

3 comments

  • Comment author
    Admin

    Yes, it can, two approaches:

    1. Use AckMan to generate CONTRL which will validate all control segments together with all transactions.

    2. As shown in the SDK, line 332:

    using (var ediReader = new EdifactReader(ediStream, TemplateFactory.FullTemplateFactory))
    {
    while(ediReader.Read())
    {
    var unb = ediReader.Item as UNB;
    if(unb != null)
    {
    // Validate
    var unbErrors = unb.Validate();
    // Pull the sender id from UNB
    var senderId = unb.INTERCHANGESENDER_2.InterchangeSenderIdentification_1;
    Debug.WriteLine("Sender ID:");
    Debug.WriteLine(senderId);
    }

    var ung = ediReader.Item as UNG;
    if (ung != null)
    {
    // Validate
    var ungErrors = ung.Validate();
    // Pull the sender id from UNG
    var senderId = ung.APPLICATIONSENDERIDENTIFICATION_2.ApplicationSenderIdentification_1;
    Debug.WriteLine("Sender ID:");
    Debug.WriteLine(senderId);
    }
    }
    }
    1
  • Comment author
    Robin Reiß

    Thanks for the quick reply.

    Is there a way I can validate UNA segments, too?

    0
  • Comment author
    Admin

    No there isn't.

    When reading EDIFACT, the parser will not read the message if UNA wasn't valid, so it implicitly validates it.

    When writing you can use Separators.ToUNA() to generate UNA out of any separator set. You can also use GenerateSegment() from the UNA class to generate an UNA. Also when writing with a separator set different than the default, the EdifactWriter automatically inserts a UNA segment. 

     

     

     

    0

Please sign in to leave a comment.