1

I'm trying to do a map on BizTalk 2013, and I'm blocked at this mapping problem (using mapper):

Input message:

<DetailsResponse>
    <HeaderDetails>
        <DocumentNumber>322</DocumentNumber>
    </HeaderDetails>
    <ItemDetails>
        <item>
            <DocumentNumber>322</DocumentNumber>
            <ItemNumber>1</ItemNumber>
            <MaterialNumber>40</MaterialNumber>
            <Description>random description 1</Description>
        </item>
        <item>
            <DocumentNumber>322</DocumentNumber>
            <ItemNumber>2</ItemNumber>
            <MaterialNumber>41</MaterialNumber>
            <Description>random description 2</Description>
        </item>
    </ItemDetails>
    <ScheduleDetails>
        <item>
            <DocumentNumber>322</DocumentNumber>
            <ItemNumber>1</ItemNumber>
            <ConfirmedQuantity>2.000</ConfirmedQuantity>
        </item>
        <item>
            <DocumentNumber>322</DocumentNumber>
            <ItemNumber>2</ItemNumber>
            <ConfirmedQuantity>3.000</ConfirmedQuantity>
        </item>
    </ScheduleDetails>
</DetailsResponse>

Intended output message:

<Response>
    <Data>
        <Items>
            <Item>
                <LineNumber>
                    <Internal>1</Internal>
                </LineNumber>
                <ConfirmedQuantity>
                    <Value>2</Value>
                </ConfirmedQuantity>
                <Article>
                    <Number>40</Number>
                    <Description>random description 1</Description>
                </Article>
            </Item>
            <Item>
                <LineNumber>
                    <Internal>2</Internal>
                </LineNumber>
                <ConfirmedQuantity>
                    <Value>3</Value>
                </ConfirmedQuantity>
                <Article>
                    <Number>41</Number>
                    <Description>random description 2</Description>
                </Article>
            </Item>
        </Items>
    </Data>
</Response>

I want to map ItemsDetails and ScheduleDetails to Item, by "merging" their data based on ItemNumber. I already tried a lots of things but wasn't able to do it yet.

I couldn't find any example about this.Does this pattern have any particular name?

If anyone has any idea that they can share, it would be appreciated.

MasterAM
  • 16,283
  • 6
  • 45
  • 66
Ricardo
  • 99
  • 2
  • 10
  • This can be done only using Call Xslt Template functoids. Here are some explanations: http://adventuresinsidethemessagebox.wordpress.com/2012/04/01/merging-details-from-two-messages-using-a-biztalk-map/ – kletnoe Jan 29 '14 at 10:14

2 Answers2

0

The only way I can think to maybe get this working with Functoids is to link ItemDetails and ScheduleDetails with one or more Looping Functoids and using an Equal Functoid to filter the ScheduleDetails based on the current ItemDetail ItemNumber.

It that doesn't work out, your only other option is custom Xslt. A Call Template would be pretty straight forward.

Johns-305
  • 10,908
  • 12
  • 21
0

If you convert your map to vanilla XSLT, then the mapping becomes straightforward :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:key name="itemSchedules" 
            match="/DetailsResponse/ScheduleDetails/item" 
            use="concat(DocumentNumber,'-',ItemNumber)" />

   <xsl:template match="/DetailsResponse">
      <Response>
         <Data>
            <Items>
               <xsl:apply-templates select="ItemDetails/item" />
            </Items>
         </Data>
      </Response>
   </xsl:template>

   <xsl:template match="item">
      <Item>
         <LineNumber>
            <Internal>
               <xsl:value-of select="ItemNumber"/>
            </Internal>
         </LineNumber>
         <ConfirmedQuantity>
            <Value>
               <xsl:value-of select="format-number(key('itemSchedules', 
                concat(DocumentNumber,'-',ItemNumber))/ConfirmedQuantity,0)" />
            </Value>
         </ConfirmedQuantity>
         <Article>
            <Number>
               <xsl:value-of select="MaterialNumber"/>
            </Number>
            <Description>
               <xsl:value-of select="Description"/>
            </Description>
         </Article>
      </Item>
   </xsl:template>
</xsl:stylesheet>

The xsl:key retains an index of references to the schedule details 'part' of the puzzle, and we create a catenated key of DocumentNumber and ItemNumber.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285