Friday, 13 October 2006

Hi

A user in the microsoft.public.biztalk.general newsgroup has a challenge he'd like solved.

Basically, he has this structure:

<Root>
  <Employee>
     <EmployeeID>1</EmployeeID>
     <JobsAssigned>10</JobsAssigned>
  </Employee>
  <Employee>
     <EmployeeID>2</EmployeeID>
     <JobsAssigned>5</JobsAssigned>
  </Employee>
  <Employee>
     <EmployeeID>3</EmployeeID>
     <JobsAssigned>8</JobsAssigned>
  </Employee>
</Root>

And he needs to find the EmployeeID of the employee that has the least jobs assigned to him/her. In this case, he needs the value "2".

This is a case, where the "Cumulative Minimum" functoid can be used.

So, I have this input schema:

and I have this fictitious output schema:

To do the task, I use this map:

Basically, I just map the fields, and then I make sure the "MinValues"-record is only created when the JobsAssigned value is equal to the cumulative minimum of the JobsAssigned.

The "Cumulative Minimum" functoid will return the smallest number of all the numbers it is given as input.

So, given the above mentioned input instance, the output of this map will be:

<ns0:OutputRoot xmlns:ns0="http://CumulativeMinimum.OutputSchema">
<MinValues>
  <Employee>2</Employee>
  <JobsAssigned>5</JobsAssigned> 
</MinValues>
</ns0:OutputRoot>

which, luckily, was what we needed :-)

Given an instance with more than one Employee hacing the same number of JobsAssigned and if this number is the minimum, the map will actually create a node for each.

As I don't know more of what the question-asker wants, I will let this be enough for now. Should it not be ok to return more than one EmployeeID in the output, the map will need to be changed.

I hope this has helped someone.

You can find a BizTalk 2006 project here: CumulativeMinimum.zip (4,51 KB)

The same will work for BizTalk 2004 - I just haven't been bothered creating the example. Let me know if you need it.

--

eliasen

Friday, 13 October 2006 22:23:30 (Romance Daylight Time, UTC+02:00)  #    Comments [0]  | 

Theme design by Jelle Druyts