Code Monkey home page Code Monkey logo

Comments (10)

irobayna avatar irobayna commented on May 16, 2024

I can get around this issue by passing strict = false

builder = Stupidedi::Builder::BuilderDsl.build(config, false)

Now I get:

Stupidedi::Exceptions::OutputError - separators  occur as data:

from stupidedi.

kputnam avatar kputnam commented on May 16, 2024

This and a few other ISA elements are handled as a special case. Try putting a blank (nil or "") value in that element and then look at the output when you serialize it using .to_x12 -- it should be converted to 10 spaces automatically.

-- Kyle

On Aug 3, 2014, at 7:27 AM, Isi Robayna [email protected] wrote:

I have the have the following definition data element summary definition:

M ISA02 I02 Authorization Information M AN 10/10
Key Point:
Must be 10 spaces
it is a mandatory field but must contain 10 spaces. Any way to work around this?

I am trying to build the output file using:

config = Stupidedi::Config.contrib
builder = Stupidedi::Builder::BuilderDsl.build(config)

builder.ISA "00", "          ", "00", "          ",
  "01", "005548384",
  "01", "126444801",
  "990531", "1230", "U", "00200", "63373", "0", "P", ":"

β€”
Reply to this email directly or view it on GitHub.

from stupidedi.

irobayna avatar irobayna commented on May 16, 2024

When using a blank (nil or "") I get original error, required element ISA02 is blank

To get around ti have to use strict: false

Note: if you change the interchange version you will see the error message

builder.ISA("00", "",             # authorization information
      "00", "",             # authentication information
      "ZZ", "SUBMITTER ID", # submitter identification
      "ZZ", "RECEIVER ID",  # recipient identification
      Time.now.utc,         # date
      Time.now.utc,         # time
      "^",                  # repetition separator
      "00200",              # interchange version
      "333666999",          # control number
      "1",                  # acknowledgement request
      "T",                  # usage indicator
      ":")        

from stupidedi.

kputnam avatar kputnam commented on May 16, 2024

Oh right, I see. I think this was handled in version 5010 by declaring that element Optional (and probably ISA04 too), but then the ElementDef is a special case of AN that formats itself as 10 spaces when it’s β€œblank” instead of an empty string. So I’d recommend changing your ISA to make that element optional, and use SpecialAN as the element type.

https://github.com/kputnam/stupidedi/blob/master/lib/stupidedi/versions/interchanges/00501/segment_defs/ISA.rb#L14

https://github.com/kputnam/stupidedi/blob/master/lib/stupidedi/versions/interchanges/00501/element_defs.rb#L19

β€” Kyle

On Aug 3, 2014, at 11:36 AM, Isi Robayna [email protected] wrote:

When using a blank (nil or "") I get original error, required element ISA02 is blank

To get around ti have to use strict: false

Note: if you change the interchange version you will see the error message

builder.ISA("00", "", # authorization information
"00", "", # authentication information
"ZZ", "SUBMITTER ID", # submitter identification
"ZZ", "RECEIVER ID", # recipient identification
Time.now.utc, # date
Time.now.utc, # time
"^", # repetition separator
"00200", # interchange version
"333666999", # control number
"1", # acknowledgement request
"T", # usage indicator
":")
β€”
Reply to this email directly or view it on GitHub.

from stupidedi.

irobayna avatar irobayna commented on May 16, 2024

thank you!

sure thing... I will

Any thoughts on as to why this happens?

Stupidedi::Exceptions::OutputError - separators  occur as data:

from stupidedi.

kputnam avatar kputnam commented on May 16, 2024

I'm not entirely sure, but I think we ought to put quotes around each separator in the error message. I suspect the separator it's complaining about is some kind of whitespace.

Before generating output the Writer looks at the Separators you want to use (either passed as an argument or there may be a default). If any of those characters occur as data in the parse tree, it will throw that error because it may be unclear if an occurrence of that character is indicates data or a delimiter.

Try explicitly constructing Separators and passing them to the writer, and maybe change the exception message to put some kind of quotes around each separator after "separators occur as data: " so you can see what they were. For instance, you would see "separators occur as data: 'a', 'b'" if you declared "a" and "b" as segment and element separators, but those characters showed up as data somewhere.

from stupidedi.

irobayna avatar irobayna commented on May 16, 2024

I think I am using a proper separators per the documentation

builder.ISA("00", "11",             # authorization information
      "00", "11",             # authentication information
      "ZZ", "SUBMITTER ID", # submitter identification
      "ZZ", "RECEIVER ID",  # recipient identification
      Time.now.utc,         # date
      Time.now.utc,         # time
      "U",                  # repetition separator
      "00200",              # interchange version
      "333666999",          # control number
      "1",                  # acknowledgement request
      "T",                  # usage indicator
      ":")                  # component separator

    builder.GS "PO", "009348384", "126564801", "19990531", "1230", "1", "X", "002001"

    builder.ST "830", "8573"

    builder.BFR "04", nil, "140801", "DL", "A", "XX14-08-01", "XX14-08-01", "XX14-08-01",
                nil, "CP"

    builder.machine.zipper.tap do |z|
      separators =
        Stupidedi::Reader::Separators.build :segment    => "~\n",
                                            :element    => "*",
                                            :component  => ":",
                                            :repetition => "^"

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

  end

from stupidedi.

kputnam avatar kputnam commented on May 16, 2024

Looks like present? is returning true on an empty set -- the set of data characters that are also used as delimiters. This may be a regression caused by recent changes to present? or just a bad interaction with the set library Cantor. Should have a fix momentarily.

from stupidedi.

kputnam avatar kputnam commented on May 16, 2024

Here's what is going on

>> s = Cantor.absolute([])
=> AbsoluteSet()

>> s.empty?
=> true

>> s.present?
=> true # huh?

from stupidedi.

irobayna avatar irobayna commented on May 16, 2024

πŸ‘ Thank you!

from stupidedi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.