Geeks With Blogs
Bill Osuch - Random geek notes

In a previous post I demonstrated how to use the Flat File Mapping Wizard to map a NACHA financial file, and at the end I said I’d follow up with a post on setting up the pipeline and preserving the header information. Well, I totally forgot about that until someone asked where the post was, so here it is…

Begin by creating the three schemas as shown in the previous post. Add a pipeline to the project, and drag the Flat file disassembler component from the toolbox to the Disassemble stage. Right-click on the component and display the Properties, and configure them as follows:

  • Document schema: NACHA_Body
  • Header schema: NACHA_Header
  • Preserve header: True
  • Trailer schema: NACHA_Trailer

Now, you’d think that setting Preserve header to True means you’d get the header added to each file, right? Nope! It’s merely added to the context collection of each message. You can see this for yourself by deploying the solution, creating a send a receive port (making sure your send port has the proper filter on it, since we’re not using an orchestration yet), stopping the send port, and dropping the test file in. The messages will be suspended, so you can view the FlatFileHeaderDocument context property:


So we need to figure out a way to create a message that has the header attached. The first step will be to create a new schema. Remember, we don’t have a single schema that includes both the header and the body. Create a new schema that has all the elements in both the header and the body schemas. This is just going to be used for regular old xml, so you don’t need to worry about delimiter, positions, etc. Call it NACHA_Full.xsd; it should look something like this:


Next we’ll create an orchestration that receives the body message, constructs a new header message by extracting the header from the context properties, and maps both of those to our new schema. Create the schema, add the send and receive ports and shapes, then add a Construct Message shape with a Message Assignment shape inside of it, and finally add another Construct Message shape with a Transform inside of it, so you have something like this:


Now let’s create the messages and variables:

  • Message: Body_Input – NACHA_Body message type
  • Message: Full_Output – NACHA_Full message type
  • Message: Header_Input – NACHA_Header message type
  • Variable: HeaderString – System.String
  • Variable: HeaderXML – System.Xml.XmlDocument

Now we’ll add the code to generate the Header_Input message. Paste this into the Message Assignment shape:

//Grab the flat file header into a string variable
HeaderString = Body_Input(XMLNORM.FlatFileHeaderDocument);

//Load HeaderString into the XML document
HeaderXML = new System.Xml.XmlDocument();

//Assign the XML to the Header message
Header_Input = HeaderXML;

The last step in the orchestration is to configure the map. Double click the Transform shape and create a new map. This map will have two inputs, so select both Header_Input and Body_Input as the Source, and Full_Output as the destination. Click OK, and the new map should open. Use a Mass Copy to join each record, as shown:


Build and Deploy, configure the Orchestration and test it. If everything works correctly, you should again have two messages, just as in the previous post, but this time they will have the header information included.

Technorati Tags:

Posted on Friday, April 20, 2012 2:50 PM BizTalk | Back to top

Comments on this post: BizTalk–Mapping a NACHA file using the Flat File Mapping Wizard and preserving header information

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Bill Osuch | Powered by: