How to change EDI segment values in a custom pipeline RRS feed

  • General discussion

  • if I want to replace some values in the ISA or GS segments. How do I grab ahold of the msg and segment values? I am a newbie!  From what I have been reading and searching I have found this, but are not quite certain how to bring it all together? I have never dealt with a pipeline before. I want to route failed msgs and insert it in the database. I assume that I create a dll then drag it to the pre-assemble stage of the Send pipeline to do what I want? Not sure if I am not the right track? Any guidence would be greatly appreciated!





    public static IBaseMessage ReplaceValues(PipelineContext pc, IBaseMessage inmsg)


    IBaseMessagePart bodyPart = inmsg.BodyPart;
    Stream originalStream = bodyPart.GetOriginalDataStream();

    int numberBytesToRead = (int)originalStream.Length;
    int numberBytesRead = 0;

    byte[] outBytes = new byte[numberBytesToRead];

    int bytes = originalStream.Read(outBytes, numberBytesRead, numberBytesToRead);

    string outboundEDI = System.Text.Encoding.Default.GetString(outBytes);

    //Replace ISA06
    string [] splitEDI = outboundEDI.Split(new Char [] {'*'});
    if (splitEDI.Length > 0 && splitEDI[06] != null)
          int controlVersion = System.Convert.ToInt32(splitEDI[06].ToString());

         outboundEDI = outboundEDI.Replace(splitEDI[06].ToString(), "FAILED_MSG");

    byte[] newEDIBytes =

    MemoryStream memStream = new MemoryStream();
    memStream.Write(newEDIBytes, 0, newEDIBytes.Length);
    memStream.Position = 0;

    bodyPart.Data = memStream;

    return inmsg;


    Tuesday, November 9, 2010 2:56 PM

All replies

  • If you want to change only ISA and GS segment values you can override the EDI Context properties in the Custom Component.

    The Custom Pipeline Component should be placed before the EDi Assembler.

    For example if you want to replace the GS03 value, find below the code snippet for the same.

     inmsg.Context.Promote("GS03",, "1234567");

    All the EDI Related Context Properties can be found in schema.

    Refer to post for more information

    Sathish -
    Tuesday, November 9, 2010 4:18 PM
  • Hello,

    I have a couple of custom pipelines that do validations that and alter some values on EDIFACT segments.

    If you want to change the values after "EDI Assembler" component use the StreamReader and StreamWriter to work your way on the data.

    Like SathishT said you can make some validations and them change somo EDI context that way you can use send ports with filters to rout the messages.


    In my recent case I had to take out the test indicator that biztalk 2010 put's on the EDI message.

    I have one component that does that with ten lines off code...pretty simple.


    I have another that does archiving off the original file that is received on Biztalk and register the location on a DATA base.

    In my previous Google searches...I came across some custom pipelines that make alot of a search you will be surprised on the amount of pipelines rolling around on the net.

    Tuesday, November 16, 2010 5:01 PM
  • Bairro

    I'm really interested in the part where you say you have once developed a "ten-lines code" solution to deal with the test indicator in BT 2010.

    I have a huge problem for the moment as BT is only accepting 0 or 1 as test indicator. My trading partner only accepts '1' or ''.

    Can you help me out please?


    Wednesday, May 4, 2011 8:05 AM