none
Promoted properties in EDI schema is not promoted by EdiReceive RRS feed

  • Question

  • I'm promoting fields like BGM02 in EDIFACT during design time, but when BizTalk processes the messages these properties does not get promoted to the context (the property schema that I'm using, and it's respective fields does not appear in the context at all).

    Everything else is working fine, the document (I've used both INVOIC and DESADV) is parsed correctly and the properties that the Edi Disassembler promotes by default (like UNB) gets promoted correctly. I haven´t found any evidence in the BizTalk documentation, literature or elsewhere that it's not possible to define your own custom promoted fields in the EDIFACT schemas.

    I have tried promoting to different property schemas, resolving the party or letting it resolve to guest party (global EDI properties), and I've tried different configurations on the Edi Disassembler, without luck.

    Is it not possible to promote properties according to your own choice in EDIFACT schemas (given that they conform to the rules, that is, non-repeating fields etc)?

    Sunday, March 29, 2009 6:33 PM

Answers

  • This is currently not supported in EDIReceive pipelines.

    You can do it by using below steps:
    - Create property schema and deploy it.
    - Read EDI message in Custome Pipeline component.
    - Promote the context properties from custom pipeline component.


    For Example:
    In ORDERS Efact message, you can read message and promote context properties:

    public

     

    Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)

    {

     

    //read and promote po properties.

     

    string nsForCP = "http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006";

     

    string qtyPropName = "QtyNum";

     

    string buyIdPropName = "BuyerName";

     

    string productCodePropName = "ProductCode";

     

    //Load Orders schema

     

    XmlDocument doc = new XmlDocument();

    doc.Load(pInMsg.BodyPart.Data);

    pInMsg.BodyPart.Data.Seek(0,

    SeekOrigin.Begin);

     

    XmlNamespaceManager xmlNSMgr= new XmlNamespaceManager(doc.NameTable);

    xmlNSMgr.AddNamespace(

    "ns0","http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006");

     

    XmlElement root = doc.DocumentElement;

     

    //read quantity

     

    XmlNodeList nodeList = root.SelectNodes("/ns0:EFACT_D98B_ORDERS/ns0:SCCLoop1/ns0:QTYLoop1/ns0:QTY/ns0:C186", xmlNSMgr);

     

    if (nodeList != null && nodeList.Count>0)

    {

     

    XmlNode qtyNode = nodeList[0];

     

    string numStr = qtyNode.ChildNodes[0].InnerText;

    pInMsg.Context.Write(qtyPropName, nsForCP, numStr);

    pInMsg.Context.Promote(qtyPropName, nsForCP, numStr);

    }

     

    //read buyer name

    nodeList = root.SelectNodes(

    "/ns0:EFACT_D98B_ORDERS/ns0:NADLoop1/ns0:NAD/ns0:C058", xmlNSMgr);

     

    if (nodeList != null && nodeList.Count > 0)

    {

     

    XmlNode nameNode = nodeList[0];

     

    string nameStr = nameNode.ChildNodes[0].InnerText;

    pInMsg.Context.Write(buyIdPropName, nsForCP, nameStr);

    pInMsg.Context.Promote(buyIdPropName, nsForCP, nameStr);

    }

     

    //read product code

    nodeList = root.SelectNodes(

    "/ns0:EFACT_D98B_ORDERS/ns0:IMD/ns0:C272",xmlNSMgr);

     

    if (nodeList != null && nodeList.Count > 0)

    {

     

    XmlNode productIdNode = nodeList[0];

     

    string productIdStr = productIdNode.ChildNodes[1].InnerText;

    pInMsg.Context.Write(productCodePropName, nsForCP, productIdStr);

    pInMsg.Context.Promote(productCodePropName, nsForCP, productIdStr);

    }

     

    return pInMsg;

    }


    Bhola Meena [http://blogs.msdn.com/biztalkrfidinside]
    • Marked as answer by Klas Ericsson Tuesday, March 31, 2009 6:54 AM
    Monday, March 30, 2009 7:42 PM

All replies

  • This is currently not supported in EDIReceive pipelines.

    You can do it by using below steps:
    - Create property schema and deploy it.
    - Read EDI message in Custome Pipeline component.
    - Promote the context properties from custom pipeline component.


    For Example:
    In ORDERS Efact message, you can read message and promote context properties:

    public

     

    Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)

    {

     

    //read and promote po properties.

     

    string nsForCP = "http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006";

     

    string qtyPropName = "QtyNum";

     

    string buyIdPropName = "BuyerName";

     

    string productCodePropName = "ProductCode";

     

    //Load Orders schema

     

    XmlDocument doc = new XmlDocument();

    doc.Load(pInMsg.BodyPart.Data);

    pInMsg.BodyPart.Data.Seek(0,

    SeekOrigin.Begin);

     

    XmlNamespaceManager xmlNSMgr= new XmlNamespaceManager(doc.NameTable);

    xmlNSMgr.AddNamespace(

    "ns0","http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006");

     

    XmlElement root = doc.DocumentElement;

     

    //read quantity

     

    XmlNodeList nodeList = root.SelectNodes("/ns0:EFACT_D98B_ORDERS/ns0:SCCLoop1/ns0:QTYLoop1/ns0:QTY/ns0:C186", xmlNSMgr);

     

    if (nodeList != null && nodeList.Count>0)

    {

     

    XmlNode qtyNode = nodeList[0];

     

    string numStr = qtyNode.ChildNodes[0].InnerText;

    pInMsg.Context.Write(qtyPropName, nsForCP, numStr);

    pInMsg.Context.Promote(qtyPropName, nsForCP, numStr);

    }

     

    //read buyer name

    nodeList = root.SelectNodes(

    "/ns0:EFACT_D98B_ORDERS/ns0:NADLoop1/ns0:NAD/ns0:C058", xmlNSMgr);

     

    if (nodeList != null && nodeList.Count > 0)

    {

     

    XmlNode nameNode = nodeList[0];

     

    string nameStr = nameNode.ChildNodes[0].InnerText;

    pInMsg.Context.Write(buyIdPropName, nsForCP, nameStr);

    pInMsg.Context.Promote(buyIdPropName, nsForCP, nameStr);

    }

     

    //read product code

    nodeList = root.SelectNodes(

    "/ns0:EFACT_D98B_ORDERS/ns0:IMD/ns0:C272",xmlNSMgr);

     

    if (nodeList != null && nodeList.Count > 0)

    {

     

    XmlNode productIdNode = nodeList[0];

     

    string productIdStr = productIdNode.ChildNodes[1].InnerText;

    pInMsg.Context.Write(productCodePropName, nsForCP, productIdStr);

    pInMsg.Context.Promote(productCodePropName, nsForCP, productIdStr);

    }

     

    return pInMsg;

    }


    Bhola Meena [http://blogs.msdn.com/biztalkrfidinside]
    • Marked as answer by Klas Ericsson Tuesday, March 31, 2009 6:54 AM
    Monday, March 30, 2009 7:42 PM
  • Thanks Bhola, I was starting to suspect this had to be done in a custom pipeline component. If anyone knows if Microsoft plans to include it in future releases of BizTalk, feel free to comment. Atleast when using BizTalk as a Message Broker for EDI in a VAN-like scenario, tracking message data like invoice number etc, is a common task.
    Tuesday, March 31, 2009 6:54 AM
  • Hi Klas,
     We will track it as feature request. This is kind of complicated as there are many different EDI document types and hard to decide which field to promote. Sometimes a EDI document have loops so one single context property can't represent a field.
    Thanks,
    Bhola
    Bhola Meena [http://blogs.msdn.com/biztalkrfidinside]
    Tuesday, March 31, 2009 6:04 PM
  • Hi again Bhola,

    Just to clarify (based on your latest reply): what I meant was to let the developer decide which field to promote in the Schema Editor, and to let the developer ascertain that the field in question is not a repeating one (in the same way it´s done for flatfile and XML formats). I think there's already a designtime validation in place that doesn´t let you promote repeating fields in the promotion dialog in VS, so that should not be a problem in runtime. 

    To let BizTalk decide which field represents the "document number" (based on each EDI schema) would indeed be complex, but that´s not what I'm after.

    In theory it should be possible to classify the EDI schema as a "normal" flatfile schema, and to process it like a normal flatfile, since the flatfile disassembler promotes the custom fields defined by the developer, but it's most probably quicker and more scalable to implement this as a custom pipeline component for EDI. 

    To summarize: As I understand your first reply, the EDI Disassembler will ignore any fields marked as promoted in the schema by the developer, and only promote the fields relating to the way BizTalk processes EDI messages, which is UNB etc.  

    Regards,
    Klas


    Wednesday, April 1, 2009 10:07 AM
  • Just ran into the same problem when promoting BGM02. Is this a confirmed bug?
    Tuesday, May 11, 2010 11:51 AM
  • I haven't tried it in BizTalk 2009, but Bhola's answer indicates that it's not featured in the EDI Disassembler, the component that would perform the promotion in the same way that the Xml or Flat File Disassembler does for those message syntaxes. So not exactly a bug, rather a non-feature. I would think twice about the sample code above since it doesn't conform to the streaming best practice approach for BizTalk pipeline components, and EDI documents tend to be large. For BGM02, a forward only stream is sufficient though since the BGM02 field it is not repeating, so the way to go would be to implement a custom stream and wrapping the incoming message body stream with this. This way, you avoid processing the message twice and loading it in memory. See examples in the SDK for more info, or http://blogs.objectsharp.com/cs/blogs/nbarden/archive/2008/04/24/developing-streaming-pipeline-components-part-1.aspx, for example.
    Wednesday, May 26, 2010 7:03 PM