Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stupidedi::Exceptions::ParseError: required segment SE is missing from table Table 3 - Summary #107

Open
n4a4 opened this issue Feb 25, 2017 · 2 comments

Comments

@n4a4
Copy link

n4a4 commented Feb 25, 2017

I have a block of code that is writing a purchase order (850). I call builder::CTT to try to write the count of the orders but when the line of code is included, I always get the following error:

Stupidedi::Exceptions::ParseError: required segment SE is missing from table Table 3 - Summary

However, when I remove the CTT line it always works. Am I using this in an incorrect way?

def self.order_edi(output_stream, headers, orders)
  config = Stupidedi::Config.contrib
  b = Stupidedi::Builder::BuilderDsl.build(config)

  isa = headers[:isa]
  gs = headers[:gs]
  st = headers[:st]
  beg = headers[:beg]
  n1 = headers[:n1]

  b.ISA isa[:authorization_information_qualifier],
        isa[:authorization_information],
        isa[:security_information_qualifier],
        isa[:security_information],
        isa[:interchange_id_qualifier],
        isa[:interchange_sender_id],
        isa[:interchange_id_qualifier],
        isa[:interchange_receiver_id],
        isa[:interchange_date],
        isa[:interchange_time],
        isa[:interchange_control_standards_identifier],
        isa[:interchange_control_version_number],
        isa[:interchange_control_number],
        isa[:acknowledgment_requested],
        isa[:interchange_usage_indicator],
        isa[:component_element_separator]

  b.GS gs[:functional_id],
       gs[:application_senders_code],
       gs[:application_receivers_code],
       gs[:date],
       gs[:time],
       gs[:group_control_number],
       gs[:responsible_agency_code],
       gs[:version]

  b.ST st[:transaction_set_id],
       st[:transaction_set_control_number]

  b.BEG beg[:transaction_set_purpose_code],
        beg[:purchase_order_type_code],
        beg[:purchase_order_number],
        beg[:release_number],
        beg[:purchase_order_date]

  b.N1 n1[:entity_identifier_code],
       n1[:name],
       n1[:identification_code_qualifier],
       n1[:identification_code]

  orders.each do |order|
    b.PO1 order[:assigned_identification],
          order[:quantity_ordered],
          order[:unit_or_basis_for_measurement_code],
          order[:unit_price],
          order[:basis_of_unit_price_code],
          order[:product_id_qualifier],
          order[:product_id]
  end

  # having this line would run into the parser exception
  b.CTT orders.size

  number_of_included_segments = 5 + orders.size
  b.SE number_of_included_segments,
       st[:transaction_set_control_number]



  b.GE 1,
       gs[:group_control_number]

  b.IEA 1,
        isa[:interchange_control_number]

  output = b.machine.zipper.tap do |z|
    separators = Stupidedi::Reader::Separators.build segment: "~\n",
      element: '*',
      component: isa[:component_element_separator],
      repetition: '^'

    w = Stupidedi::Writer::Default.new(z.root, separators)
    w.write($stdout)
  end

  p output
end
@kputnam
Copy link
Owner

kputnam commented Mar 2, 2017

This might be a bug in stupidedi. Can you change your example to include literal values (rather than references to hash values) that I can paste to help me debug? Let me know if you need a quick workaround in the meantime, but I do want to figure this out and hopefully fix it.

@outsmartin
Copy link

outsmartin commented Mar 31, 2017

Having the same issue here.
Changing CTT in the transaction_set_defs to Mandatory fixes the parse error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants