Splitting a Flat-file with multiple records to multiple files with single record.


In BizTalk we can split a flat-file with multiple records to multiple files with single record.
This can be done with Envelope schema or using the below method.

Scenario : 

Suppose we have a input flat-file with multiple records of Purchase Orders of various customers.
Output should be a different file with single Purchase order of the customer.

Solution :

Input File structure:

191,201,44,Sam
192,202,45,John
193,203,46,Jeorge
194,204,47,Kelly
195,205,48,Kristin
196,206,49,Kim


Note : There is an enter at the end of the file.

Source Schema :

Create a source schema with a parent record Root and its child record PurchaseOrder.
Set child delimiter for Root node to 0x0D 0x0A i.e. enter and child order to Postfix.













In the above pic highlighted is the properties that we need to set i.e Group Max occur =1 and Group Min occur =0.

PurchaseOrder record properties :

Set child delimiter for PurchaseOrder node to ',' i.e. comma and child order to Infix.













In the above pic highlighted is the properties that we need to set i.e Max occur =1 and Min occur =0.


Destination Schema :














Map :














Receive Pipeline :














Output Files :














There were 6 records in the input files, hence in there are 6 XML files in the output.

Port Creation\Configuration :

Receive Port & Receive Location- Create a receive port and a receive location after deploying the solution. Select receive pipeline created in the solution on receive location and poll for a specific location using *.txt mask.

Send Port - Create a send port with filter property set to receive port name and in outbound map select the map created in the solution.

How this works :

Setting the Max occur property =1 is responsible for debatching the flat file. When we set Max occur prperty = unbounded, it automatically receive multiple records of the file. In the same manner if we set Max occur =1 schema will only take a single record at a time, mapping will be done for this record and a separate file will be created for this record. Actually all this work is done by the receive pipeline. It will debatch the file while seeing the Max occur property =1 set on the schema.


1 comment:

  1. Can we customize the max occur property to 10 or 20, i have a requirement where i need to process 8M records in single file, so wanted to spit the records with around 500 each file.

    Thank
    Vishal Gupta

    ReplyDelete