cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue - Urgent

Former Member
0 Kudos

Source

<source>

<Record>

<Date>5/15/2008</Date>

<DocType>ZL</DocType>

<CompCode>1010</CompCode>

<GL_Account>21300119</GL_Account>

<Amount>14,357.83</Amount>

</Record>

<Date>5/5/2008</Date>

<DocType>ZL</DocType>

<CompCode>1020</CompCode>

<GL_Account>21300119</GL_Account>

<Amount>60.00</Amount>

</Record>

</source>

-


Expected Target:

<Target>

<Record>

<Date>5/15/2008</Date>

<DocType>ZL</DocType>

<CompCode>1010</CompCode>

<GL_Account>21300119</GL_Account>

<Amount>14,357.83</Amount>

</Record>

</Target>

<Target>

<Record>

<Date>5/5/2008</Date>

<DocType>ZL</DocType>

<CompCode>1020</CompCode>

<GL_Account>21300119</GL_Account>

<Amount>60.00</Amount>

</Record>

</Target>

I tried and I was able to produce, multiple targets nodes but not the record element in target elements.

When the "dateCompcode" changes a target node should be generated and all records having same "dateCompcode" should be in one target.

reg

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

It is a simple grouping solution using XSLT.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0" />

   <xsl:key match="source/Record" name="keyDate_CompCode" use="concat(Date, ' ', CompCode)" />

   <xsl:template match="/">
      <Output>
         <xsl:for-each select="source/Record[generate-id(.) = generate-id(key('keyDate_CompCode', concat(Date, ' ', CompCode))[1]) ]">
            <xsl:variable name="groupRecord" select="key('keyDate_CompCode', concat(Date, ' ', CompCode))" />
            <Target>
               <xsl:for-each select="$groupRecord">
                  <xsl:copy-of select="." />
               </xsl:for-each>
            </Target>
         </xsl:for-each>
      </Output>
   </xsl:template>
</xsl:stylesheet>

BR

Sameer

Former Member
0 Kudos

Sameer,

Thanks for your reply. Let me try that and I will let you know.

reg

Former Member
0 Kudos

Sameer,

could you please tell me if you have any idea reg the memory consumptions of XSLT mapping?

We are talking about 10K records - flat file.

reg

Edited by: naveen chitluri on Jul 13, 2008 4:22 PM

justin_santhanam
Active Contributor
0 Kudos

Hi Naveen,

We can do this in Message Mapping itself. Do you need to compare the CompCode +date only with every consecutive records or the whole file?

Did you got my point? Compcode will come in sorted order only, right?

raj.

Former Member
0 Kudos

I think the date comes in the asending order

Just have a look at this pay load:


<MT_Source>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>242.85</Amount>
</Record>
<Record>
<Date>05/12/2008</Date>
<DocType>ZL</DocType>
<CompCode>1020</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
<Date>05/12/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Source>

What I am looking at is that, whenever the datecompCode changes, New Node of MT_Target is created and all the records with same datecompCode will come under one MT_Target Node

Like:


<MT_Target>
<Record>
*<Date>5/15/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
*<Date>5/15/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>242.85</Amount>
</Record>
</MT_Target>

<MT_Target>
<Record>
*<Date>05/12/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1020</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Target>

<MT_Target>
<Record>
*<Date>05/12/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Target>

Former Member
0 Kudos

I am not 100% on the memory consumption front, I think you can just try testing my solution and check it out for yourself. But the grouping will work fine.

BR

Former Member
0 Kudos

Raj,

Just imagine your case and could you please tell me how we can do it?

reg