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.
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.
Input File structure:
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 :
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.