Monday, May 08, 2017

Logic Apps and EDI (IV)

This post continues the Logic Apps and EDI series of post, that I began weeks ago:

In this post I go to explain how get the "Good" and the "Bad" decoded messages from EDIFACT Decode Component.

According to the documentation, in our Agreement, we can configure how to manage the decoded EDIFACT message:

  • Split Interchange as transaction sets - suspend transaction sets on error: Parses each transaction set in an interchange into a separate XML document. If one or more transaction sets in the interchange fail validation, then EDIFACT Decode suspends only those transaction sets.
  • Split Interchange as transaction sets - suspend interchange on error: Parses each transaction set in an interchange into a separate XML document. If one or more transaction sets in the interchange fail validation, then EDIFACT Decode suspends the entire interchange.
  • Preserve Interchange - suspend transaction sets on error: Creates an XML document for the entire batched interchange. EDIFACT Decode suspends only those transaction sets that fail validation, while continuing to process all other transaction sets
  • Preserve Interchange - suspend interchange on error: Creates an XML document for the entire batched interchange. If one or more transaction sets in the interchange fail validation, then EDIFACT Decode suspends the entire interchange

In my previous post, I configured the Agreement, but I didn't modify the default behaviour:


The Decode EDIFACT Message component result "Good" messages are the equivalent XML messages extracted from the input EDIFACT flat file for each transaction set, according to my current configuration (Parses each transaction set in an interchange into a separate XML document). 


If we need that messages, after the Decode EDIFACT message component:
  1. Add a For Each step
  2. In Select an output from previous, select GoodMessages from Decode_EDIFACT_message step or in json code, insert "@body('Decode_EDIFACT_message')?['GoodMessages']"
Now with each "Good" message, you can do what you want. In my case, I go to send an email to me with each "Good" message in equivalent XML format. Inside For Each step I added a Send an email step with these properties:
  • Subject: "Good Messages"
  • To: FMondelo@kabel.es
  • Body: "@{base64ToString(item()?['Payload'])}"
I used base64ToString Logic App's function to get the string value of the decoded message.
The item() is each "Good" message. In For Each step, each item inside Select an output from previous have to be accesed by item keyword.

Payload is the property of each "Good" message, with the transformed EDIFACT message in XML format encoded in Base64.


If I run this Logic App, I will receive each transaction set on my email, something like this:



But If I modify my Agreement settings, using the option Preserve Interchange - suspend interchange on error (Creates an XML document for the entire batched interchange. If one or more transaction sets in the interchange fail validation, then EDIFACT Decode suspends the entire interchange), I will only receive one email with the entire interchange, something like this:


To be continued ...

No comments: