Multiply Repeating Records
Hi , i have a requirement. each time i have a new record from the source, i need to  multiply the records twice. But all data except the last fields will have the constant values in the destination, under the same record. Both the source and destination are repeating records. (We have only one record in the destination, where all this has to be mapped into.) 
February 24th, 2015 9:09am

Is this in the same output message or do you need to copy the entire message?
Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 10:41am

Hi,

Give us a sample input instance and expected output..We will try..

February 24th, 2015 11:37am

Hi John-305 ,Its not the same output message. i have provided a sample. the last 3 fields will be constant values that are different for both records.

Hi Ashwin, the following are the sample input and expected output files:

INPUT:

- <RAL_RECORD xmlns="">

<RECORD_TYPE>Part</RECORD_TYPE>

<Filialnum>12345</Filialnum>

<Date>20150225</Date>

<Code>P</Code>

<uniqID>110</uniqID>

<NetValue>455.56</NetValue>

<Volume>1</Volume>

</RAL_RECORD>

OUTPUT:

<Sample> ---- recrd 1

<A>Part</A>

<B>12345</B>

<C>20150225</C>

<D>Unique ID from DB</D>

 <E>Constant value "xyz"</E>

<F>Constant value "abc"</F>

</Sample>

<Sample> ---- record 2

 <A>Part</A>

<B>12345</B>

<C>20150225</C>

<D>Unique ID from DB</D>

<E>Constant value "asd"</E>

<F>Constant value "qwe"</F>

</Sample>

Input and out ar both repeating records.

Fields <A><B><C> are direct mapping.

The field <D>, that is the unique id generated from DB is to be same in the 2nd occurance of the record.


Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 1:38am

For the following input XML:

<Root xmlns="soucenamespace">
  <RAL_RECORD xmlns="">
    <RECORD_TYPE>Part</RECORD_TYPE>
    <Filialnum>12345</Filialnum>
    <Date>20150225</Date>
    <Code>P</Code>
    <uniqID>110</uniqID>
    <NetValue>455.56</NetValue>
    <Volume>1</Volume>
  </RAL_RECORD>
  <RAL_RECORD xmlns="">
    <RECORD_TYPE>OtherPart</RECORD_TYPE>
    <Filialnum>12346</Filialnum>
    <Date>20150226</Date>
    <Code>P</Code>
    <uniqID>110</uniqID>
    <NetValue>455.56</NetValue>
    <Volume>1</Volume>
  </RAL_RECORD>
</Root>

You can use the following custom XSLT (you will have to do the "Unique ID from DB" logic yourself, since I have no way of knowing how this is done today)

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:source="soucenamespace" exclude-result-prefixes="source">
  <xsl:template match="source:Root">
    <Output>
      <xsl:for-each select="RAL_RECORD">
        <xsl:variable name="UniqueID" select="'hardcoded'" />
        <!--Change to "fetch from DB logic" -->
        <Sample>
          <A>
            <xsl:value-of select="RECORD_TYPE" />
          </A>
          <B>
            <xsl:value-of select="Filialnum" />
          </B>
          <C>
            <xsl:value-of select="Date" />
          </C>
          <D>
            <xsl:value-of select="$UniqueID" />
          </D>
          <E>
            <xsl:text>xyz</xsl:text>
          </E>
          <F>
            <xsl:text>abc</xsl:text>
          </F>
        </Sample>
        <Sample>
          <A>
            <xsl:value-of select="RECORD_TYPE" />
          </A>
          <B>
            <xsl:value-of select="Filialnum" />
          </B>
          <C>
            <xsl:value-of select="Date" />
          </C>
          <D>
            <xsl:value-of select="$UniqueID" />
          </D>
          <E>
            <xsl:text>asd</xsl:text>
          </E>
          <F>
            <xsl:text>qwe</xsl:text>
          </F>
        </Sample>
      </xsl:for-each>
    </Output>
  </xsl:template>
</xsl:stylesheet>

Morten la Cour

February 25th, 2015 2:19am

This is where Table-Extractor and Table-Looping Functiod comes into play.

Do the following:

  1. Drag a Table-Looping Functiod
  2. In Table-Looping Functiod, specify 2 a constant (which defines the scope for you number of repeating records you want).
  3. In Table-Looping Functiod, specifiy  6 a constant (which defines the number of output fields, in your case you have six fields)
  4. Link RECORD_TYPE from source schema to Table-Looping Functiod as 3<sup>rd</sup> parameter.
  5. Link Filialnum from source schema to Table-Looping Functiod as 4<sup>rd</sup> parameter.
  6. Link Date from source schema to Table-Looping Functiod as 5<sup>rd</sup> parameter.
  7. Now link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayOne. This will be the 6<sup>th</sup> parameter for Table-Looping Functiod.
  8. Again link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayTwo. This will be the 7<sup>th</sup> parameter for Table-Looping Functiod.
  9. Hard code xyz as 8th parameter
  10. Hard code abc as 9th parameter
  11. Hard code asd as 10th parameter
  12. Hard code qwe as 11th parameter
  13. Now right-click the Table-Looping Functiod and select Configure Table Looping Grid and configure the grid as show above.
  14. Drag a Table Extractor fuctiod for each output. And link Table-Looping Functiod as its first parameter and specify the column names which you want to output..like 1 or 2 or 3 or 4 or 5 or 6

So for the given input:

<RAL_RECORD xmlns="">

	<RECORD_TYPE>Part</RECORD_TYPE>

	<Filialnum>12345</Filialnum>

	<Date>20150225</Date>

	<Code>P</Code>

	<uniqID>110</uniqID>

	<NetValue>455.56</NetValue>

	<Volume>1</Volume>

</RAL_RECORD>


<OutputInstance>
  <Sample>
    <A>Part</A>
    <B>12345</B>
    <C>20150225</C>
    <D>Unique ID from DB-LetsSayOne</D>
    <E>xyz</E>
    <F>abc</F>
  </Sample>
  <Sample>
    <A>Part</A>
    <B>12345</B>
    <C>20150225</C>
    <D>Unique ID from DB-LetsSayTwo</D>
    <E>asd</E>
    <F>qwe</F>
  </Sample>
</OutputInstance>

Regards,

M.R.ashwin Prabhu

Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 6:14am

This is where Table-Extractor and Table-Looping Functiod comes into play.

Do the following:

  1. Drag a Table-Looping Functiod
  2. In Table-Looping Functiod, specify 2 a constant (which defines the scope for you number of repeating records you want).
  3. In Table-Looping Functiod, specifiy  6 a constant (which defines the number of output fields, in your case you have six fields)
  4. Link RECORD_TYPE from source schema to Table-Looping Functiod as 3<sup>rd</sup> parameter.
  5. Link Filialnum from source schema to Table-Looping Functiod as 4<sup>rd</sup> parameter.
  6. Link Date from source schema to Table-Looping Functiod as 5<sup>rd</sup> parameter.
  7. Now link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayOne. This will be the 6<sup>th</sup> parameter for Table-Looping Functiod.
  8. Again link the output of the functiod which gets the unique id from db, for above example I have hard-coded it as Unique ID from DB-LetsSayTwo. This will be the 7<sup>th</sup> parameter for Table-Looping Functiod.
  9. Hard code xyz as 8th parameter
  10. Hard code abc as 9th parameter
  11. Hard code asd as 10th parameter
  12. Hard code qwe as 11th parameter
  13. Now right-click the Table-Looping Functiod and select Configure Table Looping Grid and configure the grid as show above.
  14. Drag a Table Extractor fuctiod for each output. And link Table-Looping Functiod as its first parameter and specify the column names which you want to output..like 1 or 2 or 3 or 4 or 5 or 6

So for the given input:

<RAL_RECORD xmlns="">

	<RECORD_TYPE>Part</RECORD_TYPE>

	<Filialnum>12345</Filialnum>

	<Date>20150225</Date>

	<Code>P</Code>

	<uniqID>110</uniqID>

	<NetValue>455.56</NetValue>

	<Volume>1</Volume>

</RAL_RECORD>

Output as follows:

<OutputInstance>
  <Sample>
    <A>Part</A>
    <B>12345</B>
    <C>20150225</C>
    <D>Unique ID from DB-LetsSayOne</D>
    <E>xyz</E>
    <F>abc</F>
  </Sample>
  <Sample>
    <A>Part</A>
    <B>12345</B>
    <C>20150225</C>
    <D>Unique ID from DB-LetsSayTwo</D>
    <E>asd</E>
    <F>qwe</F>
  </Sample>
</OutputInstance>

Regards,

M.R.ashwin Prabhu

February 25th, 2015 2:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics