Feb 052009

So there are a few companies out there that want to send out a file with a standard naming convention.

I thought, this will be EASY, you simply assign the file name to the transactions, and the Batching orchestration will re attach the context properties after its batching process completes and it sends it out so I can use %SourceFileName% in the Send Port.

WRONG, I get a file named %SourceFileName% in the folder.

To get a custom filename you have to attach the filename into the payload of the message somewhere. In my case I was needing to put the batch run id in the filename.

How I did it was put it in the ST03 element (since it gets rewritten in the EDI Send Pipeline).

I then created an orchestration that picks up messages using the filter recommendations in the party definition. Since it is a batched message, there is no schema that can be made that actually represents the data that the batching orchestration creates, I used an XMLDocument message.

Now came the problem of extracting the value from the message. I thought it would be as easy to use


However I was getting the error that the first argument needed to be a message, and since it was not a message, but a XLANGs.BaseTypes. Any message, I converted to a XMLDocument in an expression:

TempXML=new System.XML.XMLDocument(); TempXML=InMsg.MessagePart;

However I could not use the XLANGs function xpath to extract the value because I did not have a true message, so I had to use C#.

I had to create the following variables (in an atomic scope because it was late and I was tired and did not want to see if the variables were serializable or not)

Variable Name .NET Type
TempXML System.XML.XMLDocument
StringRdr System.IO.StringReader
XPathDoc System.Xml.XPath.XPathDocument
XPathNav System.Xml.XPath.XPathNavigator
XPathExpression System.Xml.XPath.XPathExpression
XPathNodeIterator System.Xml.XPath.XPathNodeIterator


In the expression shape I have the following code:

TempXML=InMsg.MessagePart; StringRdr=New System.IO.StringReader(TempXML.InnerXml); XPathDoc=new System.Xml.XPath.XPathDocument(StringRdr); XPathNav=XPathDoc.CreateNavigator; XPathExpression=XPathNav.Compile("//ST03[1]"); XPathNodeIterator=XPathNav.Select(XPathExpression); while(EPathNodeIterator.MoveNext()) { BatchId=System.Convert.ToString(XPathNodeIterator.Current.Value); }

Which extracts the value into BatchId from the message for me, now I can set the output file name to whatever is in the ST03 element.

In my case it was :


So now I can put in the send port


  • Jerry Smith

    Great post on this very common business requirement (but seem to be the only one out there)!

    Anyway, quick question on this statement: “I
    then created an orchestration that picks up messages using the filter recommendations in the party definition.”

    Are you referring to the Batch Filter? Does this mean the out of the box EDI batching orchestration promotes this again after batching is complete? How does this address question of this new orchestration picking up the message before the send port (defined for the party) actually picks it up? Does this new orchestration have to promote anything before it re-publishes the message to finally route it to the send port?

    Thanks again for a very informative post!