English 中文(简体)
EDIFACT macro (readable message structure)
原标题:

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

问题回答

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.

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

:s/([^?] )(.)/1
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 
...

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."




相关问题
Effective way of String splitting

I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++...

How do I parse EDIFACT in Java? [closed]

Parsing EDIFACT can be a daunting undertaking. How can I correctly create the syntactically and semantically correct tree from an EDIFACT file?

EDI File to pipe delimited flat file

I m looking for any helpful links or advice on translating an incoming EDI 940 (X12) to a (|) Pipe delimited flat file in c#.net

EDIEL library for Java/C#

This is a long-shot but does anyone know of a library in Java/C# for handling the EDIEL specification (this is the EDI spec with extensions for electricity, used by scandanavian countries and a few ...

Reading EDI Formatted Files

I m new to EDI, and I have a question. I have read that you can get most of what you need about an EDI format by looking at the last 3 characters of the ISA line. This is fine if every EDI used line ...

EDI Flat File parsing with C#?

Initially I was thinking to use SSIS to parse an EDI file, however I ve seen a few manual EDI parsers (field mapping), and would like to use automate this functionality in C#. Example EDI File:

EDIFACT macro (readable message structure)

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 ...

热门标签