We're trying to build a new EDI solution where we utilize the various action available via Logic Apps and integration account in Azure.
We have successfully got the decode part working with various EDIFACT types, profiles and agreements. However, when creating/encoding an EDIFACT message we have run into trouble.
It seems the encode action (both Encode_to_edifact_message_by_identifies and Encode_to_edifact_message_by_agreement_name_v2) require the UNA or UNB segment to be a part of the input data.
Error message when trying to encode
{
"errorMessage": "Edifact interchange should have contained UNA or UNB as the first segment. Instead TransactionSetGroup was found",
"statusCode": "BadRequest",
"ReceiverIdentifier": "96",
"receiverQualifier": "ZZ",
"SenderIdentifier": "99",
"senderQualifier": "ZZ"
}
However, this sounds strange cause this is configured in the agreement under Send Settings.
The "framingSettings" element in the agreement contain all the UNA informarmation as well as some UNB information (version etc), and the profiles makes up the sender/receiver part.
When creating the Xml content, we should not need to care about what's in the agreement - which is the whole idea behind the agreement ;)
According to ms documentation, the UNA information (separators, indicators etc) should be read from the agreement.
SETUP
It's a bit too much to provide all the samples (profile, agreements, test data etc), but hopefully someone has some valuable insights to share =)
Best regards, Mikael
Sample message to encode
<ins0:EdifactInterchangeXml DelimiterSetSerializedData="39:13:10:43:58:63:-1:46:-1"
xmlns:ins0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/InterchangeXML">
<TransactionSetGroup>
<TransactionSet DocType="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006#EFACT_D97A_DELFOR">
<ns0:EFACT_D97A_DELFOR xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006">
<UNH>
<UNH1>1</UNH1>
<UNH2>
<UNH2.1>DELFOR</UNH2.1>
<UNH2.2>D</UNH2.2>
<UNH2.3>97A</UNH2.3>
<UNH2.4>UN</UNH2.4>
</UNH2>
</UNH>
<ns0:BGM>
<ns0:C002>
<C00201>241</C00201>
</ns0:C002>
<ns0:C106>
<C10601>20170501</C10601>
</ns0:C106>
<BGM03>5</BGM03>
</ns0:BGM>
<ns0:DTM>
<ns0:C507>
<C50701>137</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:DTM>
<ns0:C507>
<C50701>158</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:DTM>
<ns0:C507>
<C50701>159</C50701>
<C50702>20171231</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:NADLoop1>
<ns0:NAD>
<NAD01>SU</NAD01>
<ns0:C082>
<C08201>123456</C08201>
<C08203>92</C08203>
</ns0:C082>
<ns0:C080>
<C08001>TEST SUPPLIER</C08001>
</ns0:C080>
</ns0:NAD>
</ns0:NADLoop1>
<ns0:GISLoop1>
<ns0:GIS>
<ns0:C529>
<C52901>36</C52901>
</ns0:C529>
</ns0:GIS>
<ns0:NADLoop2>
<ns0:NAD_2>
<NAD01>ST</NAD01>
<ns0:C082_2>
<C08201>123456789</C08201>
<C08203>16</C08203>
</ns0:C082_2>
<ns0:C080_2>
<C08001>TEST SHIP-TO PLANT</C08001>
</ns0:C080_2>
<ns0:C059_2>
<C05901>STREET 1</C05901>
<C05902>STREET 2</C05902>
<C05903>STREET3</C05903>
</ns0:C059_2>
<NAD06>CITYNAME</NAD06>
<NAD07>STATE</NAD07>
<NAD08>ZIP CODE</NAD08>
<NAD09>USA</NAD09>
</ns0:NAD_2>
</ns0:NADLoop2>
<ns0:LINLoop1>
<ns0:LIN>
<LIN01>1</LIN01>
<ns0:C212>
<C21201>PART NUMBER 1</C21201>
<C21202>IN</C21202>
</ns0:C212>
</ns0:LIN>
<ns0:IMD>
<IMD01>F</IMD01>
<ns0:C273>
<C27304>ITEM DESCRIPTION</C27304>
</ns0:C273>
</ns0:IMD>
<ns0:LOC_2>
<LOC01>7</LOC01>
<ns0:C517_2>
<C51701>123</C51701>
</ns0:C517_2>
</ns0:LOC_2>
<ns0:RFFLoop4>
<ns0:RFF_4>
<ns0:C506_4>
<C50601>ON</C50601>
<C50602>9999999</C50602>
</ns0:C506_4>
</ns0:RFF_4>
</ns0:RFFLoop4>
<ns0:QTYLoop1>
<ns0:QTY>
<ns0:C186>
<C18601>48</C18601>
<C18602>4000</C18602>
<C18603>EA</C18603>
</ns0:C186>
</ns0:QTY>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>50</C50701>
<C50702>20170101</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
<ns0:RFFLoop5>
<ns0:RFF_5>
<ns0:C506_5>
<C50601>SI</C50601>
<C50602>22222222</C50602>
</ns0:C506_5>
</ns0:RFF_5>
</ns0:RFFLoop5>
</ns0:QTYLoop1>
<ns0:QTYLoop1>
<ns0:QTY>
<ns0:C186>
<C18601>3</C18601>
<C18602>8000</C18602>
<C18603>EA</C18603>
</ns0:C186>
</ns0:QTY>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>51</C50701>
<C50702>20170101</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>52</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
</ns0:QTYLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>10</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>1000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>1</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>2000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170510</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
<ns0:RFFLoop6>
<ns0:RFF_6>
<ns0:C506_6>
<C50601>RE</C50601>
<C50602>111</C50602>
</ns0:C506_6>
</ns0:RFF_6>
</ns0:RFFLoop6>
</ns0:QTYLoop2>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>1500</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170520</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
<ns0:RFFLoop6>
<ns0:RFF_6>
<ns0:C506_6>
<C50601>RE</C50601>
<C50602>112</C50602>
</ns0:C506_6>
</ns0:RFF_6>
</ns0:RFFLoop6>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>4</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>3000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170601</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>4000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170701</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
</ns0:LINLoop1>
</ns0:GISLoop1>
<UNT>
<UNT1>34</UNT1>
<UNT2>1</UNT2>
</UNT>
</ns0:EFACT_D97A_DELFOR>
</TransactionSet>
</TransactionSetGroup>
<ns0:UNZ xmlns:ns0="http://schemas.microsoft.com/Edi/EdifactServiceSchema">
<UNZ1>1</UNZ1>
<UNZ2>1</UNZ2>
</ns0:UNZ>
</ins0:EdifactInterchangeXml>
Expected output
UNA:+.? '
UNB+UNOA:1+99:ZZ+96:ZZ+170501:1439+1++DELFOR++++1'
UNH+1+DELFOR:D:97A:UN'
BGM+241+20170501+5'
DTM+137:20170501:102'
DTM+158:20170501:102'
DTM+159:20171231:102'
NAD+SU+123456::92++TEST SUPPLIER'
GIS+36'
NAD+ST+123456789::16++TEST SHIP-TO PLANT+STREET 1:STREET 2:STREET3+CITYNAME+STATE+ZIP CODE+USA'
LIN+1++PART NUMBER 1:IN'
IMD+F++:::ITEM DESCRIPTION'
LOC+7+123'
RFF+ON:9999999'
QTY+48:4000:EA'
DTM+50:20170101:102'
RFF+SI:22222222'
QTY+3:8000:EA'
DTM+51:20170101:102'
DTM+52:20170501:102'
SCC+10++D'
QTY+1:1000'
DTM+2:20170501:102'
SCC+1++D'
QTY+1:2000'
DTM+2:20170510:102'
RFF+RE:111'
QTY+1:1500'
DTM+2:20170520:102'
RFF+RE:112'
SCC+4++D'
QTY+1:3000'
DTM+2:20170601:102'
QTY+1:4000'
DTM+2:20170701:102'
UNT+34+1'
UNZ+1+1'
The xml in the original post is invalid, it's has the root node of the output result from the decode step. The error message completely threw me in the wrong direction.
The xml must of course start with the proper root element name, in this case: EFACT_D97A_DELFOR.
Now it works like a charm! :)
Sample data
<ns0:EFACT_D97A_DELFOR xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006">
<UNH>
<UNH1>1</UNH1>
<UNH2>
<UNH2.1>DELFOR</UNH2.1>
<UNH2.2>D</UNH2.2>
<UNH2.3>97A</UNH2.3>
<UNH2.4>UN</UNH2.4>
</UNH2>
</UNH>
<ns0:BGM>
<ns0:C002>
<C00201>241</C00201>
</ns0:C002>
<ns0:C106>
<C10601>20170501</C10601>
</ns0:C106>
<BGM03>5</BGM03>
</ns0:BGM>
<ns0:DTM>
<ns0:C507>
<C50701>137</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:DTM>
<ns0:C507>
<C50701>158</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:DTM>
<ns0:C507>
<C50701>159</C50701>
<C50702>20171231</C50702>
<C50703>102</C50703>
</ns0:C507>
</ns0:DTM>
<ns0:NADLoop1>
<ns0:NAD>
<NAD01>SU</NAD01>
<ns0:C082>
<C08201>123456</C08201>
<C08203>92</C08203>
</ns0:C082>
<ns0:C080>
<C08001>TEST SUPPLIER</C08001>
</ns0:C080>
</ns0:NAD>
</ns0:NADLoop1>
<ns0:GISLoop1>
<ns0:GIS>
<ns0:C529>
<C52901>36</C52901>
</ns0:C529>
</ns0:GIS>
<ns0:NADLoop2>
<ns0:NAD_2>
<NAD01>ST</NAD01>
<ns0:C082_2>
<C08201>123456789</C08201>
<C08203>16</C08203>
</ns0:C082_2>
<ns0:C080_2>
<C08001>TEST SHIP-TO PLANT</C08001>
</ns0:C080_2>
<ns0:C059_2>
<C05901>STREET 1</C05901>
<C05902>STREET 2</C05902>
<C05903>STREET3</C05903>
</ns0:C059_2>
<NAD06>CITYNAME</NAD06>
<NAD07>STATE</NAD07>
<NAD08>ZIP CODE</NAD08>
<NAD09>USA</NAD09>
</ns0:NAD_2>
</ns0:NADLoop2>
<ns0:LINLoop1>
<ns0:LIN>
<LIN01>1</LIN01>
<ns0:C212>
<C21201>PART NUMBER 1</C21201>
<C21202>IN</C21202>
</ns0:C212>
</ns0:LIN>
<ns0:IMD>
<IMD01>F</IMD01>
<ns0:C273>
<C27304>ITEM DESCRIPTION</C27304>
</ns0:C273>
</ns0:IMD>
<ns0:LOC_2>
<LOC01>7</LOC01>
<ns0:C517_2>
<C51701>123</C51701>
</ns0:C517_2>
</ns0:LOC_2>
<ns0:RFFLoop4>
<ns0:RFF_4>
<ns0:C506_4>
<C50601>ON</C50601>
<C50602>9999999</C50602>
</ns0:C506_4>
</ns0:RFF_4>
</ns0:RFFLoop4>
<ns0:QTYLoop1>
<ns0:QTY>
<ns0:C186>
<C18601>48</C18601>
<C18602>4000</C18602>
<C18603>EA</C18603>
</ns0:C186>
</ns0:QTY>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>50</C50701>
<C50702>20170101</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
<ns0:RFFLoop5>
<ns0:RFF_5>
<ns0:C506_5>
<C50601>SI</C50601>
<C50602>22222222</C50602>
</ns0:C506_5>
</ns0:RFF_5>
</ns0:RFFLoop5>
</ns0:QTYLoop1>
<ns0:QTYLoop1>
<ns0:QTY>
<ns0:C186>
<C18601>3</C18601>
<C18602>8000</C18602>
<C18603>EA</C18603>
</ns0:C186>
</ns0:QTY>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>51</C50701>
<C50702>20170101</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
<ns0:DTM_11>
<ns0:C507_11>
<C50701>52</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507_11>
</ns0:DTM_11>
</ns0:QTYLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>10</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>1000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170501</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>1</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>2000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170510</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
<ns0:RFFLoop6>
<ns0:RFF_6>
<ns0:C506_6>
<C50601>RE</C50601>
<C50602>111</C50602>
</ns0:C506_6>
</ns0:RFF_6>
</ns0:RFFLoop6>
</ns0:QTYLoop2>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>1500</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170520</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
<ns0:RFFLoop6>
<ns0:RFF_6>
<ns0:C506_6>
<C50601>RE</C50601>
<C50602>112</C50602>
</ns0:C506_6>
</ns0:RFF_6>
</ns0:RFFLoop6>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
<ns0:SCCLoop1>
<ns0:SCC>
<SCC01>4</SCC01>
<ns0:C329>
<C32901>D</C32901>
</ns0:C329>
</ns0:SCC>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>3000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170601</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
<ns0:QTYLoop2>
<ns0:QTY_2>
<ns0:C186_2>
<C18601>1</C18601>
<C18602>4000</C18602>
</ns0:C186_2>
</ns0:QTY_2>
<ns0:DTM_13>
<ns0:C507_13>
<C50701>2</C50701>
<C50702>20170701</C50702>
<C50703>102</C50703>
</ns0:C507_13>
</ns0:DTM_13>
</ns0:QTYLoop2>
</ns0:SCCLoop1>
</ns0:LINLoop1>
</ns0:GISLoop1>
<UNT>
<UNT1>34</UNT1>
<UNT2>1</UNT2>
</UNT>
</ns0:EFACT_D97A_DELFOR>