EDIFACT宏(可读消息结构)

发布于 2024-08-14 03:08:21 字数 236 浏览 4 评论 0原文

我在 EDI 领域工作,希望获得有关 EDIFACT 宏的帮助,以使 EDIFACT 文件更具可读性。

该消息如下所示:

data'data'data'data'

我想让宏将结构转换为:

data'
data'
data'
data'

请让我知道如何执行此操作。 提前致谢!

BR 乔纳斯

I´m working within the EDI area and would like some help with a EDIFACT macro to make the EDIFACT files more readable.

The message looks like this:

data'data'data'data'

I would like to have the macro converting the structure to:

data'
data'
data'
data'

Pls let me know how to do this.
Thanks in advance!

BR
Jonas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半山落雨半山空 2024-08-21 03:08:21

如果您只想以更易读的格式查看文件,请尝试下载 Softshare EDI 记事本。它是一个相当不错的工具,专门用于此目的,它支持 X12、EDIFACT 和 TRADACOMS 标准,而且是免费的。

If you merely want to view the files in a more readable format, try downloading the Softshare EDI Notepad. It's a fairly good tool just for that purpose, it supports X12, EDIFACT and TRADACOMS standards, and it's free.

辞取 2024-08-21 03:08:21

在 VIM 中替换(假设正在使用 UNOA 字符集的标准 EDIFACT 分隔符/转义字符):

:s/\([^?]'\)\(.\)/\1\r\2/g

分解正则表达式:
\([^?]'\) - 搜索出现在除 ?(标准转义字符)之外的任何字符之后的 ' 并捕获这些两个字符作为第一个原子。这是每个段的最后两个字符。
\(.\) - 捕获段终止符后面的任何单个字符(即,如果段终止符已经位于行末尾,则不匹配)

然后用段终止符和下一个段的开头之间的新行。

否则你可能会得到这样的结果:

...
FTX+AAR+++FORWARDING?: Freight under Vendor?'
s care.'
NAD+BY+9312345123452'
CTA+PD+0001:Terence Trent D?'
Arby'
...

而不是这样:

...
FTX+AAR+++FORWARDING?: Freight under Vendor?'s care .'
NAD+BY+9312345123452'
CTA+PD+0001:Terence Trent D?'Arby'
...

Replacing in VIM (assuming that the standard EDIFACT separators/escape characters for UNOA character set are in use):

:s/\([^?]'\)\(.\)/\1\r\2/g

Breaking down the regex:
\([^?]'\) - search for ' which occurs after any character except ? (the standard escape character) and capture these two characters as the first atom. These are the last two characters of each segment.
\(.\) - Capture any single character following the segment terminator (ie. don't match if the segment terminator is already on the end of a line)

Then replace all matches on this line with a new line between the segment terminator and the beginning of the next segment.

Otherwise you could end up with this:

...
FTX+AAR+++FORWARDING?: Freight under Vendor?'
s care.'
NAD+BY+9312345123452'
CTA+PD+0001:Terence Trent D?'
Arby'
...

instead of this:

...
FTX+AAR+++FORWARDING?: Freight under Vendor?'s care .'
NAD+BY+9312345123452'
CTA+PD+0001:Terence Trent D?'Arby'
...
私野 2024-08-21 03:08:21

这是您要找的吗?

Option Explicit

Dim stmOutput: Set stmOutput = CreateObject("ADODB.Stream")
stmOutput.Open
stmOutput.Type = 2 'adTypeText
stmOutput.Charset = "us-ascii"

Dim stm: Set stm = CreateObject("ADODB.Stream")
stm.Type = 1 'adTypeBinary
stm.Open
stm.LoadFromFile "EDIFACT.txt"

stm.Position = 0
stm.Type = 2 'adTypeText
stm.Charset = "us-ascii"

Dim c: c = ""
Do Until stm.EOS
  c = stm.ReadText(1)
  Select Case c
    Case Chr(39)
      stmOutput.WriteText c & vbCrLf
    Case Else
      stmOutput.WriteText c
  End Select
Loop


stm.Close
Set stm = Nothing

stmOutput.SaveToFile "EDIFACT.with-CRLF.txt"
stmOutput.Close
Set stmOutput = Nothing

WScript.Echo "Done."

Is this what you are looking for?

Option Explicit

Dim stmOutput: Set stmOutput = CreateObject("ADODB.Stream")
stmOutput.Open
stmOutput.Type = 2 'adTypeText
stmOutput.Charset = "us-ascii"

Dim stm: Set stm = CreateObject("ADODB.Stream")
stm.Type = 1 'adTypeBinary
stm.Open
stm.LoadFromFile "EDIFACT.txt"

stm.Position = 0
stm.Type = 2 'adTypeText
stm.Charset = "us-ascii"

Dim c: c = ""
Do Until stm.EOS
  c = stm.ReadText(1)
  Select Case c
    Case Chr(39)
      stmOutput.WriteText c & vbCrLf
    Case Else
      stmOutput.WriteText c
  End Select
Loop


stm.Close
Set stm = Nothing

stmOutput.SaveToFile "EDIFACT.with-CRLF.txt"
stmOutput.Close
Set stmOutput = Nothing

WScript.Echo "Done."
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文