Geeks With Blogs
Bill Osuch - Random geek notes

BizTalk’s HIPAA X12 schemas have several repeating date/time segments in them, where the XML winds up looking something like this:


The corresponding EDI segments would look like this:


The DateTimeQualifier element indicates whether it’s the start date or end date – 232 for start, 233 for end. So in this example (an X12 835) we’re saying the statement starts on 3/1/2012 and ends on 3/2/2012.

When you’re mapping from some other data format, many times your start and end dates will be within the same node, like this:


So how do you map from that and create two repeating segments in your destination map? You could connect both the <Begin> and <End> nodes to a looping functoid, and connect its output to <DTM_StatementDate>, then connect both <Begin> and <End> to <DTM_StatementDate> … this would give you two repeating segments, each with the correct date, but how to add the correct qualifier? The answer is the Table Looping Functoid!

To test this, let’s create a simplified schema that just contains the date fields we’re mapping. First, create your input schema:


And your output schema:


Now create a map that uses these two schemas, and drag a Table Looping functoid onto it. The first input parameter configures the scope (or how many times the records will loop), so drag a link from the StatementDates node over to the functoid. Yes, StatementDates only appears once, so this would make it seem like it would only loop once, but you’ll see in just a minute.

The second parameter in the functoid is the number of columns in the output table. We want to fill two fields, so just set this to 2.

Now drag the Begin and End nodes over to the functoid.

Finally, we want to add the constant values for DateTimeQualifier, so add a value of 232 and another of 233. When all your inputs are configured, it should look like this:


Now we’ll configure the output table. Click on the Table Looping Grid, and configure it to look like this:


Microsoft’s description of this functoid says “The Table Looping functoid repeats with the looping record it is connected to. Within each iteration, it loops once per row in the table looping grid, producing multiple output loops.” So here we will loop (# of <StatementDates> nodes) * (Rows in the table), or 2 times.

Drag two Table Extractor functoids onto the map; these are what are going to pull the data we want out of the table. The first input to each of these will be the output of the TableLooping functoid, and the second input will be the row number to pull from. So the functoid connected to <DTM01_DateTimeQualifier> will look like this:


Connect these two functoids to the two nodes we want to populate, and connect another output from the Table Looping functoid to the <DTM_StatementDate> record. You should have a map that looks something like this:


Create some sample xml, use it as the TestMap Input Instance, and you should get a result like the XML at the top of this post.

Technorati Tags: , ,

Posted on Thursday, March 29, 2012 8:07 AM BizTalk , Mapping , EDI | Back to top

Comments on this post: BizTalk–Mapping repeating EDI segments using a Table Looping functoid

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

Copyright © Bill Osuch | Powered by: