Geeks With Blogs
Bill Osuch - Random geek notes

In two previous posts I talked about party configuration and routing of EDI messages:

Basic Party Resolution in BizTalk 2010
EDI Party Resolution (& trading partners) in BizTalk 2010

In this post I’ll build off of those examples and set up EDI batching so that we can deliver more than one EDI 810 invoice per file. You’ll need to have worked through the previous two posts to have your BizTalk application ready to follow along with these steps.

First, change the File name: of the Contoso Send Port to “Unbatched - %MessageID%.txt” (no quotes, of course).

Next, we’ll create a new Receive Location to pick up the unbatched messages and mark them for batching. (For more information on how this works, read up on the BatchMarker pipeline component at this MSDN link) Create a Receive Port called InvoicesToBatch, and a Receive Location called InvoicesToBatch_FILE. The receive folder should be the same as the folder used by the Contoso Send Port. Set the File mask: to “Unbatched*.txt”, and choose EdiReceive for the Receive pipeline:.

Now let’s configure the batching properties of the Contoso Purchase Order agreement. Click on the My Company –> Contoso tab, then Batch Configuration.  For the Batch name: enter “Invoices for Contoso”. Move to the Filter section and add the following filter:

BTS.ReceivePortName == InvoicesToBatch And
BTS.MessageType ==

In the Release section, choose Maximum number of transaction sets in, set the drop-down to Interchange: and enter 3. Finally, click Start immediately in the Activation section

Now we need a Send Port where we can drop the batched file. Create a new Send Port called BatchedInvoicesForContoso_FILE, pointing at the same directory as the Contoso Send Port, and set the File name: to “Batched - %MessageID%.txt”. Choose EdiSend for the Send pipeline: then move to the Filters tab. Create a filter that looks like this:

EDI.ToBeBatched == False And
EDI.BatchName == Invoices for Contoso And
EDI.SenderPartyName == My Company And
EDI.DestinationPartyName == Contoso

Click OK to save the Send Port.

So what all have we done here? As in the previous post, when we drop a Contoso XML file to the Input directory, it will have the Destination party set in the orchestration and an EDI 810 file will be dropped to the Send Port. The new Receive Port will grab the file, and the BatchMarker pipeline component will promote the appropriate context properties to allow the file to be batched. When 3 interchanges (ST/SE segments in this case) have gone through the batch process, the file will be written out. We’ve given it a different prefix (“Unbatched” vs. “Batched”) so it won’t be grabbed again and enter an infinite loop.

Time to test. Stop and restart the application, and restart the Host Instance. Drop a Contoso XML file to the Input directory, and switch over to the Contoso output directory. You should see a file created (starting with “Unbatched…”), and then it will disappear very quickly. Drop a second file in and the process repeats. Now go to the BizTalk Group Hub, and run a query for Running Service Instances. You should have a record for the BatchingService; double-click it to open and click on the Messages tab. In the Message Type column you should see two messages of type Drop a third XML file into the Input directory and the batch should be released – you should see a Batched – <something>.txt file. Open it up and you should have a single ISA and GS segment, and three ST/SE groups.

Let’s say you want BizTalk to go ahead and batch the files it is currently holding, before the actual maximum number of transaction sets is released. Drop two instances of the XML file to the Input directory, then open the Contoso Purchase Order agreement and view the Batch Configuration tab. Click the Override button, and after a few moments a file should be dropped to Contoso’s output directory. Open it up and you’ll see that it contains only two interchanges.

You may want more control over when a batch is released – for example, you might want to send out a single batch every day when all of the files for a certain client have been processed. In a future post I’ll talk about using an external release trigger, to allow you to control exactly when the batch is released.

Technorati Tags: ,

Posted on Thursday, February 16, 2012 3:04 PM BizTalk , EDI | Back to top

Comments on this post: BizTalk 2010 EDI Batching Tutorial

# re: BizTalk 2010 EDI Batching Tutorial
Requesting Gravatar...

I liked your article regarding the batching of x12 EDI messages while sending out to the partner, but one more details like : Is it necessary to drop the unbatched files to a file location and than by using a receive location pick them again.

In our case we are using AS2 connection and we do not have file location. Can we batch the files without using the file drop approach ?
Left by Sachin Gupta on Oct 23, 2012 12:30 PM

# re: BizTalk 2010 EDI Batching Tutorial
Requesting Gravatar...
How would you batch transactions which are not yet EDI formatted transactions, into a single interchange? We have an ERP process that creates a fixed record flat file of invoice data. This file could contain 15 invoices for the same trading partner. Currently, I get 15 ISA/IEA envelopes from this data, one interchange for each invoice. I would like one interchange/group envelope that contains all 15 ST/SE transactions. In all the batching examples I'm finding, they talk about using the EDI Receive pipeline - but the messages I'm trying to batch are not EDI messages (yet).

I'm thinking I'm missing something - and I don't know what it is that I'm missing yet.
Left by Ted Onley on Sep 02, 2014 10:31 AM

Your comment:
 (will show your gravatar)

Copyright © Bill Osuch | Powered by: