May 152009

This is geared for single batches of transactions, be on the lookout for an upcoming tutorial on how to use the Batches functionality in BizTalk 2009.

This is actually a step by step tutorial on how to enable batching for outbound EDI transactions, where the input file needs to be split up from one single message but creating multiple transactions.

In my case I am going to take an invoice process. I am picking up a file from an FTP site with multiple rows, each row represents an invoice. Once all of the transactions are created, I need to release the batch.

The first think I need to do is create an orchestration that promotes the following context properties:


Because I am going to be looping through a single message, I am unable to promote values in a loop, so I need to escape the loop to promote the values.

Create an orchestration that will be called from within the loop to send it to the Microsoft’s batching orchestration. In this case I am going to create a new project called InvoiceBatcher, and the in the project create an orchestration. Add the following references:

C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Edi.BaseArtifacts.dll
C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Edi.BatchingOrchestration.dll

Reference the EDI 810 project.

Setup objects and configuration for the orchestration

1. CorrelationType which contains the context properties


2. Multi-part Message Type called EDIType representing the 810, also change the Type Modifier to Public (because we are going to be sending data to this orchestration outside of this project

3. EDIPortType which is a one way port type that points to the multi-part message type created in step 2.

4. Create a Correlation Set that is based on the CorrelationType created in step 1.

5. Create a message called OutEDIMsg that is based on the EDIType created in step 2.

6. Create a Port called Port and referencing the EDIPortType that was created in Step 3 and set it to Direct and direction set to Send.

7. Create an Int32 Orchestration Parameter called PartyNo with a direction of In

8. Create a Message Parameter called EDIMsg based on the EDIType created in step 2 with a direction of in.

9. Click on the Orchestration surface and change the Type Modifier to Public so it can be accessed by other orchestrations that will be referencing this assembly

Your orchestration view should look like this:

Orchestration Objects

The orchestration surface should look like this:


The code in the Promote Context is this:


On the Send EDI Message, send the OutEDIMsg and make sure that the Initializing Correlation Set is ‘CorrelationSet’

Deploy it to the BizTalk EDI Application

Next is to create the batch release process. The first thing we need to do is create a schema that represents the table in the management database.

Create a new project called PAM and create a schema called PAMRequest.xsd. Open the newly created schema in the XML editor, not the BizTalk Schema editor and paste the following code:

<?xml version="1.0"?>
<xs:schema xmlns:tns="http://PAM_Trigger" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://PAM_Trigger" xmlns:xs="">
  <xs:element name="Request">
        <xs:element xmlns:updategram="urn:schemas-microsoft-com:xml-updategram" updategram:Prefix="updg" minOccurs="1" maxOccurs="unbounded" name="sync">
              <xs:element updategram:Prefix="updg" minOccurs="0" maxOccurs="unbounded" name="after">
                    <xs:element minOccurs="0" maxOccurs="unbounded" name="PAM_Control">
                        <xs:attribute name="DestinationParty" type="xs:string" />
                        <xs:attribute name="EdiMessageType" type="xs:short" />
                        <xs:attribute name="ActionType" type="xs:string" />
                        <xs:attribute name="ActionDateTime" type="xs:string" />
                        <xs:attribute name="UsedOnce" type="xs:boolean" />
  <xs:element name="Response">
        <xs:element name="Success" />

Deploy the project to the BizTalk EDI Application

Now to create an orchestration that will actually release the batch of transactions.

Create a new project called BatchRelease

Add a reference to the PAM assembly.

Create a new orchestration called ReleaseEDIBatch

Set the Type Modifier to Public so any other orchestration can reference it.

Create the following orchestration objects (from bottom to top)

PamResponseType (Multi-part Message Type)

PamRequestType (Multi-part Message Type)

PAMPortType (Request/Response Port Type)

TempXML (System.XML.XMLDocument)

PAMResponseMsg (PAMResponseType)

PAMRequestMsg (PAMRequestType)

PAMPort (Specify Later, Send-Recieve direction)

PartnerNo (Direction:In, Int32)

The Orchestration View should look like this:


The orchestration surface looks like this:


The logic to create the PAM message in the message assignment shape is:

TempXML=new System.Xml.XmlDocument();
TempXML.LoadXml("<ns0:Request xmlns:ns0=\"http://PAM_Trigger\"><ns0:sync><ns0:after><ns0:PAM_Control DestinationParty=\""+System.Convert.ToString(PartnerNo)+"\" EdiMessageType=\"0\" ActionType=\"EdiBatchOverride\" ActionDateTime=\""+System.Convert.ToString(System.DateTime.Now)+"\" UsedOnce=\"0\" /></ns0:after></ns0:sync></ns0:Request>");

Deploy it to the BizTalk EDI Application

Now to create the actual Invoice orchestration, first reference the InvoiceBatcher and the BatchRelease assemblies. Create the multi-part message that represents the input message, and the port type to bring in the file from the ftp server. I created the following variables all as Int32:

ThisInvoiceNo (default value set at 0)



OriginalInformixMsg (Informix810Type)

NewInformixMsg (Inforix810Type)

EDIMsg (InvoiceBatcher.Multi-part Message Types.EDIType)


The following Orchestration View represents the setup.


The steps for this orchestration is to receive the file, count the number of invoices, set the party number, start looping while the current invoice number is less than the invoice count. In the loop, it increases the current invoice number, injects that number into the message. The map takes that newly created message and extracts the data from the input message and creates the 810 transaction. It then sends the transaction to be batched and continues creating new transactions. Once the loop completes, it releases the batch.

The orchestration looks like this:


The Set Party Number expression shape has the following code:


The Inject Number message assignment has the following code:


The map looks like this:


The arguments to the Send EDI start orchestration shape (InvoiceBatcher.BatchPromote) are the following:


The arguments to the Release Batch start orchestration shape (BatchRelease.ReleaseEDIBatch) are the following:


The last thing of mention is to set up the send port for the ReleaseEDIBatch orchestration to bind to.

In the BizTalk EDI Application, create a request response send port set it to SQL and point to the BizTalk Management database. Sent the send and receive pipelines to DefaultXML

Set the following connection information as follows:


Bind to it and you are ready to go!

  • Thank you very much man, you are well appreciated.

    I have found that I am about 1-2 years behind you in general.

    I have found your tutorials more to the point and easier to understand than the “white pages” and the MSDN help sections.

    This is the third tutorial/walkthrough that I’ve needed within a month of two of you writing it.

    Thanks a lot!
    Furthermore, if you did a Biztalk Hl7 for dummies or Biztalk 101 for HL7/EDI I would buy it.

  • Tim wrote:
    Thanks for the great tutorial. I am trying to implement your solution for my project, and am getting the following error in the Batch Promote orchestration for each item in the batch:

    A batch item failed persistence Item-ID 45a8d516-a23c-4ba6-a69c-edb1a16458e9 OperationType MAIO_CommitBatch Status -1061151998 ErrorInfo The published message could not be routed because no subscribers were found. .

    I am uncertain if I configured the direct send port named “Port” correctly, and this didn’t seem to be spelled out in the tutorial. Could you share that configuration? Is there additional party configuration I need to do in terms of setting up filters beyond the steps called for in your tutorial?

    Thanks in advance. Like I say, great tutorial!


    Our answer: Open up the subscription query in the mgmt console and see what the orchestration is looking for to activate and look at the message and see what the context properties are and see what the difference are.

  • sangeetha

    what should be the message part type in EDIType of Invoicebatcher Orchestration?

  • Thank you for excelllent tutorial, I was on a project recently where this type of controll was implemented. Thank you for Trail Blazing!

  • dev

    This is good article about batching and gives more insight about EDI batching.

    Does the partyno actually be a party in Biztalk. can it be any number but unique to the orchestration instance?


  • The party number is the number at the top of the EDI properties that BizTalk EDI ASM uses to determine how to wrap the group of transactions in a functional group and interchange, what the ids are and what delimiters to use.

  • Ritesh

    Nice post. One think I would mentione here:
    When you create a batch, the Batch name on the EDI Property>Batches screen should be – in this format – “[Partyname][X12]Default”. eg. if your party name is – “IBM” and you are working with X12 transactions, then your party name should be – “IBMX12Default”

  • Kiran

    is there any specific reason to use start orchestration, if we use call orchestration we get more control right for batch promote and release edi orchestrations?

  • Kiran

    I have implemented my solution in a similar way, however very randomly trigger goes first to the batching orchestration… rather than the individual edi messages… and I get a warning.. THERE ARE NO BATCH ELEMENTS TO SEND FOR BATCH…..