Skip to main content Skip to complementary content

Mapping a recursive loop

Use a RecursiveLoop function to map an input recursive loop to a similar output loop.

Before you begin

You have created a map with an input and output structure. For this example, you can use CustomComponent as input and Component as output. These structures can be found under Other Projects > Examples > Structures > Recursive > Component.

About this task

In this example, the input structure has a Component element containing a SubComponents loop. This is a recursive loop that uses the same elements as its parent.

This recursive loop should be mapped to a similar recursive loop in the output structure.

This map is available in Other Projects > Examples > Maps > Looping > LoopSkipLevel.

Procedure

  1. Drag the input Component element to the corresponding output element.
  2. In the input structure, right-click the SubComponents loop and click Expand Recursive Elements, then right-click it again and click Expand All to show its children.
  3. Repeat the previous steps on the output loop.
  4. Drag and drop a RecursiveLoop function in the Loop tab of the output SubComponents element.
  5. Drag and drop the input SubComponents element on the Input Map Element argument.
  6. Drag the input SubComponents element on the corresponding output to map their children.

Results

With the RecursiveLoop function, you only need to map the first level of the recursive loop. The same mapping is applied to all subsequent levels present in the input file. You can use the Test Run button to see the output based on the sample input file. In this example, the output looks like this:
<Component>
  <Id>1</Id>
  <PartNumber>45I1122</PartNumber>
  <Quantity>1</Quantity>
  <Description>Main Component</Description>
  <SubComponents>
    <Id>102</Id>
    <PartNumber>12ZSSS</PartNumber>
    <Quantity>5</Quantity>
    <Description>Door Assembly</Description>
    <SubComponents>
      <Id>201</Id>
      <PartNumber>88-B</PartNumber>
      <Quantity>2</Quantity>
      <Description>Hinge</Description>
    </SubComponents>
    <SubComponents>
      <Id>202</Id>
      <PartNumber>GF4488-B</PartNumber>
      <Quantity>1</Quantity>
      <Description>Lock</Description>
    </SubComponents>
    <SubComponents>
      <Id>203</Id>
      <PartNumber>288333-I10023</PartNumber>
      <Quantity>1</Quantity>
      <Description>Sign</Description>
    </SubComponents>
  </SubComponents>
  <SubComponents>
    <Id>302</Id>
    <PartNumber>12IQWO</PartNumber>
    <Quantity>14</Quantity>
    <Description>Window Assembly</Description>
    <SubComponents>
      <Id>401</Id>
      <PartNumber>88-C</PartNumber>
      <Quantity>2</Quantity>
      <Description>Window Lock</Description>
    </SubComponents>
    <SubComponents>
      <Id>402</Id>
      <PartNumber>RT433</PartNumber>
      <Quantity>1</Quantity>
      <Description>Window Frame</Description>
    </SubComponents>
    <SubComponents>
      <Id>403</Id>
      <PartNumber>15</PartNumber>
      <Quantity>1</Quantity>
      <Description>Glass</Description>
    </SubComponents>
  </SubComponents>
</Component>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!