Parsing EDIFACT messages with Frends
EDIFACT messages have a fairly simple structure, but they are not easy to read for humans because of delimited records (the field's position defines the meaning of the value), and extensive use of short identifiers and cryptic codes instead of self-explaining field names and code values.
β
Parsing the EDIFACT message does not translate all the identifiers or codes, but it converts the message structure to a clear tree structure which makes it much easier to read and process the message.
Edifact ConvertToJson
For parsing the EDIFACT messages we use the Edifact ConvertToJson Task which converts the message structure to a JSON tree structure.
The Task only has one Input field: Input edifact. This is used to provide the input Edifact message for the Task.
Example:
β
Currently, the ConvertToJson Task returns the EDIFACT message as a JSON string and you need to parse the string to a JToken tree for easier processing. In the future, the ConvertToJson Task will most likely directly return the message as a JToken tree.
β
The JSON string to JToken tree conversion can be done either with a ConvertJsonStringtoJToken Task or with the JToken.Parse() C# Expression like in this picture:
Now the EDIFACT message is a JToken tree, which makes it much easier to see the message structure compared to reading the structure from the original EDIFACT message. The message segments like UNH (message header) and DTM (date/time/period) have their short cryptic names, but the segment field names are quite self-explanatory. For example, the IMD (Item description) segment's item description can be found in the field "Itemdescription_04":
β
It is best to check the exact meaning of EDIFACT fields and codes from the EDIFACT message description. See the example EDIFACT purchase order (ORDERS) message's message structure description on the Stylus Studio EDIFACT pages.
The next article is Example on Mapping from EDIFACT JToken tree