EDI文件可以在数据中具有〜吗?
我正在解析EDI文件,然后分配〜S。我想知道EDI是否可以在数据本身中拥有〜?是否有一个规则在数据中说不?这是针对810/850等
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我正在解析EDI文件,然后分配〜S。我想知道EDI是否可以在数据本身中拥有〜?是否有一个规则在数据中说不?这是针对810/850等
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
ISA段的第106个字符中定义的值(或者,或者,对于空格问题的脆弱 -
isa16
元素之后的第一个字符)是段定界符(用官方术语:段终结者
)。大多数时候,人们指定〜
字符,但其他选择肯定是有效的。在此示例中,第106个字符是
〜
:isa*00*00*00**zz*amazonds*01*testID*070808*1310*u*00401*000000043*1*t*t*t*t* +〜
而不是计数106个字符(同样,这可能是脆弱的问题),您可以计算16 elements - 也就是说16个星号 - 找到
isa16 (
+
),然后选择下一个字符(〜
)。官方X12规范中有两个相关部分(强调强调):
因此,根据规格的这一部分,如果将
〜
用作段终结者,则在数据元素中不允许使用〜
文字主体)。现在,让我们看一下第12.5.A.5节 - 针对分界符的建议:
本节说,
〜
被选择为默认值,因为很少在文本数据中找到〜
(例如,使用>,这是一个坏主意。 。
也就是说,即使在技术上禁止使用片段终止器,EDI传输仍然是可能的可能的,以无意中的方式将
〜
在文本数据中包括可能是偶然的。此外,bin
和bsd
(二进制数据)段肯定可以包括〜
(尽管这些可能无法基于您的事务集应用与之合作)。在我们的解析API ,我们根据基于类型的类型应用了一组特定模式我们遇到的细分市场。对我们来说,仅基于细分定界符天真地拆分不足包含在文本数据中。
对于常规段(即
bin
或bsd
),逻辑就是这样:例如,对于段
beg*po-00001 ** 20210901〜
,该过程看起来像:beg
。由于这不是一个特殊的段(bin
或bsd
),请通过在*
上拆分来消耗元素。PO-00001
。''
。20210901
。〜
。(The pattern for binary segments is different from the pattern we use for regular segments.)
~
in the textual data when theISA16
段定界符也是〜
; the JSON代表对查看该问题特别有用。isa16
段定界符是^
时,我们在文本数据中成功使用〜
成功的解析器的示例。~
is specified inISA16< /code>,但已被省略了以支持新线 - 我们偶尔会看到。
希望这会有所帮助。
The value defined in the 106th character of the ISA segment (or, alternatively – to be a bit less brittle to whitespace issues – the 1st character after the
ISA16
element) is the segment delimiter (in official terms: thesegment terminator
). Most of the time people specify the~
character, but other choices are certainly valid.In this example, the 106th character is
~
:ISA*00* *00* *ZZ*AMAZONDS *01*TESTID *070808*1310*U*00401*000000043*1*T*+~
Instead of counting 106 characters (which, again, can be brittle to whitespace issues), you can count 16 elements – that is, 16 asterisks – to find the value for
ISA16
(which is+
), and then pick the next character (which is~
).There are two relevant sections in the official X12 specification (bolded for emphasis):
So, according to this part of the spec, if the
~
is used as the segment terminator, then the use of the~
is disallowed in a data element (that is, the textual body).Now, let's look at section 12.5.A.5 – Recommendations for the Delimiters:
This section is saying that
~
was chosen as the default because~
is seldom found in textual data (it would have been a bad idea, for example, to use.
as the default, since that's such a common inclusion).That said, even though using the segment terminator is technically prohibited, it's still possible for an EDI transmission to inadvertently include
~
in the textual data – in other words, your trading partner may include this by accident. Further, theBIN
andBSD
(binary data) segments can certainly include~
(though these may not apply based on the transaction sets you're working with).In our parsing API, we apply a set of specific set of patterns based on the type of segment we encounter. For us, it's not sufficient to split naively based on the segment delimiter alone because we may encounter binary segments (
BIN
,BSD
), where it's possible that the segment delimiter character is included in the textual data.For a regular segment (i.e. not
BIN
orBSD
), the logic is something like this:As an example, for segment
BEG*PO-00001**20210901~
, the process would look like:BEG
. Since this is not a special segment (BIN
orBSD
), consume elements by splitting on*
.PO-00001
.''
.20210901
.~
.(The pattern for binary segments is different from the pattern we use for regular segments.)
~
in the textual data when theISA16
segment delimiter is also~
; the JSON representation is particularly helpful for seeing the issue.~
in the textual data when theISA16
segment delimiter is^
.~
is specified inISA16
, but has been omitted altogether in favor of newlines – which we see occasionally.Hope this helps.