Stupidedi Either.failure(“段ST~未发生”)
我正在使用 Ruby 库 STUPIDEDI 来解析一些 X12 文件。我没有超越标题中的这个错误。请帮助我
代码
input = if RUBY_VERSION > "1.8"
File.open(Rails.root.join('spec','fixtures','22.txt'), :encoding => "ISO-8859-1")
else
File.open(Rails.root.join('spec','fixtures','22.txt'))
end
p input
config = Stupidedi::Config.hipaa
parser = Stupidedi::Parser.build(config)
parser, result = parser.read(Stupidedi::Reader.build(input))
if result.fatal?
result.explain{|reason| raise reason + " at #{result.position.inspect}" }
end
x = parser.first
.flatmap{|m| m.find(:GS) }
.flatmap{|m| m.find(:ST) }
.tap do |m|
el(m.find(:N1, "PR"), 2){|e| puts "Payer: #{e}" }
el(m.find(:N1, "PE"), 2){|e| puts "Payee: #{e}" }
end
p x
input.close
文件
ISA*00* *00* *ZZ*CHEESE *12*VENDOR ISA*160321*1828*U*00400*000004970*0*T*>~
GS*PS*CHEESE*2018584966*20160321*1828*4970*X*004010~
ST*830*0001~
BFR*00*Forecast ID**DL*A*20131229*20140323*20140104****MN~
REF*IA*Vendor Code~
N1*DU*CHEESE US*15*1526642~
N1*VN*Vendor Name*92*123456789~
LIN*1*UP*123456789123456*B123456789~
UIT*EA~
FST*0*D*W*20131229~
FST*0*D*W*20140105~
FST*0*D*W*20140112~
FST*0*D*W*20140119~
FST*0*D*W*20140126~
FST*0*D*W*20140202~
FST*0*D*W*20140209~
FST*0*D*W*20140216~
FST*0*D*W*20140223~
FST*0*D*W*20140302~
FST*0*D*W*20140309~
FST*0*D*W*20140316~
FST*0*D*W*20140323~
SE*21*0001~
GE*1*4970~
IEA*1*000004970~
请帮助我如何解决这个问题。我真的需要你的帮助!我是 EDI 新手
I'm using Ruby library STUPIDEDI to parse some X12 Files. I am not getting beyond this error in the title. Please help me
Code
input = if RUBY_VERSION > "1.8"
File.open(Rails.root.join('spec','fixtures','22.txt'), :encoding => "ISO-8859-1")
else
File.open(Rails.root.join('spec','fixtures','22.txt'))
end
p input
config = Stupidedi::Config.hipaa
parser = Stupidedi::Parser.build(config)
parser, result = parser.read(Stupidedi::Reader.build(input))
if result.fatal?
result.explain{|reason| raise reason + " at #{result.position.inspect}" }
end
x = parser.first
.flatmap{|m| m.find(:GS) }
.flatmap{|m| m.find(:ST) }
.tap do |m|
el(m.find(:N1, "PR"), 2){|e| puts "Payer: #{e}" }
el(m.find(:N1, "PE"), 2){|e| puts "Payee: #{e}" }
end
p x
input.close
File
ISA*00* *00* *ZZ*CHEESE *12*VENDOR ISA*160321*1828*U*00400*000004970*0*T*>~
GS*PS*CHEESE*2018584966*20160321*1828*4970*X*004010~
ST*830*0001~
BFR*00*Forecast ID**DL*A*20131229*20140323*20140104****MN~
REF*IA*Vendor Code~
N1*DU*CHEESE US*15*1526642~
N1*VN*Vendor Name*92*123456789~
LIN*1*UP*123456789123456*B123456789~
UIT*EA~
FST*0*D*W*20131229~
FST*0*D*W*20140105~
FST*0*D*W*20140112~
FST*0*D*W*20140119~
FST*0*D*W*20140126~
FST*0*D*W*20140202~
FST*0*D*W*20140209~
FST*0*D*W*20140216~
FST*0*D*W*20140223~
FST*0*D*W*20140302~
FST*0*D*W*20140309~
FST*0*D*W*20140316~
FST*0*D*W*20140323~
SE*21*0001~
GE*1*4970~
IEA*1*000004970~
Please help me how to solve this. I really need your help! I am new to EDI
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这解决了问题:
Stupidedi::Config.contrib(Stupidedi::Config.hipaa(Stupidedi::Config.default))
对于任何会使用的人,stupidedi!
Turns out this solved the problem:
Stupidedi::Config.contrib(Stupidedi::Config.hipaa(Stupidedi::Config.default))
For anyone who would use, stupidedi!