Skip to Content
0
Mar 31, 2011 at 10:05 PM

mapping doubt, n values depending on field value

11 Views

Hi All,

I have this source structure:

<sourceItem> (1..unbounded)
     <sourcevalue1> (1..1)
     <sourcevalue2> (1..1)

Both sourcevalues are inside sourceItem.

Target structure is as this:

<targetItem> (1..unbounded)
     <targetvalue1> (1..1)
     <targetnode> (1..unbounded)
          <targetvalue2> (1..1)

Targetvalue1 is inside targetItem and targetnode is at same level as targetvalue1. Targetvalue2 is inside targetnode.

Logic for creation of targetItem (which is done and working as in thread mapping issue, maybe need UDF) is for example:

The sourcefields got values 1, 2, 2, 2 and 3.

Then, targetfield is created for each nonrepeteable sourcefield value, in this case it need to be created 3 times.

What I don't know if PI mapping can do this without UDF, is:

1) targetvalue1 need to get corresponding value of targetItem.

2) targetnode need to be created as many repeats of targetvalue1.

3) targetvalue2 need to have each value of corresponding context of sourcevalue2.

If it was not clear, let me give you an example. When this source example is mapped:

<sourceItem>
     <sourcevalue1>1</sourcevalue1>
     <sourcevalue2>A</sourcevalue2>
</sourceItem>
<sourceItem>
     <sourcevalue1>2</sourcevalue1>
     <sourcevalue2>B</sourcevalue2>
</sourceItem>
<sourceItem>
     <sourcevalue1>2</sourcevalue1>
     <sourcevalue2>C</sourcevalue2>
</sourceItem>
<sourceItem>
     <sourcevalue1>2</sourcevalue1>
     <sourcevalue2>D</sourcevalue2>
</sourceItem>
<sourceItem>
     <sourcevalue1>3</sourcevalue1>
     <sourcevalue2>E</sourcevalue2>
</sourceItem>

we need to get this target example:

<targetItem>
     <targetvalue1>1</targetvalue1>
     <targetnode>
          <targetvalue2>A</targetvalue2>
     </targetnode>
</targetItem>
<targetItem>
     <targetvalue1>2</targetvalue1>
     <targetnode>
          <targetvalue2>B</targetvalue2>
     </targetnode>
     <targetnode>
          <targetvalue2>C</targetvalue2>
     </targetnode>
     <targetnode>
          <targetvalue2>D</targetvalue2>
     </targetnode>
</targetItem>
<targetItem>
     <targetvalue1>3</targetvalue1>
     <targetnode>
          <targetvalue2>E</targetvalue2>
     </targetnode>
</targetItem>

And I can't find a way to do it.

The only thing is now done is the correct creation of the targetItem.

Any genious knows how can this be solved?

Thanks in advice!

Regards.