none
UNB segment[recipient value is dynamic]->map values from oracle table

    Question

  • Hi Experts,

    we are in the situation that generate the EDI file by using reading the data's from oracle table[polling statement] then map those data's to EDI schema..in that UNB segment --> have to map the data's from oracle table[separate table entry is there for UNB details].

    we can able to generate the EDI File for static sender & Recipient values..

    we are unable to proceed further in the below scenario..

    Scenario: sender is constant  but recipient is dynamic..

    based on the some code like

    1 means --> recipient -->AAA

    2 means --> recipient --> BBB

    3 means --> recipient ---> CCC

    code[1,2,3...] values should be referred from LOC segment ..

    etc..

    how to handle these kind of situation ..can EDI experts please guide us to resolve the issue?. it would be very helpful if anyone come up with solution?Please guide us?


    Thanks, Archana




    Thursday, September 26, 2013 6:02 AM

Answers

  • As la Cour pointed out, you should be using .Write not .Promote for both properties.

    Are you sure you code is following the correct path?  In Visual Studio, you can attach to BTSNTSvc.exe and set a break point at the beginning of .Execute.  Then you can step through and see what's going on.

    Your conditions would always evaluate to FALSE.

    string ReadContextPropName = "PUCL_REL_LOC_CODE_1";
    if (ReadContextPropName.Equals("INNSAGG"))
    else if (ReadContextPropName.Equals("INNSXXY"))
    
    
    Looks like you should be checking val instead.
    Monday, September 30, 2013 1:46 PM

All replies

  • You can use the properties in the EdiOverride collection to specify specific values that will be applied regardless of the Party/Agreement configuration.  Reference: http://msdn.microsoft.com/en-us/library/dd210685.aspx

    So, what you'd have to do is handle the message at some point before the EdiAssembler to set these properties to you custom values.

    The values are applied during serialization and don't affect Party resolution.

    Few things to note, the properties are not preserved by the Batching Orchestration so if you're using that, you'd have to intercept the Interchange message after Batch release, but before the EdiAssembler.  Whether it's an Orchestration or a Pipeline Component, you'd have to decide based on your current implementation.

    Thursday, September 26, 2013 2:28 PM
  • Hi Boatseller,thanks a lot : ).I am new to custom pipeline component..I tried to crate the custom pipeline but feel ..difficult..can you please provide me some reference links..

    Thanks, Archana


    Friday, September 27, 2013 5:41 AM
  • Hi Boatseller,

    created the custom pipeline component here is the code. 

    #region IComponent Members
            public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
            {
               IBaseMessageContext context = pInMsg.Context;
                context.Write("OverrideEDIHeader ", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)true);
               context.Write("UNB3.1", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)"UNB3.1OverrideValue");
                return pInMsg;
            }
            #endregion

     -------

    1.Promoted the LOC field from oracledbbinding.xsd(based on this field only I can able to assign the Recipient value)

    2.How to validate the LOC field[pollingstatement.xsd ,polled the data's from oracle] in C# code[Custom pipeline Component Code].

    ie: have to read the LOCCODE [Oracledbbinding.xsd]

      if LOCCODE == 1 then map the value AAA to UNB3.1 [Recipient]

    else if LOCCODE ==2 then map the Value BBB to UNB3.1

    can you please guide to achieve this scenario.. 


    Thanks, Archana


    Friday, September 27, 2013 9:32 AM
  • Sorry, I'm not totally following you.  If you have LOCCODE, you can use a switch or if...else to determine which UNB3.1 value you need, pretty much like you already have written above.

    As la Cour notes, it's UNB3_1.  The pipeline code looks sound otherwise.


    • Edited by boatseller Friday, September 27, 2013 3:08 PM missed the . notation
    Friday, September 27, 2013 12:32 PM
  • Are you sure it's not:

     context.Write("UNB3_1", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)"UNB3.1OverrideValue");

    I can't find any properties in that namespace named UNB3.1? only UNB3_1 and UNB2_1??

    http://msdn.microsoft.com/en-us/library/dd210685.aspx

    Morten la Cour

    Friday, September 27, 2013 1:56 PM
  • Hello Boat seller & La Cour,

    thanks a lot ..yes you are right..UNB3_1 for recipient..but I am not getting the output..getting the below error

    error:

    There was a failure executing the send pipeline: "Custom_Pipeline_UNB_Receipt_Dynamic.Custom_PipeLine_UNB_RecipientID, Custom_Pipeline_UNB_Receipt_Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=" Source: "EDI Assembler" Send Port: "Coparn_Generation" Reason: A message was encountered with root element name of POLLINGSTMTRECORD. It could not be classified as an X12 or Edifact message. The root namespace was http://Microsoft.LobServices.OracleDB/2007/03/POLLINGSTMT

    i did the following to create the custom send pipeline.

    1.added the Custom pipeline component ToolIcon to "SendPipeline"

    2.In Send Port-->chosen CustomsendPipeline

    can you please tell me that what am I doing wrong? please guide me


    Thanks, Archana

    Monday, September 30, 2013 6:28 AM
  • You need to map your message to edifact XML

    before it enters the ediassembler

    morten la cour

    Monday, September 30, 2013 6:38 AM
  • sorry I couldn't understand your point la cour..can you please tell me in details..i am new to custom pipeline component .hanging on this issue ..my requirement is polling the data's from oracle table [pollingstmt] -->then generate the EDI File ..please guide me la cour..


    Thanks, Archana



    Monday, September 30, 2013 6:56 AM
  • This has nothing to do with your Pipeline or Pipeline Components.

    You need to create a map from your Oracle Schema to an EDIFACT Schema, do the mapping, deploy the map and apply it to either your Receive Port, Send Port (probably the best choice in your case) or Orchestration. The EDIAssembler can only "eat" EDIFACT XML and not anything else.

    Morten la Cour


    • Edited by la Cour Monday, September 30, 2013 7:12 AM
    Monday, September 30, 2013 7:11 AM
  • la cour..already I did the mapping[oracle schema to EDI schema]..but still I am not getting the EDI file generation as output file.

    Thanks, Archana

    Monday, September 30, 2013 7:18 AM
  • Well, if you get an error from the EDAssembler that it received a message with 

    root name: POLLINGSTMTRECORD

    hnamespace: http://Microsoft.LobServices.OracleDB/2007/03/POLLINGSTMT

    I'm pretty sure that the map is not applied.

    Where have you applied the map?

    Are you using the XMLReceive Pipeline on the Receive Port that receives from Oracle?

    Morten la Cour

    Monday, September 30, 2013 7:26 AM
  • yes i am using the XMLReceive on Receive Port.now I changed the Rootname to POLLINGReCORD...but still I am getting the same error..can you please tell me ...am I doing anything wrong?.in mapping-->its like dirext map from oracle pollingreceord to EDI.


    Thanks, Archana



    Monday, September 30, 2013 8:39 AM
  • Change your Send Pipeline To PassthruTransmit and use a File Adapter.

    Take the output and verify that the output is EDIFACT XML.

    If it is not, then run it through your map in Visual Studio and verify that the output is EDIFACT XML.

    If it is not, then change your map.

    also, where is your map applied?

    Morten la Cour

    Monday, September 30, 2013 8:55 AM
  • i am able to get the Mapping output in visual studio.

    i applied the map in send port-->outboundMaps.

    the above error is solved now but now i am getting another error.

    Error details: There was a failure executing the send pipeline: "Custom_Pipeline_UNB_Receipt_Dynamic.Custom_PipeLine_UNB_RecipientID, Custom_Pipeline_UNB_Receipt_Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6c925ec11f2caf28" Source: "CustomPipelineComponent" Send Port: "Coparn_File_generations" Reason: Loading property information list by namespace failed or property not found in the list. Verify that the schema is deployed properly.   : (


    Thanks, Archana



    Monday, September 30, 2013 10:18 AM
  • This seems to come from your custom Pipeline Component, which puzzles me, since you previously showed that you are only writing to Context. The error indicates that you are trying to Promote to a Property that doesn't have a corresponding Property Schema deployed. Can you show your code in the Pipeline Component causing the error.


    Morten la Cour

    Monday, September 30, 2013 10:34 AM
  • using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Xml;

    using System.Xml.XPath;

    using System.IO;

    using Microsoft.BizTalk.Message.Interop;

    using Microsoft.BizTalk.Component.Interop;   

    namespace UNB_Recipient_Custom

    {

        [ComponentCategory(CategoryTypes.CATID_PipelineComponent)]

        [ComponentCategory(CategoryTypes.CATID_Any)]

        [System.Runtime.InteropServices.Guid("48BEC85A-20EE-40ad-BFD0-319B59A0DDBC")]

        public class SampleUNB_Custom:

                        IBaseComponent,

                        IComponentUI,

                        IComponent,

                        IPersistPropertyBag

        {

            #region IBaseComponent Members

            public string Description

            {

                get

                {

                    return "Pipeline component used to write context properties to a BizTalk message";

                }

            }

            public string Name

            {

                get

                {

                    return "CustomPipelineComponent";

                }

            }

            public string Version

            {

                get

                {

                    return "1.0.0.0";

                }

            }

            #endregion

            #region IComponentUI Members

            public IntPtr Icon

            {

                get

                {

                    return new System.IntPtr();

                }

            }

            public System.Collections.IEnumerator Validate(object projectSystem)

            {

                return null;

            }

            #endregion

            #region IPersistPropertyBag Members

            public void GetClassID(out Guid classID)

            {

                classID = new Guid("48BEC85A-20EE-40ad-BFD0-319B59A0DDBC");

            }

            public void InitNew()

            {

            }

            public void Load(IPropertyBag propertyBag, int errorLog)

            {

            }

            public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)

            {

            }

            #endregion

            #region IComponent Members

            public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)

            {

                string ReadContextPropName = "PUCL_REL_LOC_CODE_1";

          string ReadContextPropNamespace = "https://Custom_Pipeline_UNB_Receipt_Dynamic.PropertySchema";

          string SetContextPropName = "UNB3_1";

          string SetContextPropNamespace = "http://schemas.microsoft.com/BizTalk/2006/edi-properties";

                  

              object val = pInMsg.Context.Read(ReadContextPropName, ReadContextPropNamespace);

              if (val != null)

              {

              

                  IBaseMessageContext context = pInMsg.Context;

                  if (ReadContextPropName.Equals("INNSAGG"))

                  {

                      context.Write("OverrideEDIHeader ", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)true);

                      context.Write("UNB3_1", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)"NSAGG");

                      pInMsg.Context.Write(SetContextPropName, SetContextPropNamespace, val.ToString());

                      pInMsg.Context.Promote(SetContextPropName, SetContextPropNamespace, val.ToString());

                     

                  }

                  else if (ReadContextPropName.Equals("INNSXXY"))

                  {

                      context.Write("OverrideEDIHeader ", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)true);

                      context.Write("UNB3_1", "http://schemas.microsoft.com/BizTalk/2006/edi-properties", (object)"NSXXY");

                      pInMsg.Context.Write(SetContextPropName, SetContextPropNamespace, val.ToString());

                      pInMsg.Context.Promote(SetContextPropName, SetContextPropNamespace, val.ToString());

                  }

                

                

              }

                   

                return pInMsg;

            }

            #endregion

        }

    }


    Thanks, Archana

    Monday, September 30, 2013 10:46 AM
  • You shouldn't both write and promote:

                      pInMsg.Context.Write(SetContextPropName, SetContextPropNamespace, val.ToString());

                      pInMsg.Context.Promote(SetContextPropName, SetContextPropNamespace, val.ToString());

                     

    Writing should be sufficient.

    Morten la Cour


    • Edited by la Cour Monday, September 30, 2013 10:55 AM
    Monday, September 30, 2013 10:50 AM
  • i tried in that option la cour but still  i am getting that error : (

    Thanks, Archana

    Monday, September 30, 2013 11:02 AM
  • Are all .Promotes removed from your code?

    Have you restarted your Host Instances after you re-deployed your Pipeline Component?

    I don't understand the following code:

      if (ReadContextPropName.Equals("INNSAGG"))

                  {

    Wouldn't ReadContextPropName always be equal to PUCL_REL_LOC_CODE_1

    Morten la Cour

    Monday, September 30, 2013 11:10 AM
  • yes i restarted the host instance after the re-deployement..

    my requirement is ..based on the value of the PUCL_REL_LOC_CODE_1 from oracledbbinding..i have to set the UNB3_1 (Recipient) value.so i promoted the PUCL_REL_LOC_CODE_1 element..

    string ReadContextPropName = "PUCL_REL_LOC_CODE_1";

    is this the right way to achieve these kind of requirement la cour?


    Thanks, Archana

    Monday, September 30, 2013 11:17 AM
  • I think you should take a step back and not try to get everything working all at the same time.  These errors are all for different and unrelated reasons.

    Have you been able to generate your EDI file without any customizations?  Once you get that working, we can address each issue one at a time.

    Monday, September 30, 2013 11:40 AM
  • Hi Boatseller,

    yes i am able to generate the EDI file without any customizations . Now i able to get the output but custom pipeline component code is not working. Perhaps EDI file is generated with default sender and recipient id like [BTS-SENDER:ZZZ+RECEIVE-PARTNER:ZZZ].i don't know what am I missing in custom send  pipeline component..


    Thanks, Archana



    Monday, September 30, 2013 12:26 PM
  • Now i able to get the output but custom pipeline component code is not working. Perhaps EDI file is generated with default sender and recipient id like [BTS-SENDER:ZZZ+RECEIVE-PARTNER:ZZZ].

    Just to confirm, BTS-SENDER and RECEIVE-PARTNER are what is configured in your agreement so the EDI is being generated correctly but without the override UNB3_1 data.
    Monday, September 30, 2013 12:58 PM
  • boatseller,

    yes ,sender & Recipient values are configured in party-->agreement is only working but we are expecting the output that custom pipeline should replace the recipient[UNB3_1]value. i think that custom pipeline component code is not working..boatseller : (please confirm that am i using the correct code to override the UNB3_1 recipient value ..please guide me boatseller


    Thanks, Archana


    Monday, September 30, 2013 1:05 PM
  • As la Cour pointed out, you should be using .Write not .Promote for both properties.

    Are you sure you code is following the correct path?  In Visual Studio, you can attach to BTSNTSvc.exe and set a break point at the beginning of .Execute.  Then you can step through and see what's going on.

    Your conditions would always evaluate to FALSE.

    string ReadContextPropName = "PUCL_REL_LOC_CODE_1";
    if (ReadContextPropName.Equals("INNSAGG"))
    else if (ReadContextPropName.Equals("INNSXXY"))
    
    
    Looks like you should be checking val instead.
    Monday, September 30, 2013 1:46 PM
  • Update:PUCL_REL_LOC_CODE_1 element occurs multiple time that is PollingRecord is unbounded..so I cant promote the element ..can you please suggest me that how to override the Recipient value.i am new to C#. how to read the PUCL_REL_LOC_CODE_1 value inside C#.it would be very  helpful to proceed further if I got the solution.

    Thanks, Archana




    Wednesday, October 09, 2013 10:02 AM
  • Here's you first two options:

    1. Change the SP output to emit PUCL_REL_LOC_CODE_1 only once, using a separate result set.

    2. If that's not possible, the easiest way to retrieve it would be in an Orchestration using the xpath function which would look something like:

    strPUCL_REL_LOC_CODE_1 = xpath(MyIncomingMessage, "string(//*[local-name()='PUCL_REL_LOC_CODE_1'][1]/text())");
    
    MyOutgoingMessage(EDIOverride.UNB3_1) = strPUCL_REL_LOC_CODE_1;
    

    Wednesday, October 09, 2013 12:58 PM
  • thanks a lot boatseler.. we got the result : )..assigned the xpath value to string variable then override the recipient value in message assignment shape..

    Thanks, Archana


    Tuesday, October 15, 2013 6:51 AM