Class EDI::E::Message
In: lib/edi4r/edifact.rb
Parent: EDI::Message

Class EDI::E::Message

This class implements a single business document according to UN/EDIFACT

Methods

add   new   new_segment   parse   to_s   validate  

Public Class methods

Creates an empty UN/EDIFACT message Don‘t use directly - use new_message of class Interchange or MsgGroup instead!

First parameter

This is always the parent object, either a message group or an interchange object. Use method new_message in the corresponding object instead of creating messages unattended, and the parent reference will be accounted for automatically.

Second parameter, case "Hash"

List of supported hash keys:

Essentials, should not be changed later

:msg_type :Sets S009.0065, default = ‘ORDERS‘
:version :Sets S009.0052, default = ‘D’
:release :Sets S009.0054, default = ‘96A’
:resp_agency :Sets S009.0051, default = ‘UN‘

Optional parameters, required depending upon use case

:assigned_code :Sets S009.0057 (subset), default = nil

Second parameter, case "Segment"

This mode is only used internally when parsing data.

Notes

  • The counter in UNH (0062) is set automatically to a number that is unique for the running process.
  • The trailer segment (usually UNT) is generated automatically.
  • Whenever possible, avoid write access to the message header or trailer segments!

Returns a new Message object that contains the data of the strings passed in the segment_list array. Uses the context of the given parent object and configures message as a child.

Public Instance methods

Add a previously derived segment to the end of this message (append) Make sure that all mandatory elements have been supplied.

Notes

  • Strictly add segments in the sequence described by this message’s branching diagram!
  • Adding a segment will automatically increase the corresponding counter in the message trailer.

Example:

   seg = msg.new_segment( 'BGM' )
   seg.d1004 = '220'
   # etc.
   msg.add seg

Derive a new segment with the given name from this message context. The call will fail if the message name is unknown to this message’s UN/TDID (not in EDMD/IDMD).

Example:

   seg = msg.new_segment( 'BGM' )
   seg.d1004 = '220'
   # etc.
   msg.add seg

[Validate]