tag = 'UNB' Eancom.register_segment(tag: tag, klass: Eancom::Edifact::UNB) structure = Eancom::Edifact::Structure.new(tag: tag) #============================================================================== # Tag # #============================================================================== tag = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 3, dictionary: nil, description: "Interchange Header", required: true ) tag.add(:tag, data) structure << tag #============================================================================== # Syntax identifier # #============================================================================== syntax_identifier = Eancom::Edifact::Composite.new() syntax_dictionary = { 'UNOA' => { description: 'UN/ECE level A' }, 'UNOB' => { description: 'UN/ECE level B' }, 'UNOC' => { description: 'UN/ECE level C' }, 'UNOD' => { description: 'UN/ECE level D' }, 'UNOE' => { description: 'UN/ECE level E' }, 'UNOF' => { description: 'UN/ECE level F' }, } data = Eancom::Edifact::Data.new( type: String, length: 4, dictionary: syntax_dictionary, description: "Syntax identifier.", required: true ) syntax_identifier.add(:syntax_identifier, data) syntax_version_dict = { '2' => { description: 'Version 2' }, '3' => { description: 'Version 3' } } data = Eancom::Edifact::Data.new( type: String, length: 1, dictionary: syntax_version_dict, description: "Syntax version number.", required: true ) syntax_identifier.add(:syntax_version_number, data) structure << syntax_identifier #============================================================================== # Interchange Sender # #============================================================================== interchange_sender = Eancom::Edifact::Composite.new() data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: "Interchange sender identification (GLN).", required: true ) interchange_sender.add(:interchange_sender_identification, data) data = Eancom::Edifact::Data.new( type: String, length: 1..4, dictionary: nil, description: "Identification code qualifier (14 = GS1).", required: true ) interchange_sender.add(:sender_identifiction_code_qualifier, data) data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: "Interchange sender internal identification.", required: false ) interchange_sender.add(:interchange_sender_internal_identification, data) structure << interchange_sender #============================================================================== # Interchange Recipient # #============================================================================== interchange_recipient = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: "Interchange recipient identification (GLN).", required: true ) interchange_recipient.add(:interchange_recipient_identification, data) data = Eancom::Edifact::Data.new( type: String, length: 1..4, dictionary: nil, description: "Identification code qualifier (14 = GS1).", required: true ) interchange_recipient.add(:recipient_identifiction_code_qualifier, data) data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil, description: "Interchange sender internal identification", required: false ) interchange_recipient.add(:interchange_recipient_internal_identification, data) structure << interchange_recipient #============================================================================== # Date and Time of Preparation # #============================================================================== date_and_time_of_preparation = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 6..8, dictionary: nil, description: "Date (YYMMDD)", required: true ) date_and_time_of_preparation.add(:date, data) data = Eancom::Edifact::Data.new( type: String, length: 4, dictionary: nil, description: "Time (HHMM)", required: true ) date_and_time_of_preparation.add(:time, data) structure << date_and_time_of_preparation #============================================================================== # Interchange control reference # #============================================================================== interchange_control_reference = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..14, dictionary: nil, description: "Interchange control reference.", required: true ) interchange_control_reference.add(:interchange_control_reference, data) structure << interchange_control_reference #============================================================================== # Recipient Reference / Password Details # #============================================================================== recipient_reference = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..14, dictionary: nil, description: "Recipient reference/password.", required: true ) recipient_reference.add(:recipient_reference, data) data = Eancom::Edifact::Data.new( type: String, length: 2, dictionary: nil, description: "Recipient reference/password qualifier.", required: false ) recipient_reference.add(:recipient_reference_qualifier, data) structure << recipient_reference #============================================================================== # Application Reference # #============================================================================== application_reference = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..14, dictionary: nil, description: "Application reference.", required: false ) application_reference.add(:application_reference, data) structure << application_reference #============================================================================== # Processing priority code # #============================================================================== processing_priority_code = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1, dictionary: { 'A' => { description: 'A = Highest priority' }}, description: "Processing priority code.", required: false ) processing_priority_code.add(:processing_priority_code, data) structure << processing_priority_code #============================================================================== # Acknowledgement request # #============================================================================== acknowledgement_request = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1, dictionary: { '1' => { description: '1 = Requested' }}, description: "Acknowledgement request.", required: false ) acknowledgement_request.add(:acknowledgement_request, data) structure << acknowledgement_request #============================================================================== # Interchange Agreement Identifier # #============================================================================== interchange_agreement_identifier = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: nil , description: "Interchange agreement identifier.", required: false ) interchange_agreement_identifier.add(:interchange_agreement_identifier, data) structure << interchange_agreement_identifier #============================================================================== # Test Indicator # #============================================================================== test_indicator = Eancom::Edifact::Composite.new data = Eancom::Edifact::Data.new( type: String, length: 1..35, dictionary: { '0' => { description: '0 = interchange is not a test'}, '1' => { description: '1 = interchange is a test'} }, description: "Test indicator.", required: false ) test_indicator.add(:test_indicator, data) structure << test_indicator #============================================================================== Eancom.register_structure(tag: 'UNB', structure: structure)